From 0cdc1bbfb18d0d6b15618b2ac340827dde65908b Mon Sep 17 00:00:00 2001 From: ZHANG Yuntian <95260730+RadxaYuntian@users.noreply.github.com> Date: Fri, 8 Mar 2024 10:27:11 +0800 Subject: [PATCH] feat: ci: avoid unnecessary release steps Signed-off-by: ZHANG Yuntian --- .github/workflows/release.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 87f759b..017d833 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,8 @@ permissions: jobs: build: runs-on: ubuntu-latest + outputs: + distro: ${{ steps.distro_check.outputs.distro }} steps: - name: Checkout uses: actions/checkout@v4 @@ -47,10 +49,20 @@ jobs: path: | ${{ env.artifacts_path }}/*.deb src/packages/arm64/**/*.deb + - name: Check if the latest version is releasable + id: distro_check + run: | + version="$(dpkg-parsechangelog -S Version)" + if [[ -n "$(git tag -l "$version")" ]] + then + echo "distro=UNRELEASED" >> "$GITHUB_OUTPUT" + else + echo "distro=$(dpkg-parsechangelog -S Distribution)" >> "$GITHUB_OUTPUT" + fi release: runs-on: ubuntu-latest needs: build - if: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' }} + if: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' && needs.build.outputs.distro != 'UNRELEASED' }} steps: - name: Checkout uses: actions/checkout@v4 @@ -70,19 +82,12 @@ jobs: echo "$(dpkg-parsechangelog -S Changes)" >> $GITHUB_ENV echo '```' >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - if [[ -n "$(git tag -l "$version")" ]] - then - echo "distro=UNRELEASED" >> $GITHUB_ENV - else - echo "distro=$(dpkg-parsechangelog -S Distribution)" >> $GITHUB_ENV - fi echo "$version" > VERSION if [[ -f pkg.conf.template ]] then sed "s/VERSION/$(dpkg-parsechangelog -S Version)/g" pkg.conf.template > pkg.conf fi - name: Release - if: env.distro != 'UNRELEASED' uses: softprops/action-gh-release@v1 with: tag_name: ${{ env.version }} @@ -96,7 +101,6 @@ jobs: pkg.conf VERSION - name: Append changelog - if: env.distro != 'UNRELEASED' uses: softprops/action-gh-release@v1 with: tag_name: ${{ env.version }} @@ -105,7 +109,6 @@ jobs: ${{ env.changes }} append_body: true - name: Update Test repos - if: env.distro != 'UNRELEASED' uses: radxa-repo/update-repo-action@main with: test-repo: true