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
4 changes: 4 additions & 0 deletions .github/npm-release-lines.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"1": "latest",
"2": "next"
}
57 changes: 57 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,63 @@ jobs:
run: |
pnpm test

node-v2-test:
name: Test node v2 preview
continue-on-error: true
if: >-
${{ !contains(github.event.head_commit.message, 'chore: ') }}
runs-on: macos-latest
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
submodules: true
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
toolchain: nightly-2026-04-10
targets: wasm32-wasip1
- uses: ./.github/actions/setup-node
with:
node-version: 20
install-dependencies: "false"
- name: Prepare
run: |
corepack enable
pnpm install --frozen-lockfile
- name: Test v2 native API
working-directory: packages/core-v2
run: pnpm test:native
- name: Test v1 plugin compatibility
working-directory: packages/core-v2
run: pnpm test:plugin-v1

wasm-v2-test:
name: Test wasm v2 preview
continue-on-error: true
if: >-
${{ !contains(github.event.head_commit.message, 'chore: ') }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
submodules: true
- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- uses: ./.github/actions/setup-node
with:
node-version: 20
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Test v2 Wasm API
working-directory: bindings/binding_core_wasm_v2
run: ./scripts/test.sh

react-compiler-test:
name: Test react-compiler bindings - ${{ matrix.os }}
if: >-
Expand Down
55 changes: 43 additions & 12 deletions .github/workflows/publish-npm-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ on:
skipPublishing:
type: boolean
required: true
npmTag:
description: "Override the configured npm dist-tag"
type: string
required: false
default: ""

jobs:
check-if-build-required:
Expand All @@ -68,7 +73,7 @@ jobs:
run: |
set -euo pipefail
case "$PACKAGE" in
core | html | minifier | react-compiler) ;;
core | core-v2 | html | minifier | react-compiler) ;;
*)
echo "Unsupported package: $PACKAGE" >&2
exit 1
Expand Down Expand Up @@ -366,7 +371,7 @@ jobs:
run: |
set -euo pipefail
case "$PACKAGE" in
core | html | minifier | react-compiler) ;;
core | core-v2 | html | minifier | react-compiler) ;;
*)
echo "Unsupported package: $PACKAGE" >&2
exit 1
Expand Down Expand Up @@ -403,7 +408,7 @@ jobs:
run: |
set -euo pipefail
case "$PACKAGE" in
core | html | minifier | react-compiler) ;;
core | core-v2 | html | minifier | react-compiler) ;;
*)
echo "Unsupported package: $PACKAGE" >&2
exit 1
Expand Down Expand Up @@ -515,7 +520,7 @@ jobs:
run: |
set -euo pipefail
case "$PACKAGE" in
core | html | minifier | react-compiler) ;;
core | core-v2 | html | minifier | react-compiler) ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add a root test script for core-v2

When publish-npm-v2-preview.yml invokes this reusable workflow with package: core-v2, the Linux binding test jobs pass this allow-list and later run pnpm "test:${PACKAGE}" from the repository root inside Docker. At this commit the root package.json only defines test:core, not test:core-v2, so both Linux binding test jobs fail with a missing script and publish-core never reaches the publish step. Add a root test:core-v2 script or special-case these jobs to run the package-local test command.

Useful? React with 👍 / 👎.

*)
echo "Unsupported package: $PACKAGE" >&2
exit 1
Expand Down Expand Up @@ -598,7 +603,7 @@ jobs:
run: |
set -euo pipefail
case "$PACKAGE" in
core | html | minifier | react-compiler) ;;
core | core-v2 | html | minifier | react-compiler) ;;
*)
echo "Unsupported package: $PACKAGE" >&2
exit 1
Expand Down Expand Up @@ -662,12 +667,13 @@ jobs:

- name: Tag npm release
env:
EXPLICIT_NPM_TAG: ${{ inputs.npmTag }}
RELEASE_VERSION: ${{ inputs.version }}
run: |
if [[ "$RELEASE_VERSION" != *"nightly"* ]]; then
echo "NPM_TAG=latest" >> "$GITHUB_ENV"
if [[ -n "$EXPLICIT_NPM_TAG" ]]; then
echo "NPM_TAG=$EXPLICIT_NPM_TAG" >> "$GITHUB_ENV"
else
echo "NPM_TAG=nightly" >> "$GITHUB_ENV"
echo "NPM_TAG=$(node scripts/resolve-npm-tag.mjs "$RELEASE_VERSION")" >> "$GITHUB_ENV"
fi

- name: Install dependencies
Expand All @@ -679,13 +685,21 @@ jobs:
pattern: "bindings-${{ inputs.buildType }}-${{ inputs.package }}-${{ inputs.version}}-*"
path: ./packages/${{ inputs.package }}/artifacts

- name: Prepare v2 package identity
if: ${{ inputs.package == 'core-v2' }}
env:
RELEASE_VERSION: ${{ inputs.version }}
run: |
node scripts/prepare-npm-v2-package.mjs packages/core-v2 "$RELEASE_VERSION" @swc/core

- name: List binaries
shell: bash
env:
PACKAGE: ${{ inputs.package }}
run: ls -R "packages/$PACKAGE/artifacts"

- name: Move binaries
if: ${{ inputs.package != 'core-v2' }}
shell: bash
env:
PACKAGE: ${{ inputs.package }}
Expand All @@ -696,26 +710,42 @@ jobs:
ls -R ./artifacts_cli
npm run artifacts

- name: Prepare v2 native packages
if: ${{ inputs.package == 'core-v2' }}
working-directory: packages/core-v2
run: npm run artifacts

- name: List npm
shell: bash
env:
PACKAGE: ${{ inputs.package }}
run: ls -R "packages/$PACKAGE/scripts/npm"

- name: Set fallback dependencies
if: ${{ inputs.package != 'core-v2' }}
shell: bash
run: |
node ./scripts/update_fallback_dependencies.js

- name: Publish
if: ${{ !inputs.skipPublishing }}
if: ${{ !inputs.skipPublishing && inputs.package != 'core-v2' }}
env:
GITHUB_TOKEN: ${{ github.token }}
PACKAGE: ${{ inputs.package }}
run: |
pnpm --filter "./packages/$PACKAGE" prepack
pnpm publish -r --filter "./packages/$PACKAGE" --filter "./packages/$PACKAGE/scripts/npm/*" --access public --tag "$NPM_TAG" --force --no-git-checks

- name: Publish v2 preview
if: ${{ !inputs.skipPublishing && inputs.package == 'core-v2' }}
working-directory: packages/core-v2
run: |
npm run prepack
for package_dir in scripts/npm/*; do
npm publish "$package_dir" --access public --tag "$NPM_TAG"
done
npm publish . --access public --tag "$NPM_TAG"

- name: Upload CLI binaries to gh release
if: ${{ !inputs.skipPublishing && inputs.package == 'core' }}
shell: bash
Expand Down Expand Up @@ -780,12 +810,13 @@ jobs:

- name: Tag npm release
env:
EXPLICIT_NPM_TAG: ${{ inputs.npmTag }}
RELEASE_VERSION: ${{ inputs.version }}
run: |
if [[ "$RELEASE_VERSION" != *"nightly"* ]]; then
echo "NPM_TAG=latest" >> "$GITHUB_ENV"
if [[ -n "$EXPLICIT_NPM_TAG" ]]; then
echo "NPM_TAG=$EXPLICIT_NPM_TAG" >> "$GITHUB_ENV"
else
echo "NPM_TAG=nightly" >> "$GITHUB_ENV"
echo "NPM_TAG=$(node scripts/resolve-npm-tag.mjs "$RELEASE_VERSION")" >> "$GITHUB_ENV"
fi

- name: Setup node
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/publish-npm-v2-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: "Publish SWC v2 preview"

permissions: {}

on:
workflow_dispatch:
inputs:
version:
description: "The 2.x prerelease version to publish"
required: true
type: string
skipPublishing:
description: "Build and validate without publishing"
required: false
default: false
type: boolean

jobs:
publish-types:
name: Publish @swc/types v2
runs-on: ubuntu-latest
environment: publish
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
ref: "v${{ inputs.version }}"
- uses: ./.github/actions/setup-node
with:
cache: "false"
- run: corepack enable && pnpm install --frozen-lockfile
- run: pnpm --filter @swc-internal/types-v2 build
- name: Stage packages
run: node scripts/stage-npm-v2.mjs "${{ inputs.version }}"
- name: Publish types
if: ${{ !inputs.skipPublishing }}
run: npm publish "target/npm-v2/${{ inputs.version }}/types" --access public --tag next

publish-core:
name: Publish @swc/core v2
needs: publish-types
permissions:
contents: write
id-token: write
uses: ./.github/workflows/publish-npm-package.yml
with:
buildType: "v2-preview"
package: "core-v2"
version: ${{ inputs.version }}
buildCli: false
skipBuild: false
publishWasm: false
skipPublishing: ${{ inputs.skipPublishing }}
npmTag: "next"

publish-wasm:
name: Publish @swc/wasm v2
needs: publish-types
runs-on: ubuntu-latest
environment: publish
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
persist-credentials: false
ref: "v${{ inputs.version }}"
- uses: ./.github/actions/setup-node
with:
cache: "false"
- run: corepack enable && pnpm install --frozen-lockfile
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build Wasm
working-directory: bindings/binding_core_wasm_v2
run: wasm-pack build --out-name wasm --release --scope=swc --target nodejs
- name: Prepare package identity
run: |
node scripts/prepare-npm-v2-package.mjs bindings/binding_core_wasm_v2/pkg "${{ inputs.version }}" @swc/wasm
- name: Publish Wasm
if: ${{ !inputs.skipPublishing }}
run: npm publish bindings/binding_core_wasm_v2/pkg --access public --tag next
47 changes: 47 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading