Prepare release patch (main) #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Prepare Release PR | |
| run-name: "Prepare release ${{ inputs.release-version }} (${{ github.ref_name }})" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release-version: | |
| description: Select release semantic version. | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| defaults: | |
| run: | |
| shell: bash | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| prepare: | |
| name: Prepare Release PR | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | |
| with: | |
| node-version: lts/* | |
| - name: Bump version | |
| run: | | |
| npm version "${{ inputs.release-version }}" --no-git-tag-version | |
| - name: Read version | |
| id: version | |
| run: | | |
| echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Create release branch | |
| run: | | |
| git checkout -b release/v${{ steps.version.outputs.version }} | |
| - name: Commit version change | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add package.json | |
| git commit -m "chore(release): v${{ steps.version.outputs.version }}" | |
| git push origin HEAD | |
| - name: Create Pull Request | |
| run: | | |
| gh pr create \ | |
| --title "release: v${{ steps.version.outputs.version }}" \ | |
| --body "Release v${{ steps.version.outputs.version }}" \ | |
| --base main \ | |
| --head release/v${{ steps.version.outputs.version }} \ | |
| --label "ignore for release" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |