From a5b6a822a3d121272dd153555cb233224a0d9172 Mon Sep 17 00:00:00 2001 From: walkowif <59475134+walkowif@users.noreply.github.com> Date: Wed, 5 Jul 2023 14:26:08 +0200 Subject: [PATCH] Skip release creation on rc tag (#166) --- .github/workflows/build-check-install.yaml | 6 +++++ .github/workflows/pkgdown.yaml | 6 +++++ .github/workflows/release.yaml | 26 ++++++++++++++++++++++ .github/workflows/validation.yaml | 9 ++++++++ 4 files changed, 47 insertions(+) diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 2a1d68a1..fb9dd39b 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -786,7 +786,13 @@ jobs: with: name: ${{ env.PKGBUILD }} + - name: Check if release exists + id: check-if-release-exists + uses: insightsengineering/release-existence-action@v1 + - name: Upload binaries to release ๐Ÿ”ผ + if: >- + steps.check-if-release-exists.outputs.release-exists == 'true' uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index b40c7f9c..07de9d02 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -284,7 +284,13 @@ jobs: with: name: pkgdown.zip + - name: Check if release exists + id: check-if-release-exists + uses: insightsengineering/release-existence-action@v1 + - name: Upload binaries to release โคด + if: >- + steps.check-if-release-exists.outputs.release-exists == 'true' uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bc3f8a00..9fddb393 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,6 +11,12 @@ on: description: | Github token with write access to the repository required: false + inputs: + create-rc-releases: + description: Whether releases for RC tags (e.g. v0.0.1-rc1) should be created? + required: false + default: false + type: boolean workflow_dispatch: concurrency: @@ -40,6 +46,23 @@ jobs: - name: Checkout repo ๐Ÿ›Ž uses: actions/checkout@v3 + - name: Get branch names ๐ŸŒฟ + id: branch-name + uses: tj-actions/branch-names@v6 + + - name: Check if running for rc tag ๐Ÿท๏ธ + id: rc-tag + run: | + echo "Current tag: ${{ steps.branch-name.outputs.tag }}" + current_tag="${{ steps.branch-name.outputs.tag }}" + if [ "$(echo "$current_tag" | grep -E "^v([0-9]+\.)?([0-9]+\.)?([0-9]+)(-rc[0-9]+)$")" != "" ]; then + echo "Running for rc-tag." + echo "is-rc-tag=true" >> $GITHUB_OUTPUT + else + echo "is-rc-tag=false" >> $GITHUB_OUTPUT + fi + shell: bash + - name: Generate Changelog ๐Ÿ“œ run: | RELEASE_VERSION=$(awk -F: '/Version:/{gsub(/[ ]+/,"") ; print $2}' DESCRIPTION) @@ -47,6 +70,9 @@ jobs: (awk "/^#+.*${REPOSITORY_NAME//./\.}.*${RELEASE_VERSION//./\.}$/{flag=1;next}/^#+.*${REPOSITORY_NAME//./\.}.*/{flag=0}flag" NEWS.md | grep -v "^$" || echo "* ${RELEASE_VERSION}") > RELEASE_BODY.txt - name: Create release ๐ŸŒŸ + if: >- + steps.rc-tag.outputs.is-rc-tag == 'false' || + inputs.create-rc-releases == true uses: softprops/action-gh-release@v1 with: body_path: RELEASE_BODY.txt diff --git a/.github/workflows/validation.yaml b/.github/workflows/validation.yaml index fde74bf8..417f9d2f 100644 --- a/.github/workflows/validation.yaml +++ b/.github/workflows/validation.yaml @@ -107,12 +107,21 @@ jobs: runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') steps: + - name: Checkout repo ๐Ÿ›Ž + uses: actions/checkout@v3 + - name: Download artifact โฌ uses: actions/download-artifact@v3 with: name: validation_report.pdf + - name: Check if release exists + id: check-if-release-exists + uses: insightsengineering/release-existence-action@v1 + - name: Upload report to release ๐Ÿ”ผ + if: >- + steps.check-if-release-exists.outputs.release-exists == 'true' uses: svenstaro/upload-release-action@v2 with: file: ./validation_report.pdf