chore(releases): add package version in changeset PRs (#2730) #2589
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: 🦋 Changesets Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "docs/**" | |
| - "**.md" | |
| - ".github/CODEOWNERS" | |
| - ".github/ISSUE_TEMPLATE/**" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| release: | |
| name: 🦋 Changesets Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| pull-requests: write | |
| id-token: write | |
| if: github.repository == 'triggerdotdev/trigger.dev' | |
| outputs: | |
| published: ${{ steps.changesets.outputs.published }} | |
| published_packages: ${{ steps.changesets.outputs.publishedPackages }} | |
| published_package_version: ${{ steps.get_version.outputs.package_version }} | |
| steps: | |
| - name: ⬇️ Checkout repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: ⎔ Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10.23.0 | |
| - name: ⎔ Setup node | |
| uses: buildjet/setup-node@v4 | |
| with: | |
| node-version: 20.19.0 | |
| cache: "pnpm" | |
| - name: 📥 Download deps | |
| run: pnpm install --frozen-lockfile | |
| - name: 📀 Generate Prisma Client | |
| run: pnpm run generate | |
| - name: 🏗️ Build | |
| run: pnpm run build --filter "@trigger.dev/*" --filter "trigger.dev" | |
| - name: 🔎 Type check | |
| run: pnpm run typecheck --filter "@trigger.dev/*" --filter "trigger.dev" | |
| # This action has two responsibilities. The first time the workflow runs | |
| # (initial push to the `main` branch) it will create a new branch and | |
| # then open a PR with the related changes for the new version. After the | |
| # PR is merged, the workflow will run again and this action will build + | |
| # publish to npm. | |
| - name: 🚀 PR / Publish | |
| if: ${{ !env.ACT }} | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: pnpm run changeset:version | |
| commit: "chore: release packages" | |
| title: "chore: release packages" | |
| publish: pnpm run changeset:release | |
| createGithubReleases: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: 📦 Get package version | |
| if: steps.changesets.outputs.published == 'true' | |
| id: get_version | |
| run: | | |
| package_version=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[0].version') | |
| echo "package_version=${package_version}" >> "$GITHUB_OUTPUT" | |
| - name: Update PR title with version | |
| if: steps.changesets.outputs.published != 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| PR_NUMBER=$(gh pr list --head changeset-release/main --json number --jq '.[0].number') | |
| if [ -n "$PR_NUMBER" ]; then | |
| git fetch origin changeset-release/main | |
| # we arbitrarily reference the version of the cli package here; it is the same for all package releases | |
| VERSION=$(git show origin/changeset-release/main:packages/cli-v3/package.json | jq -r '.version') | |
| gh pr edit "$PR_NUMBER" --title "chore: release v$VERSION" | |
| fi |