Skip to content

perf(transform): hoist shared classes, and update the design notes (#… #1880

perf(transform): hoist shared classes, and update the design notes (#…

perf(transform): hoist shared classes, and update the design notes (#… #1880

Workflow file for this run

name: Publish
on:
push:
branches:
- v2
paths:
- '.changeset/**'
- 'packages/**'
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
workflow_dispatch:
inputs:
dry_run:
description: 'Build the matrix and run publish checks without publishing'
type: boolean
default: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
build-native:
name: Build (${{ matrix.target }})
if: ${{ github.repository == 'chakra-ui/panda' || github.event_name == 'workflow_dispatch' }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- { target: aarch64-apple-darwin, runner: macos-latest }
- { target: x86_64-apple-darwin, runner: macos-latest }
- { target: x86_64-unknown-linux-gnu, runner: ubuntu-latest, args: --use-napi-cross }
- { target: aarch64-unknown-linux-gnu, runner: ubuntu-latest, args: --use-napi-cross }
- { target: x86_64-unknown-linux-musl, runner: ubuntu-latest, zig: true, args: -x }
- { target: aarch64-unknown-linux-musl, runner: ubuntu-latest, zig: true, args: -x }
- { target: x86_64-pc-windows-msvc, runner: windows-latest }
- { target: aarch64-pc-windows-msvc, runner: windows-latest }
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install dependencies
uses: ./.github/composite-actions/install
with:
ignore-scripts: 'true'
- name: Add Rust target
run: rustup target add ${{ matrix.target }}
- name: Install Zig for musl
if: matrix.zig
shell: bash
run: |
set -euo pipefail
zig_version=0.14.1
zig_dir="$RUNNER_TOOL_CACHE/zig/${zig_version}/x64"
if [ ! -x "$zig_dir/zig" ]; then
mkdir -p "$zig_dir"
curl -fsSL "https://ziglang.org/download/${zig_version}/zig-x86_64-linux-${zig_version}.tar.xz" -o "$RUNNER_TEMP/zig.tar.xz"
tar -xJf "$RUNNER_TEMP/zig.tar.xz" -C "$RUNNER_TEMP"
cp -R "$RUNNER_TEMP/zig-x86_64-linux-${zig_version}/." "$zig_dir/"
fi
echo "$zig_dir" >> "$GITHUB_PATH"
- name: Install cargo-zigbuild for musl
if: matrix.zig
uses: taiki-e/install-action@v2
with:
tool: cargo-zigbuild
# Use napi directly so per-target flags are not lost behind pnpm's separator.
- name: Build native binding
working-directory: packages/compiler
run: >-
pnpm exec napi build --platform --release --manifest-path crate/Cargo.toml --output-dir . --js binding.cjs
--dts native.d.ts --target ${{ matrix.target }} ${{ matrix.args }}
- name: Upload native binary
uses: actions/upload-artifact@v7
with:
name: bindings-${{ matrix.target }}
path: packages/compiler/*.node
if-no-files-found: error
# binding.cjs is platform-independent, but version-coupled. Upload it once.
- name: Upload NAPI loader
if: matrix.target == 'x86_64-unknown-linux-gnu'
uses: actions/upload-artifact@v7
with:
name: compiler-loader
path: packages/compiler/binding.cjs
if-no-files-found: error
build-wasm:
name: Build wasm artifacts
if: ${{ github.repository == 'chakra-ui/panda' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install dependencies
uses: ./.github/composite-actions/install
with:
ignore-scripts: 'true'
- name: Add wasm Rust target
run: rustup target add wasm32-unknown-unknown
- name: Install wasm-pack
uses: taiki-e/install-action@v2
with:
tool: wasm-pack
- name: Build wasm artifacts
run: pnpm --filter @pandacss/compiler-wasm build:wasm
- name: Upload wasm artifacts
uses: actions/upload-artifact@v7
with:
name: compiler-wasm
path: |
packages/compiler-wasm/pkg-node
packages/compiler-wasm/pkg-web
if-no-files-found: error
build-wasi:
name: Build wasi artifact
if: ${{ github.repository == 'chakra-ui/panda' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install dependencies
uses: ./.github/composite-actions/install
with:
ignore-scripts: 'true'
- name: Add wasi Rust target
run: rustup target add wasm32-wasip1-threads
- name: Build wasi binding
working-directory: packages/compiler
run: >-
pnpm exec napi build --platform --release --manifest-path crate/Cargo.toml --output-dir . --js binding.cjs
--dts native.d.ts --target wasm32-wasip1-threads
- name: Upload wasi artifact
uses: actions/upload-artifact@v7
with:
name: bindings-wasm32-wasi
path: |
packages/compiler/compiler.wasm32-wasi.wasm
packages/compiler/compiler.wasi.cjs
packages/compiler/compiler.wasi-browser.js
packages/compiler/wasi-worker.mjs
packages/compiler/wasi-worker-browser.mjs
if-no-files-found: error
release:
name: Release
needs:
- build-native
- build-wasm
- build-wasi
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install dependencies
uses: ./.github/composite-actions/install
with:
ignore-scripts: 'true'
- name: Download native binary artifacts
uses: actions/download-artifact@v8
with:
pattern: bindings-*
path: packages/compiler/artifacts
merge-multiple: true
- name: Download NAPI loader
uses: actions/download-artifact@v8
with:
name: compiler-loader
path: packages/compiler
- name: Download wasm artifacts
uses: actions/download-artifact@v8
with:
name: compiler-wasm
path: packages/compiler-wasm
- name: Stage wasi loader files at package root
working-directory: packages/compiler
run: >-
mv artifacts/compiler.wasi.cjs artifacts/compiler.wasi-browser.js artifacts/wasi-worker.mjs
artifacts/wasi-worker-browser.mjs .
- name: Stage platform npm packages
working-directory: packages/compiler
run: pnpm exec napi artifacts --output-dir artifacts --npm-dir npm
- name: Verify wasi binding loads
run: |
cleanup() {
rm -f packages/compiler/node_modules/@pandacss/compiler-wasm32-wasi
if [ -f packages/compiler/compiler.wasi.cjs.smoke ]; then
mv packages/compiler/compiler.wasi.cjs.smoke packages/compiler/compiler.wasi.cjs
fi
}
trap cleanup EXIT
mv packages/compiler/compiler.wasi.cjs packages/compiler/compiler.wasi.cjs.smoke
mkdir -p packages/compiler/node_modules/@pandacss
ln -s ../../npm/wasm32-wasi packages/compiler/node_modules/@pandacss/compiler-wasm32-wasi
NAPI_RS_FORCE_WASI=error node -e "const binding = require('./packages/compiler/binding.cjs'); if (typeof binding.compile !== 'function' || typeof binding.Compiler?.fromConfig !== 'function') process.exit(1)"
- name: Build package JS
run: |
pnpm --filter @pandacss/types build
pnpm --filter @pandacss/compiler-shared build
pnpm --filter @pandacss/config build
pnpm --filter @pandacss/compiler build:js
pnpm --filter @pandacss/compiler-wasm build:js
pnpm -r "--filter=./packages/**" "--filter=!@pandacss/types" "--filter=!@pandacss/compiler-shared" "--filter=!@pandacss/config" "--filter=!@pandacss/compiler" "--filter=!@pandacss/compiler-wasm" build
- name: Verify dry-run artifacts
if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}
run: |
find packages/compiler/npm -name '*.node'
test "$(find packages/compiler/npm -name '*.node' | wc -l)" -eq 8
test -f packages/compiler/npm/wasm32-wasi/compiler.wasm32-wasi.wasm
test -f packages/compiler/npm/wasm32-wasi/compiler.wasi.cjs
test -f packages/compiler-wasm/pkg-node/compiler_wasm_bg.wasm
test -f packages/compiler-wasm/pkg-web/compiler_wasm_bg.wasm
- name: Publish
id: changesets
if: >-
${{ github.repository == 'chakra-ui/panda' && !(github.event_name == 'workflow_dispatch' && inputs.dry_run) }}
uses: changesets/action@v1
with:
publish: pnpm release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: true
- name: Send Slack notification
if: steps.changesets.outputs.published == 'true'
uses: slackapi/slack-github-action@v3
with:
webhook-type: webhook-trigger
payload: |
{
"package_name": "@pandacss/cli",
"changelog_url": "https://github.com/chakra-ui/panda/blob/v2/CHANGELOG.md"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}