From 148b9d17c5bc63d74b8844acc2d4c1391b2776e2 Mon Sep 17 00:00:00 2001 From: Nick Le Large Date: Thu, 7 Nov 2024 16:27:46 +0100 Subject: [PATCH] Combine version bump and release workflows An action using the GITHUB_TOKEN cannot trigger another workflow. So to create a new release after a version bump, we simply run the release in the same workflow. See https://github.com/orgs/community/discussions/27028#discussioncomment-3254360 --- ...l => bump-version-and-create-release.yaml} | 33 +++++++++++++++++-- .github/workflows/create-release.yaml | 31 ----------------- 2 files changed, 31 insertions(+), 33 deletions(-) rename .github/workflows/{bump-version.yaml => bump-version-and-create-release.yaml} (66%) delete mode 100644 .github/workflows/create-release.yaml diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version-and-create-release.yaml similarity index 66% rename from .github/workflows/bump-version.yaml rename to .github/workflows/bump-version-and-create-release.yaml index ddb2b71..ab523a2 100644 --- a/.github/workflows/bump-version.yaml +++ b/.github/workflows/bump-version-and-create-release.yaml @@ -1,4 +1,4 @@ -name: Bump version +name: Bump version and create release on: pull_request: types: @@ -8,11 +8,13 @@ on: - github_action # TODO: Remove before merge jobs: - build: + bump-version: if: github.event.pull_request.merged == true runs-on: ubuntu-latest permissions: contents: write + outputs: + new_tag: ${{ steps.bump_version.outputs.new_tag }} steps: - name: Check out the repository uses: actions/checkout@v4 @@ -48,3 +50,30 @@ jobs: run: | git tag ${{ steps.bump_version.outputs.new_tag }} git push origin ${{ steps.bump_version.outputs.new_tag }} + + create-release: + needs: bump-version + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Build release packages + uses: docker/build-push-action@v6 + with: + tags: | + util_caching_release + push: false + target: release + + - name: Copy release packages + run: | + mkdir -p /tmp/artifacts/ + docker run --rm -v /tmp/artifacts:/tmp/artifacts util_caching_release cp -r /release /tmp/artifacts/ + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + artifacts: "/tmp/artifacts/release/*" + tag: ${{ needs.bump-version.outputs.new_tag }} + + diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml deleted file mode 100644 index e7a76f1..0000000 --- a/.github/workflows/create-release.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: Create Release -on: - push: - tags: - - "v*" - -jobs: - build-and-release: - permissions: - contents: write - - runs-on: ubuntu-latest - steps: - - name: Build release packages - uses: docker/build-push-action@v6 - with: - tags: | - util_caching_release - push: false - target: release - - - name: Copy release packages - run: | - mkdir -p /tmp/artifacts/ - docker run --rm -v /tmp/artifacts:/tmp/artifacts util_caching_release cp -r /release /tmp/artifacts/ - - - name: Create Release - uses: ncipollo/release-action@v1 - with: - artifacts: "/tmp/artifacts/release/*" -