Prepare release patch (main) #6
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: Generate token | |
| id: generate_token | |
| uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1 | |
| with: | |
| app-id: ${{ vars.GH_APP_ID }} | |
| private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
| - name: Create release branch and commit | |
| id: create_release_branch | |
| run: | | |
| BRANCH_NAME="release/v${{ steps.version.outputs.version }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git checkout -b "$BRANCH_NAME" | |
| git add package.json | |
| git commit -m "chore(release): v${{ steps.version.outputs.version }}" | |
| git push --set-upstream origin "$BRANCH_NAME" | |
| echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
| - name: Create Pull Request | |
| env: | |
| GH_TOKEN: ${{ steps.generate_token.outputs.token }} | |
| run: | | |
| gh pr create \ | |
| --base main \ | |
| --head ${{ steps.create_release_branch.outputs.branch }} \ | |
| --title "release: v${{ steps.version.outputs.version }}" \ | |
| --body "Release v${{ steps.version.outputs.version }}" \ | |
| --label "ignore for release" \ | |
| --assignee "${{ github.repository_owner }}" |