Update build-and-tests.yml #18
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
| name: CI | |
| env: | |
| DEBUG: napi:* | |
| APP_NAME: rollup | |
| MACOSX_DEPLOYMENT_TARGET: '10.13' | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - 'v*.*.**' | |
| pull_request: | |
| types: | |
| - synchronize | |
| - opened | |
| - reopened | |
| merge_group: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| - host: ubuntu-latest | |
| target: wasm32-unknown-unknown | |
| name: wasm | |
| is-wasm-build: true | |
| build: >- | |
| rustup default nightly-2025-07-25 && | |
| rustup target add wasm32-unknown-unknown && | |
| npm run build:wasm | |
| path: | | |
| wasm/ | |
| .empty | |
| - host: ubuntu-latest | |
| target: wasm32-unknown-unknown | |
| name: wasm-node | |
| is-wasm-build: true | |
| build: >- | |
| rustup default nightly-2025-07-25 && | |
| rustup target add wasm32-unknown-unknown && | |
| npm run build:wasm:node | |
| path: | | |
| wasm-node/ | |
| .empty | |
| - host: ubuntu-latest | |
| target: aarch64-linux-android | |
| build: npm run build:napi -- --release --target aarch64-linux-android --use-napi-cross | |
| - host: ubuntu-latest | |
| target: aarch64-unknown-linux-ohos | |
| build: npm run build:napi -- --release --target aarch64-unknown-linux-ohos --use-napi-cross | |
| name: Build ${{ matrix.settings.name || matrix.settings.target }} | |
| runs-on: ${{ matrix.settings.host }} | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout Commit | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Setup Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| if: ${{ !matrix.settings.docker }} | |
| with: | |
| node-version: 24 | |
| - name: Install Toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| if: ${{ !matrix.settings.docker }} | |
| with: | |
| toolchain: nightly-2025-07-25 | |
| targets: ${{ matrix.settings.target }} | |
| - name: Setup OpenHarmony SDK | |
| if: ${{ contains(matrix.settings.target, 'ohos') }} | |
| uses: openharmony-rs/setup-ohos-sdk@10564ad8040178be4aa02e0d3a2c25c32779fa3f # v0.2 | |
| - name: Restore Cargo cache | |
| uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| .cargo-cache | |
| rust/target/ | |
| key: ${{ matrix.settings.name || matrix.settings.target }}-cargo-${{ matrix.settings.host }}-${{ hashFiles('rust/Cargo.lock') }} | |
| restore-keys: ${{ matrix.settings.name || matrix.settings.target }}-cargo-${{ matrix.settings.host }} | |
| - uses: goto-bus-stop/setup-zig@abea47f85e598557f500fa1fd2ab7464fcb39406 # v2.2.1 | |
| if: ${{ contains(matrix.settings.target, 'musl') }} | |
| with: | |
| version: 0.14.1 | |
| - name: Install cargo-zigbuild | |
| uses: taiki-e/install-action@a416ddeedbd372e614cc1386e8b642692f66865e # v2.57.1 | |
| if: ${{ contains(matrix.settings.target, 'musl') }} | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| tool: cargo-zigbuild | |
| - name: Setup toolchain | |
| run: ${{ matrix.settings.setup }} | |
| if: ${{ matrix.settings.setup }} | |
| shell: bash | |
| - name: Restore Node dependencies cache | |
| id: cache-node-modules | |
| uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| path: | | |
| node_modules | |
| ~/.npm | |
| key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }} | |
| restore-keys: node-modules-${{ runner.os }} | |
| - name: Install Node dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: npm ${{ github.ref == 'refs/heads/master' && 'ci' || 'install' }} --ignore-scripts | |
| - name: Save Node dependencies cache | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' && github.ref == 'refs/heads/master' | |
| uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| path: | | |
| node_modules | |
| ~/.npm | |
| key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }} | |
| - name: Build in docker | |
| uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # v3 | |
| if: ${{ matrix.settings.docker }} | |
| with: | |
| image: ${{ matrix.settings.docker }} | |
| options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build' | |
| run: ${{ matrix.settings.build }} | |
| - name: Build | |
| run: ${{ matrix.settings.build }} | |
| if: ${{ !matrix.settings.docker }} | |
| shell: bash | |
| - name: Save Cargo cache | |
| if: github.ref == 'refs/heads/master' | |
| uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| .cargo-cache | |
| rust/target/ | |
| key: ${{ matrix.settings.name || matrix.settings.target }}-cargo-${{ matrix.settings.host }}-${{ hashFiles('rust/Cargo.lock') }} | |
| - name: Upload wasm artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: bindings-${{ matrix.settings.name }} | |
| path: ${{ matrix.settings.path }} | |
| if-no-files-found: error | |
| if: ${{ matrix.settings.is-wasm-build }} | |
| - name: Upload napi artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: ${{ env.APP_NAME }}.*.node | |
| if-no-files-found: error | |
| if: ${{ !matrix.settings.is-wasm-build }} | |
| publish: | |
| name: Publish | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: | |
| - build | |
| steps: | |
| - name: Checkout Commit | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| # Necessary to find the commits included in the release | |
| fetch-depth: 0 | |
| - name: Setup Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| check-latest: true | |
| - name: Restore Node dependencies cache | |
| id: cache-node-modules | |
| uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| path: | | |
| node_modules | |
| ~/.npm | |
| key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }} | |
| restore-keys: node-modules-${{ runner.os }} | |
| - name: Install Node dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: npm install --ignore-scripts | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: artifacts | |
| - name: Copy wasm files | |
| run: cp -R artifacts/bindings-wasm/wasm . | |
| - name: Build JavaScript | |
| run: npm run build:cjs && cp artifacts/*/*.node dist/ && npm run build:bootstrap | |
| - name: see npm | |
| run : | | |
| sudo apt update && sudo apt install tree | |
| tree ./npm | |
| - name: Move artifacts | |
| run: npm run ci:artifacts | |