Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:

permissions:
contents: write
pull-requests: write

jobs:
bump-version:
Expand All @@ -37,15 +38,46 @@ jobs:
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Bump version
run: yarn version ${{ inputs.level }}
id: bump_version
run: |
yarn version ${{ inputs.level }}
VERSION=$(node -p 'require("./package.json").version')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Commit and push
env:
VERSION: ${{ steps.bump_version.outputs.version }}
BRANCH_NAME: actions/bump-version/v${{ steps.bump_version.outputs.version }}
run: |
if [ -z "$VERSION" ]; then
echo "Version output is empty"
exit 1
fi

if git diff --quiet; then
echo "No changes to commit"
exit 1
fi

git add -A
git commit -m "Bump version (${{ inputs.level }}) for release"
git push origin HEAD:${{ github.ref_name }}
git commit -m "Bump version to v$VERSION"
git push --force origin HEAD:$BRANCH_NAME
Comment thread
zetter-rpf marked this conversation as resolved.

- name: Create PR
env:
GH_TOKEN: ${{ github.token }}
BASE_BRANCH: main
HEAD_BRANCH: actions/bump-version/v${{ steps.bump_version.outputs.version }}
PR_TITLE: Bump version to v${{ steps.bump_version.outputs.version }}
Comment thread
zetter-rpf marked this conversation as resolved.
PR_BODY: |
Version: v${{ steps.bump_version.outputs.version }}

Automated version bump generated by this workflow run:
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
gh pr create \
--repo "${{ github.repository }}" \
--base "$BASE_BRANCH" \
--head "$HEAD_BRANCH" \
--title "$PR_TITLE" \
--body "$PR_BODY"
Comment thread
zetter-rpf marked this conversation as resolved.
Loading