Skip to content

Commit a4e34d3

Browse files
Release: open a Version packages PR instead of pushing to main (#161)
main only accepts changes through a pull request, so the Release workflow's direct push of the version bump failed on every merge and nothing published until someone hand-cut a Version packages PR. The workflow now versions pending changesets on the version-packages branch, opens that PR itself and starts its required checks with workflow_dispatch (which GITHUB_TOKEN may trigger). Build and publish are skipped on that run; merging the PR runs the workflow again with nothing pending, and that run publishes. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 806258c commit a4e34d3

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
push:
66
branches: [main]
7+
workflow_dispatch:
78

89
permissions:
910
contents: read

‎.github/workflows/release.yml‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ concurrency:
1414
permissions:
1515
contents: write
1616
id-token: write
17+
pull-requests: write
18+
actions: write
1719

1820
env:
1921
YARN_ENABLE_HARDENED_MODE: "1"
@@ -53,27 +55,48 @@ jobs:
5355

5456
- run: yarn install --immutable
5557

58+
# main only takes changes through a pull request, so the version bump cannot be
59+
# pushed from here. Pending changesets are versioned on the version-packages
60+
# branch and offered as a "Version packages" PR; merging that PR runs this
61+
# workflow again with nothing pending, and that run publishes.
5662
- name: Version pending changesets
63+
id: version
5764
env:
65+
GH_TOKEN: ${{ github.token }}
5866
YARN_ENABLE_IMMUTABLE_INSTALLS: "false"
5967
run: |
6068
if ! ls .changeset/*.md 2>/dev/null | grep -qv README.md; then
6169
echo "No pending changesets."
6270
exit 0
6371
fi
72+
echo "pending=true" >> "$GITHUB_OUTPUT"
6473
yarn version-packages
6574
git config user.name "github-actions[bot]"
6675
git config user.email "41898283+github-actions[bot]@users.noreply.github.com"
76+
git checkout -B version-packages
6777
git add -A
6878
git commit -m "Version packages"
69-
git push
79+
git push --force origin version-packages
80+
git checkout --quiet "$GITHUB_SHA"
81+
if [ -z "$(gh pr list --head version-packages --state open --json number --jq '.[].number')" ]; then
82+
gh pr create --base main --head version-packages --title "Version packages" \
83+
--body "Pending changesets versioned by the Release workflow. Merging this PR publishes the new versions." \
84+
|| echo "::warning::Could not open the PR. Open it by hand: ${{ github.server_url }}/${{ github.repository }}/compare/main...version-packages"
85+
fi
86+
# A PR opened with GITHUB_TOKEN gets no pull_request runs, but workflow_dispatch
87+
# is exempt, so start the required checks on the branch directly.
88+
gh workflow run polinrider-scan.yml --ref version-packages || true
89+
gh workflow run ci.yml --ref version-packages || true
90+
echo "::notice::Changesets were versioned on the version-packages branch. Merge the Version packages PR to publish."
7091
71-
- run: yarn build
92+
- if: steps.version.outputs.pending != 'true'
93+
run: yarn build
7294

7395
# Idempotent: publishes only versions not already on the registry, so a rerun after a partial failure is safe.
7496
# One package failing (for example ENEEDAUTH when its npmjs.com trusted publisher is not set up) does not
7597
# stop the others; the step fails at the end and names what did not publish.
7698
- name: Publish
99+
if: steps.version.outputs.pending != 'true'
77100
run: |
78101
failed=""
79102
for dir in helpers apihelper apphelper content-providers integration-sdk texting; do

0 commit comments

Comments
 (0)