Repository navigation
Release 0.2.0: relative JS imports, markup else if, rx-tsc on npm #101
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 } | |
| - { os: ubuntu-latest, target: wasm32-wasip1-threads, test: true } # @reactivescript/compiler-wasm32-wasi: WebContainers, musl, Windows on ARM | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| working-directory: compiler | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@v5 | |
| # Pinned: Rust 1.100's wasi-libc defines __wasilibc_futex_wait_atomic_wait with a signature emnapi 1.x's | |
| # libemnapi-napi-rs-mt.a does not match, and links crt1-reactor.o itself, so the WASI package breaks. Lift once | |
| # emnapi follows. | |
| - uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: 1.99.1 | |
| 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 | |
| # RUSTC: napi-build finds crt1-reactor.o from it for WASI; the rustup proxy's name gives a module that | |
| # deadlocks before its threads start (as @solidjs/compiler's workflow notes) | |
| run: RUSTC="$(rustup which rustc)" npx napi build --platform --release --strip --features node --target ${{ matrix.target }} --manifest-path ./Cargo.toml -- --lib | |
| - name: Test | |
| if: matrix.test | |
| run: npm test | |
| env: | |
| NAPI_RS_FORCE_WASI: ${{ matrix.target == 'wasm32-wasip1-threads' && '1' || '' }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: binding-${{ matrix.target }} | |
| path: | | |
| compiler/*.node | |
| compiler/compiler.wasm32-wasi.wasm | |
| compiler/compiler.wasi.cjs | |
| compiler/compiler.wasi.d.cts | |
| compiler/compiler.wasi-browser.js | |
| compiler/wasi-worker.mjs | |
| compiler/wasi-worker-browser.mjs | |
| 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 | |
| # npm ci with the runner's npm 10: npm 11+ rejects a lock that lacks the | |
| # not-yet-published platform packages. Then upgrade npm only to publish. | |
| - run: npm ci | |
| - run: npm install -g npm@latest # trusted publishing needs npm 11.5.1 or later | |
| - name: Platform packages | |
| run: | | |
| node scripts/sync-optional-deps.mjs --publish | |
| 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 }} |