Create bump package versions PR #5
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: Create bump package versions PR | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| create-bump-pr: | |
| name: Create bump package versions PR | |
| environment: CI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - uses: ./.github/actions/setup | |
| - uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0 | |
| id: create_token | |
| with: | |
| app-id: ${{ vars.GH_APP_ID }} | |
| private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
| - name: Build required packages | |
| run: pnpm run build --filter=@inversifyjs/foundation-changelog-generator | |
| - name: Version packages | |
| run: pnpm changeset version | |
| - name: Commit release | |
| id: commit | |
| run: | | |
| if git diff --quiet; then | |
| echo "No changes" | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git checkout -B changeset-release/main | |
| git add . | |
| git commit -m "chore: bump package versions" | |
| - name: Push branch | |
| if: steps.commit.outputs.has_changes == 'true' | |
| run: git push origin changeset-release/main --force | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Open PR | |
| if: steps.commit.outputs.has_changes == 'true' | |
| run: | | |
| if [ "$(gh pr list --head changeset-release/main --state open --json number --jq 'length')" -eq 0 ]; then | |
| gh pr create \ | |
| --base main \ | |
| --head changeset-release/main \ | |
| --title "[Changesets] Bump package versions" \ | |
| --body "Automated release PR" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ steps.create_token.outputs.token }} |