From c3ad0c8db41ddb31213eda248d435a44d0fe26cd Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Fri, 4 Dec 2026 12:28:36 -0800 Subject: [PATCH 1/3] ci: create release pull requests with an app token so checks run Co-Authored-By: Claude --- .github/workflows/release.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2bc99843..89d9fcac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,9 +16,19 @@ jobs: hasChangesets: ${{ steps.changesets.outputs.has-changesets }} releaseExists: ${{ steps.published.outputs.exists }} permissions: - contents: write - pull-requests: write + contents: read steps: + - name: Gather credentials + id: credentials + uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0 + with: + client-id: ${{ secrets.GH_APP_CLIENT_ID }} + private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: ${{ github.event.repository.name }} + permission-contents: write + permission-pull-requests: write + - name: Checkout repo uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -38,7 +48,7 @@ jobs: uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 with: commit-message: "chore: release" - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ steps.credentials.outputs.token }} pr-draft: create pr-title: "chore: release" version-script: npm run version From dfa5fea4e89730b36ea05803ff82fe8ba269d615 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Fri, 4 Dec 2026 13:33:43 -0800 Subject: [PATCH 2/3] ci: keep the release app token in a job that runs no npm Co-Authored-By: Claude --- .github/workflows/release.yml | 74 ++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 23db90f4..988cece2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,14 +15,14 @@ jobs: outputs: hasChangesets: ${{ steps.changesets.outputs.has-changesets }} releaseExists: ${{ steps.published.outputs.exists }} + title: ${{ steps.version.outputs.title }} permissions: - contents: write - pull-requests: write + contents: read steps: - name: Checkout repo uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - persist-credentials: true + persist-credentials: false - name: Setup Node uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 @@ -47,15 +47,29 @@ jobs: fi echo "title=${title}" >> "$GITHUB_OUTPUT" - - name: Update release PR + - name: Check for changesets id: changesets - uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 + run: | + if find .changeset -maxdepth 1 -name "*.md" ! -name README.md | grep -q .; then + echo "has-changesets=true" >> "$GITHUB_OUTPUT" + else + echo "has-changesets=false" >> "$GITHUB_OUTPUT" + fi + + - name: Version packages + if: steps.changesets.outputs.has-changesets == 'true' + run: | + npm run version + git add --all + git diff --cached --binary "$GITHUB_SHA" > "$RUNNER_TEMP/version.patch" + + - name: Upload the version changes + if: steps.changesets.outputs.has-changesets == 'true' + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - commit-message: ${{ steps.version.outputs.title }} - github-token: ${{ secrets.GITHUB_TOKEN }} - pr-draft: create - pr-title: ${{ steps.version.outputs.title }} - version-script: npm run version + if-no-files-found: error + name: version + path: ${{ runner.temp }}/version.patch - name: Check if publish is needed id: published @@ -70,6 +84,46 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + release-pr: + name: Release PR + if: github.ref == 'refs/heads/main' && needs.changelog.outputs.hasChangesets == 'true' + runs-on: ubuntu-latest + needs: changelog + environment: release-pr + permissions: + contents: read + steps: + - name: Gather credentials + id: credentials + uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0 + with: + client-id: ${{ secrets.GH_APP_CLIENT_ID }} + private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: ${{ github.event.repository.name }} + permission-contents: write + permission-pull-requests: write + + - name: Checkout repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Download the version changes + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: version + path: ${{ runner.temp }}/version + + - name: Update release PR + uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 + with: + commit-message: ${{ needs.changelog.outputs.title }} + github-token: ${{ steps.credentials.outputs.token }} + pr-draft: create + pr-title: ${{ needs.changelog.outputs.title }} + version-script: git apply ${{ runner.temp }}/version/version.patch + build: name: Build if: github.ref == 'refs/heads/main' && needs.changelog.outputs.hasChangesets == 'false' && needs.changelog.outputs.releaseExists == 'false' From bc1cb7cd6d0071de119cd001081fc4b4e9d160bf Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Fri, 4 Dec 2026 13:40:36 -0800 Subject: [PATCH 3/3] ci: refuse version changes that aren't regular files Co-Authored-By: Claude --- .github/workflows/release.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 988cece2..5e7cc279 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -115,6 +115,16 @@ jobs: name: version path: ${{ runner.temp }}/version + - name: Check the version changes + run: | + index="${RUNNER_TEMP}/version.index" + GIT_INDEX_FILE="$index" git read-tree HEAD + GIT_INDEX_FILE="$index" git apply --cached "${RUNNER_TEMP}/version/version.patch" + if GIT_INDEX_FILE="$index" git ls-files --stage | grep -v -E '^100(644|755) '; then + echo "::error::The version changes hold a file that isn't a regular file" + exit 1 + fi + - name: Update release PR uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 with: