Skip to content

Commit

Permalink
Split compute-version and update-version-file into separate jobs
Browse files Browse the repository at this point in the history
Clone full history in release action to access the newly created tag

Add compute version as dependency of release job
  • Loading branch information
ll-nick committed Nov 12, 2024
1 parent 966334f commit a4470ab
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions .github/workflows/bump-version-and-create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- main

jobs:
bump-version:
compute-version:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
Expand All @@ -17,8 +17,6 @@ jobs:
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Read version from file
run: |
Expand All @@ -37,31 +35,46 @@ jobs:
INITIAL_VERSION: ${{ env.INITIAL_VERSION }}
WITH_V: true


update-version-file:
if: github.event.pull_request.merged == true
needs: compute-version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Update version file with new version
run: |
echo "New version: ${{ steps.bump_version.outputs.new_tag }}"
echo "VERSION=${{ steps.bump_version.outputs.new_tag }}" > version
echo "New version: ${{ needs.compute-version.outputs.new_tag }}"
echo "VERSION=${{ needs.compute-version.outputs.new_tag }}" > version
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add version
git commit -m "chore: update version file to ${{ steps.bump_version.outputs.new_tag }}"
git commit -m "chore: update version file to ${{ needs.compute-version.outputs.new_tag }}"
git push
- name: Push new tag
run: |
git tag ${{ steps.bump_version.outputs.new_tag }}
git push origin ${{ steps.bump_version.outputs.new_tag }}
git tag ${{ needs.compute-version.outputs.new_tag }}
git push origin ${{ needs.compute-version.outputs.new_tag }}
create-release:
needs: bump-version
needs: [compute-version, update-version-file]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repository and pull the new tag
uses: actions/checkout@v4
with:
ref: ${{ needs.bump-version.outputs.new_tag }}
fetch-depth: 0
ref: ${{ needs.compute-version.outputs.new_tag }}

- name: Build release packages
uses: docker/build-push-action@v6
Expand All @@ -81,6 +94,6 @@ jobs:
uses: ncipollo/release-action@v1
with:
artifacts: "/tmp/artifacts/release/*"
tag: ${{ needs.bump-version.outputs.new_tag }}
tag: ${{ needs.compute-version.outputs.new_tag }}
body: ${{ github.event.pull_request.body }}

0 comments on commit a4470ab

Please sign in to comment.