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
106 changes: 106 additions & 0 deletions .github/workflows/compiler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# The compiler's npm package, @reactivescript/compiler (compiler/): the crate's Node-API build for each platform,
# each tested on its own runner, then published as one package per platform (@reactivescript/compiler-<platform>)
# beside the main package, which loads the one that fits and carries the Vite front end (`/vite`).
#
# A release is a version bump merged to main (compiler/README.md, Releasing), once the repository variable RELEASES
# is `on`: a version npm does not have is published by trusted publishing (OIDC, no token) and tagged
# `compiler-v<version>`.
name: compiler

on:
push:
branches: [main]
paths: ["compiler/**", ".github/workflows/compiler.yml"]
pull_request:
paths: ["compiler/**", ".github/workflows/compiler.yml"]
workflow_dispatch:

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, test: true }
- { os: ubuntu-24.04-arm, target: aarch64-unknown-linux-gnu, test: true }
- { os: macos-latest, target: aarch64-apple-darwin, test: true }
- { os: macos-latest, target: x86_64-apple-darwin, test: false } # cross-built on Apple silicon
- { os: windows-latest, target: x86_64-pc-windows-msvc, test: true }
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: compiler
shell: bash
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
workspaces: compiler
key: ${{ matrix.target }}
- uses: actions/setup-node@v5
with:
node-version: 22
- run: npm ci
- name: Node-API build
run: npx napi build --platform --release --strip --features node --target ${{ matrix.target }} --manifest-path ./Cargo.toml -- --lib
- name: Test
if: matrix.test
run: npm test
- uses: actions/upload-artifact@v4
with:
name: binding-${{ matrix.target }}
path: compiler/*.node
if-no-files-found: error

# which version is new: on main only, after every platform built
version:
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && vars.RELEASES == 'on'
needs: build
runs-on: ubuntu-latest
outputs:
version: ${{ steps.v.outputs.version }}
steps:
- uses: actions/checkout@v5
- id: v
run: |
v=$(node -p 'require("./compiler/package.json").version')
if [ -z "$(npm view "@reactivescript/compiler@$v" version 2>/dev/null)" ]; then echo "version=$v" >> "$GITHUB_OUTPUT"; fi

publish:
needs: version
if: needs.version.outputs.version != ''
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write # trusted publishing: npm takes the job's OIDC token, and adds provenance
contents: write # the tag
defaults:
run:
working-directory: compiler
steps:
- uses: actions/checkout@v5
- uses: actions/download-artifact@v4
with:
pattern: binding-*
path: compiler/artifacts
merge-multiple: true
- uses: actions/setup-node@v5
with:
node-version: 22
registry-url: https://registry.npmjs.org
- run: npm install -g npm@latest # trusted publishing needs npm 11.5.1 or later
- run: npm ci
- name: Platform packages
run: |
node scripts/sync-optional-deps.mjs
npx napi artifacts --output-dir artifacts --npm-dir npm
for d in npm/*/; do npm publish "$d" --access public; done
- run: npm publish --access public
- name: Tag
working-directory: .
run: git tag "compiler-v$V" && git push origin "compiler-v$V"
env:
V: ${{ needs.version.outputs.version }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
node_modules/
compiler/target/
compiler/*.node
compiler/test/.out/
compiler/artifacts/
Loading
Loading