diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index cbdf45d40..4e3155c83 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -15,6 +15,7 @@ on: permissions: contents: write + pull-requests: write jobs: bump-version: @@ -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 + + - 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 }} + 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"