cad8791859
Follow-up to the v4.4.5 release incident where the release PR (#3406) was merged with a stale lockfile and stale Chart.yaml, breaking npm + helm releases. The two automation jobs (`update-lockfile`, `bump-chart-version`) got cancelled mid-flight by `cancel-in-progress` when the merge fired the workflow again on `main`. This restructures `changeset:version` so all the post-version-bump fixups happen in the same script and end up in a single atomic commit on `changeset-release/main`, via `changesets/action`'s normal commit step. Pattern borrowed from Cloudflare workers-sdk, Astro, shadcn/ui. ## Before ``` push: main └── release-pr (changeset version → bumps package.jsons, opens PR) └── update-lockfile (separate job, separate commit) └── bump-chart-version (separate job, separate commit) ``` Three jobs, three commits to the release branch. ## After ``` push: main └── release-pr └── changesets/action runs: changeset version pnpm install --lockfile-only node scripts/bump-helm-chart.mjs node scripts/cleanup-server-changes.mjs ...all staged and committed as ONE commit by the action ``` One job, one commit.
75 lines
2.4 KiB
YAML
75 lines
2.4 KiB
YAML
name: 🦋 Changesets PR
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "packages/**"
|
|
- ".changeset/**"
|
|
- ".server-changes/**"
|
|
- "package.json"
|
|
- "pnpm-lock.yaml"
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
release-pr:
|
|
name: Create Release PR
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
if: github.repository == 'triggerdotdev/trigger.dev'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
|
|
|
|
- name: Setup node
|
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
with:
|
|
node-version: 20.20.0
|
|
cache: "pnpm"
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Create release PR
|
|
id: changesets
|
|
uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1.7.0
|
|
with:
|
|
version: pnpm run changeset:version
|
|
commit: "chore: release"
|
|
title: "chore: release"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Update PR title and enhance body
|
|
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"
|
|
|
|
# Enhance the PR body with a clean, deduplicated summary
|
|
RAW_BODY=$(gh pr view "$PR_NUMBER" --json body --jq '.body')
|
|
ENHANCED_BODY=$(CHANGESET_PR_BODY="$RAW_BODY" node scripts/enhance-release-pr.mjs "$VERSION")
|
|
if [ -n "$ENHANCED_BODY" ]; then
|
|
gh api repos/triggerdotdev/trigger.dev/pulls/"$PR_NUMBER" \
|
|
-X PATCH \
|
|
-f body="$ENHANCED_BODY"
|
|
fi
|
|
fi
|