Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ All publishable packages in this repository use a pull-request-driven release fl

The `plugin-react` and `plugin-react-swc` releases move their manually maintained `Unreleased` notes under the new version. The `plugin-rsc` release generates its changelog from conventional commits.

To preview the available release types and versions locally, run the following command from the repository root and cancel before confirming so no files are changed:

```sh
node scripts/prepare-release.ts plugin-react
```

Replace `plugin-react` with `plugin-react-swc` or `plugin-rsc` as needed.

## Review and Publish

1. Review the generated version and changelog, and wait for the release PR checks to pass.
Expand Down
42 changes: 11 additions & 31 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- plugin-react-swc
- plugin-rsc
release:
description: Bumpp release type
description: Release type
required: true
default: next
type: choice
Expand Down Expand Up @@ -71,8 +71,7 @@ jobs:
RELEASE: ${{ inputs.version || inputs.release }}
RELEASE_PACKAGE: ${{ inputs.package }}
run: |
node scripts/prepare-release.ts "$RELEASE_PACKAGE" "$RELEASE"
echo "version=$(jq -r .version packages/$RELEASE_PACKAGE/package.json)" >> "$GITHUB_OUTPUT"
node scripts/prepare-release.ts "$RELEASE_PACKAGE" "$RELEASE" >> "$GITHUB_OUTPUT"

- id: generate-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
Expand All @@ -85,31 +84,12 @@ jobs:
permission-pull-requests: write

- name: Open release PR
env:
APP_SLUG: ${{ steps.generate-token.outputs.app-slug }}
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
PACKAGE: ${{ inputs.package }}
PR_BODY_FILE: ${{ runner.temp }}/release-pr-body.md
VERSION: ${{ steps.prepare.outputs.version }}
run: |
BRANCH="release-$PACKAGE-$VERSION-$GITHUB_RUN_ID"
BOT_ID="$(gh api "/users/$APP_SLUG%5Bbot%5D" --jq .id)"
{
echo "$PACKAGE release PR generated by the Prepare Release workflow: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
echo
echo "## Changelog"
echo
node scripts/extract-changelog.ts "packages/$PACKAGE/CHANGELOG.md" "$VERSION"
} > "$PR_BODY_FILE"
git config user.name "$APP_SLUG[bot]"
git config user.email "$BOT_ID+$APP_SLUG[bot]@users.noreply.github.com"
git switch -c "$BRANCH"
git add "packages/$PACKAGE/package.json" "packages/$PACKAGE/CHANGELOG.md"
git commit -m "release: $PACKAGE@$VERSION"
git push -u "https://x-access-token:$GH_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD
gh pr create \
--assignee "$GITHUB_ACTOR" \
--base main \
--head "$BRANCH" \
--title "release: $PACKAGE@$VERSION" \
--body-file "$PR_BODY_FILE"
uses: vitejs/release-scripts/action/release-pr@bec07424241c85b28458756d0ef9edbb130dc63e # v1.9.1
with:
app-slug: ${{ steps.generate-token.outputs.app-slug }}
token: ${{ steps.generate-token.outputs.token }}
package-name: ${{ inputs.package }}
package-path: packages/${{ inputs.package }}
pr-body: ${{ steps.prepare.outputs.pr_body }}
tag: ${{ steps.prepare.outputs.tag }}
version: ${{ steps.prepare.outputs.version }}
55 changes: 22 additions & 33 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,36 @@ jobs:
outputs:
package: ${{ steps.detect.outputs.package }}
release: ${{ steps.detect.outputs.release }}
tag: ${{ steps.detect.outputs.tag }}
version: ${{ steps.detect.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

- name: Install pnpm
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9

- name: Set node version
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24
package-manager-cache: false

- name: Install deps
run: pnpm install --filter . --frozen-lockfile --ignore-scripts
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'

- name: Detect release
id: detect
run: |
SUBJECT="$(git log -1 --format=%s)"
for PACKAGE in plugin-react plugin-react-swc plugin-rsc; do
VERSION="$(jq -r .version "packages/$PACKAGE/package.json")"
EXPECTED="release: $PACKAGE@$VERSION"
if [[ "$SUBJECT" == "$EXPECTED"* ]]; then
echo "package=$PACKAGE" >> "$GITHUB_OUTPUT"
echo "release=true" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Detected $PACKAGE release $VERSION"
exit 0
fi
done
echo "release=false" >> "$GITHUB_OUTPUT"
echo "No release commit found at HEAD"
run: node scripts/detect-release.ts "$(git log -1 --format=%s)" >> "$GITHUB_OUTPUT"

publish-release:
if: needs.detect-release.outputs.release == 'true'
needs: detect-release
name: Publish ${{ needs.detect-release.outputs.package }}
name: Publish ${{ needs.detect-release.outputs.tag }}
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -58,10 +59,8 @@ jobs:

- name: Check release tag
env:
PACKAGE: ${{ needs.detect-release.outputs.package }}
VERSION: ${{ needs.detect-release.outputs.version }}
TAG: ${{ needs.detect-release.outputs.tag }}
run: |
TAG="$PACKAGE@$VERSION"
if git rev-parse --verify --quiet "refs/tags/$TAG"; then
echo "Tag $TAG already exists"
exit 1
Expand Down Expand Up @@ -91,24 +90,13 @@ jobs:

- name: Publish package
env:
PACKAGE: ${{ needs.detect-release.outputs.package }}
VERSION: ${{ needs.detect-release.outputs.version }}
TAG: ${{ needs.detect-release.outputs.tag }}
# npm 11.5.2+ is required for trusted publishing.
# zizmor: ignore[adhoc-packages]
run: npm i -g npm@^11.5.2 && pnpm run ci-publish "$PACKAGE@$VERSION"

- id: generate-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.RELEASE_GITHUB_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_GITHUB_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: ${{ github.event.repository.name }}
permission-contents: write
run: npm i -g npm@^11.5.2 && pnpm run ci-publish "$TAG"

- name: Create GitHub release
run: |
TAG="$PACKAGE@$VERSION"
node scripts/extract-changelog.ts "packages/$PACKAGE/CHANGELOG.md" "$VERSION" > "$NOTES_FILE"

prerelease=()
Expand All @@ -122,7 +110,8 @@ jobs:
--notes-file "$NOTES_FILE" \
"${prerelease[@]}"
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
GH_TOKEN: ${{ github.token }}
NOTES_FILE: ${{ runner.temp }}/release-notes.md
PACKAGE: ${{ needs.detect-release.outputs.package }}
TAG: ${{ needs.detect-release.outputs.tag }}
VERSION: ${{ needs.detect-release.outputs.version }}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
"@eslint/js": "^9.39.5",
"@types/fs-extra": "^11.0.4",
"@types/node": "^24.13.3",
"@vitejs/release-scripts": "^1.8.0",
"bumpp": "^10.4.1",
"@vitejs/release-scripts": "^1.9.1",
"eslint": "^9.39.5",
"eslint-plugin-import-x": "^4.17.1",
"eslint-plugin-n": "^18.2.2",
Expand Down
Loading
Loading