Skip to content
Draft
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
10 changes: 5 additions & 5 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 @@ -90,6 +89,7 @@ jobs:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
PACKAGE: ${{ inputs.package }}
PR_BODY_FILE: ${{ runner.temp }}/release-pr-body.md
TAG: ${{ steps.prepare.outputs.tag }}
VERSION: ${{ steps.prepare.outputs.version }}
run: |
BRANCH="release-$PACKAGE-$VERSION-$GITHUB_RUN_ID"
Expand All @@ -105,11 +105,11 @@ jobs:
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 commit -m "release: $TAG"
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" \
--title "release: $TAG" \
--body-file "$PR_BODY_FILE"
44 changes: 21 additions & 23 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,11 +90,10 @@ 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"
run: npm i -g npm@^11.5.2 && pnpm run ci-publish "$TAG"

- id: generate-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
Expand All @@ -108,7 +106,6 @@ jobs:

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

prerelease=()
Expand All @@ -125,4 +122,5 @@ jobs:
GH_TOKEN: ${{ steps.generate-token.outputs.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 }}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@types/fs-extra": "^11.0.4",
"@types/node": "^24.13.3",
"@vitejs/release-scripts": "^1.8.0",
"bumpp": "^10.4.1",
"eslint": "^9.39.5",
"eslint-plugin-import-x": "^4.17.1",
"eslint-plugin-n": "^18.2.2",
Expand Down
Loading
Loading