|
| 1 | +name: nightmonkey-compilers |
| 2 | + |
| 3 | +# Builds the NightMonkey compiler for each supported host from the NightMonkey |
| 4 | +# revision and engine version the StarlingMonkey submodule pins, and uploads |
| 5 | +# each as an artifact named after its file in lib/nightmonkey/ (see |
| 6 | +# NIGHTMONKEY_HOST_ASSETS in src/componentize.js). The compiler is a native |
| 7 | +# binary, so unlike the engine it cannot be built once on Linux. |
| 8 | +on: |
| 9 | + workflow_call: |
| 10 | + |
| 11 | +defaults: |
| 12 | + run: |
| 13 | + shell: bash |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: NightMonkey compiler (${{ matrix.asset }}) |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - os: ubuntu-latest |
| 23 | + asset: nightmonkey-x86_64-linux |
| 24 | + binary: nightmonkey |
| 25 | + - os: ubuntu-24.04-arm |
| 26 | + asset: nightmonkey-aarch64-linux |
| 27 | + binary: nightmonkey |
| 28 | + - os: macos-15 |
| 29 | + asset: nightmonkey-aarch64-macos |
| 30 | + binary: nightmonkey |
| 31 | + - os: windows-2022 |
| 32 | + asset: nightmonkey-x86_64-windows.exe |
| 33 | + binary: nightmonkey.exe |
| 34 | + runs-on: ${{ matrix.os }} |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + submodules: true |
| 39 | + |
| 40 | + - name: Read NightMonkey pins |
| 41 | + id: pins |
| 42 | + run: | |
| 43 | + file=StarlingMonkey/cmake/nightmonkey.cmake |
| 44 | + revision="$(awk '/^set\(NIGHTMONKEY_TAG / {gsub(/set\(NIGHTMONKEY_TAG |\)/, ""); print}' "$file")" |
| 45 | + engine="$(awk '/^set\(NIGHTMONKEY_ENGINE_VERSION / {gsub(/"/, "", $2); print $2}' "$file")" |
| 46 | + echo "revision=$revision" >> "$GITHUB_OUTPUT" |
| 47 | + echo "engine=$engine" >> "$GITHUB_OUTPUT" |
| 48 | +
|
| 49 | + - uses: actions/cache@v4 |
| 50 | + id: cache |
| 51 | + with: |
| 52 | + key: ${{ matrix.asset }}-${{ steps.pins.outputs.revision }}-${{ steps.pins.outputs.engine }} |
| 53 | + path: ${{ matrix.asset }} |
| 54 | + |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + if: steps.cache.outputs.cache-hit != 'true' |
| 57 | + with: |
| 58 | + repository: bytecodealliance/nightmonkey |
| 59 | + ref: ${{ steps.pins.outputs.revision }} |
| 60 | + path: nightmonkey |
| 61 | + |
| 62 | + - name: Build compiler |
| 63 | + if: steps.cache.outputs.cache-hit != 'true' |
| 64 | + # Run from the StarlingMonkey tree so that rustup uses its toolchain, as |
| 65 | + # the engine build does. |
| 66 | + working-directory: StarlingMonkey |
| 67 | + run: | |
| 68 | + cargo build --release -p nightmonkey --manifest-path ../nightmonkey/Cargo.toml \ |
| 69 | + --target-dir ../nightmonkey-target \ |
| 70 | + --no-default-features --features "${{ steps.pins.outputs.engine }}" |
| 71 | + cp "../nightmonkey-target/release/${{ matrix.binary }}" "../${{ matrix.asset }}" |
| 72 | +
|
| 73 | + - name: Check compiler |
| 74 | + run: ./${{ matrix.asset }} --help |
| 75 | + |
| 76 | + - uses: actions/upload-artifact@v4 |
| 77 | + with: |
| 78 | + name: ${{ matrix.asset }} |
| 79 | + path: ${{ matrix.asset }} |
| 80 | + if-no-files-found: error |
0 commit comments