chore: reorganize directories #363
This file contains 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: Publish Any Commit | |
on: | |
pull_request: | |
push: | |
branches: | |
- "**" | |
tags: | |
- "!**" | |
env: | |
DEBUG: napi:* | |
APP_NAME: tree-shaker | |
MACOSX_DEPLOYMENT_TARGET: '10.13' | |
CARGO_INCREMENTAL: '1' | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
settings: | |
- host: windows-latest | |
build: pnpm build --target x86_64-pc-windows-msvc | |
target: x86_64-pc-windows-msvc | |
- host: macos-latest | |
target: x86_64-apple-darwin | |
setup: rustup target add x86_64-apple-darwin | |
build: pnpm build --target x86_64-apple-darwin | |
- host: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian | |
build: cd tasks/napi; pnpm build --target x86_64-unknown-linux-gnu | |
- host: macos-latest | |
target: aarch64-apple-darwin | |
build: pnpm build --target aarch64-apple-darwin | |
name: ${{ matrix.settings.target }} | |
runs-on: ${{ matrix.settings.host }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
if: ${{ !matrix.settings.docker }} | |
with: | |
node-version: 22 | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Install | |
uses: dtolnay/rust-toolchain@stable | |
if: ${{ !matrix.settings.docker }} | |
with: | |
toolchain: stable | |
targets: ${{ matrix.settings.target }} | |
- name: Cache cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
.cargo-cache | |
target/ | |
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} | |
- name: Setup toolchain | |
run: ${{ matrix.settings.setup }} | |
if: ${{ matrix.settings.setup }} | |
shell: bash | |
- name: Install dependencies | |
run: pnpm install | |
working-directory: ./packages/napi | |
- name: Build in docker | |
uses: addnab/docker-run-action@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 | |
working-directory: ./packages/napi | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bindings-${{ matrix.settings.target }} | |
path: napi/${{ env.APP_NAME }}.*.node | |
if-no-files-found: error | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Install dependencies | |
run: pnpm install | |
working-directory: ./packages/napi | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./packages/napi/artifacts | |
- name: Move artifacts | |
run: pnpm artifacts | |
working-directory: ./packages/napi | |
- name: List packages | |
run: ls -R ./npm | |
shell: bash | |
working-directory: ./packages/napi | |
- run: node ./scripts/patch.mjs | |
working-directory: ./packages/napi | |
- run: pnpx pkg-pr-new publish './' './npm/*' --pnpm | |
working-directory: ./packages/napi |