Skip to content
Merged
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
95 changes: 95 additions & 0 deletions .github/workflows/pkg.pr.new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Publish to pkg.pr.new

# Publishes a continuous preview release to https://pkg.pr.new whenever a
# maintainer adds the `pkg.pr.new` label to a pull request (or via manual
# dispatch). Requires the pkg.pr.new GitHub App to be installed on the repo:
# https://github.com/apps/pkg-pr-new

# One-shot per label by design (matches rolldown's PR preview): a preview is
# built only when the `pkg.pr.new` label itself is added (the job guards check
# the triggering label, github.event.label.name, NOT the full label set, so
# adding any other label to an already-labeled PR does not rebuild).
# `synchronize` is intentionally NOT subscribed, so later commits do not
# rebuild — re-apply the label or use workflow_dispatch to refresh. This avoids
# an 8-platform native build on every push.
on:
workflow_dispatch:
pull_request:
types: [labeled]

permissions: {}

# Cancel an in-flight preview when the label is re-applied on the same PR.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
DEBUG: 'napi:*'

jobs:
build:
name: Build
if: >
github.repository == 'voidzero-dev/oxc-angular-compiler' &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.label.name == 'pkg.pr.new'))
permissions:
contents: read
uses: ./.github/workflows/reusable-build.yml

publish:
name: Publish preview
if: >
github.repository == 'voidzero-dev/oxc-angular-compiler' &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.label.name == 'pkg.pr.new'))
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2

- name: Install pnpm
uses: pnpm/action-setup@08c4be7e2e672a47d11bd04269e27e5f3e8529cb # v6.0.0

- name: Install Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 24
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: napi/angular-compiler/artifacts

- name: Create npm dirs
run: pnpm --filter ./napi/angular-compiler exec napi create-npm-dirs

- name: Move artifacts
run: pnpm --filter ./napi/angular-compiler artifacts

- name: Build TypeScript
run: pnpm --filter ./napi/angular-compiler build:ts

# Inject the platform binding packages into the root package's
# optionalDependencies (without publishing them to npm) so pkg.pr.new
# rewrites those deps to the preview URLs it generates. --no-gh-release
# keeps `napi pre-publish` from attempting a real GitHub release tag.
- name: Prepare optionalDependencies
run: pnpm --filter ./napi/angular-compiler exec napi pre-publish -t npm --skip-optional-publish --no-gh-release

# Invoke the lockfile-pinned pkg-pr-new binary directly, NOT via
# `pnpm exec`: the previous step injects binding optionalDependencies into
# napi/angular-compiler/package.json, desyncing it from the lockfile, and
# the workspace's `verifyDepsBeforeRun: install` would make `pnpm exec`
# fail the frozen-lockfile check before pkg-pr-new runs. The direct call
# skips that gate while still using the pinned install (not `pnpm dlx`).
# Requires the pkg.pr.new GitHub App on the repo.
- name: Publish preview to pkg.pr.new
run: ./node_modules/.bin/pkg-pr-new publish './napi/angular-compiler/npm/*' './napi/angular-compiler'
99 changes: 2 additions & 97 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,105 +16,10 @@ concurrency:

jobs:
build:
name: Build - ${{ matrix.target }}
name: Build
permissions:
contents: read
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-24.04-arm
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: aarch64-pc-windows-msvc
os: windows-latest

steps:
- name: Support longpaths
if: ${{ matrix.os == 'windows-latest' }}
run: git config --system core.longpaths true
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2

- name: Update submodules
run: git submodule update --init --recursive

- name: Print rustup toolchain version
shell: bash
id: rustup-version
run: |
export RUST_TOOLCHAIN_VERSION="$(grep 'channel' rust-toolchain.toml | head -1 | awk -F '"' '{print $2}')"
echo "Rust toolchain version: $RUST_TOOLCHAIN_VERSION"
echo "RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION" >> "$GITHUB_OUTPUT"

- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
toolchain: '${{ steps.rustup-version.outputs.RUST_TOOLCHAIN_VERSION }}'
targets: ${{ matrix.target }}

- name: Cache Rust
uses: Swatinem/rust-cache@fb003b4f771bbf9c2de31d5f65c40689cc097fb5 # v2.1.0

- uses: mlugg/setup-zig@fa65c4058643678a4e4a9a60513944a7d8d35440 # v2.1.0
if: ${{ contains(matrix.target, 'musl') }}
with:
version: 0.15.2

- name: Install cargo-zigbuild
uses: taiki-e/install-action@cca35edeb1d01366c2843b68fc3ca441446d73d3 # v2.77.1
if: ${{ contains(matrix.target, 'musl') }}
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tool: cargo-zigbuild

- name: Install pnpm
uses: pnpm/action-setup@08c4be7e2e672a47d11bd04269e27e5f3e8529cb # v6.0.0

- name: Install Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 24
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Build ${{ matrix.target }}
working-directory: napi/angular-compiler
if: ${{ !contains(matrix.target , 'gnu') && !contains(matrix.target, 'musl') }}
run: pnpm build-dev --release --target ${{ matrix.target }}

- name: Build ${{ matrix.target }}
working-directory: napi/angular-compiler
if: ${{ contains(matrix.target , 'gnu') }}
run: pnpm build-dev --release --target ${{ matrix.target }} --use-napi-cross
env:
TARGET_CC: clang

- name: Build ${{ matrix.target }}
working-directory: napi/angular-compiler
if: ${{ contains(matrix.target, 'musl') }}
run: pnpm build-dev --release --target ${{ matrix.target }} -x

- name: Upload artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: bindings-${{ matrix.target }}
path: napi/angular-compiler/*.node
if-no-files-found: error
uses: ./.github/workflows/reusable-build.yml

publish:
name: Publish
Expand Down
116 changes: 116 additions & 0 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Reusable Build

# Builds the native NAPI bindings for every target and uploads them as
# `bindings-<target>` artifacts. Called by both `release.yml` (tag releases)
# and `pkg.pr.new.yml` (PR preview packages) so the build matrix lives in one
# place.

on:
workflow_call:

permissions: {}

env:
DEBUG: 'napi:*'

jobs:
build:
name: Build - ${{ matrix.target }}
permissions:
contents: read
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-24.04-arm
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: aarch64-pc-windows-msvc
os: windows-latest

steps:
- name: Support longpaths
if: ${{ matrix.os == 'windows-latest' }}
run: git config --system core.longpaths true
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2

- name: Update submodules
run: git submodule update --init --recursive

- name: Print rustup toolchain version
shell: bash
id: rustup-version
run: |
export RUST_TOOLCHAIN_VERSION="$(grep 'channel' rust-toolchain.toml | head -1 | awk -F '"' '{print $2}')"
echo "Rust toolchain version: $RUST_TOOLCHAIN_VERSION"
echo "RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION" >> "$GITHUB_OUTPUT"

- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
toolchain: '${{ steps.rustup-version.outputs.RUST_TOOLCHAIN_VERSION }}'
targets: ${{ matrix.target }}

- name: Cache Rust
uses: Swatinem/rust-cache@fb003b4f771bbf9c2de31d5f65c40689cc097fb5 # v2.1.0

- uses: mlugg/setup-zig@fa65c4058643678a4e4a9a60513944a7d8d35440 # v2.1.0
if: ${{ contains(matrix.target, 'musl') }}
with:
version: 0.15.2

- name: Install cargo-zigbuild
uses: taiki-e/install-action@cca35edeb1d01366c2843b68fc3ca441446d73d3 # v2.77.1
if: ${{ contains(matrix.target, 'musl') }}
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tool: cargo-zigbuild

- name: Install pnpm
uses: pnpm/action-setup@08c4be7e2e672a47d11bd04269e27e5f3e8529cb # v6.0.0

- name: Install Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: 24
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Build ${{ matrix.target }}
working-directory: napi/angular-compiler
if: ${{ !contains(matrix.target , 'gnu') && !contains(matrix.target, 'musl') }}
run: pnpm build-dev --release --target ${{ matrix.target }}

- name: Build ${{ matrix.target }}
working-directory: napi/angular-compiler
if: ${{ contains(matrix.target , 'gnu') }}
run: pnpm build-dev --release --target ${{ matrix.target }} --use-napi-cross
env:
TARGET_CC: clang

- name: Build ${{ matrix.target }}
working-directory: napi/angular-compiler
if: ${{ contains(matrix.target, 'musl') }}
run: pnpm build-dev --release --target ${{ matrix.target }} -x

- name: Upload artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: bindings-${{ matrix.target }}
path: napi/angular-compiler/*.node
if-no-files-found: error
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"@napi-rs/cli": "catalog:",
"oxfmt": "catalog:",
"oxlint": "^1.56.0",
"oxlint-tsgolint": "^0.23.0"
"oxlint-tsgolint": "^0.23.0",
"pkg-pr-new": "0.0.75"
},
"packageManager": "pnpm@11.4.0"
}
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

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

Loading