publish-napi #85
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
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy | |
# SPDX-License-Identifier: Apache-2.0 | |
# SPDX-License-Identifier: MIT | |
name: publish napi modules | |
env: | |
DEBUG: napi:* | |
APP_NAME: create-tauri-app | |
MACOSX_DEPLOYMENT_TARGET: '10.13' | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseId: | |
description: 'Release Id' | |
required: true | |
type: string | |
repository_dispatch: | |
types: [publish-napi] | |
jobs: | |
build: | |
defaults: | |
run: | |
working-directory: node | |
strategy: | |
fail-fast: false | |
matrix: | |
settings: | |
- host: macos-latest | |
target: x86_64-apple-darwin | |
architecture: x64 | |
build: | | |
pnpm build | |
strip -x *.node | |
- host: windows-latest | |
target: x86_64-pc-windows-msvc | |
architecture: x64 | |
build: pnpm build | |
- host: windows-latest | |
target: i686-pc-windows-msvc | |
architecture: x64 | |
build: | | |
pnpm build --target i686-pc-windows-msvc | |
- host: windows-latest | |
target: aarch64-pc-windows-msvc | |
architecture: x64 | |
build: | | |
pnpm build --target aarch64-pc-windows-msvc | |
- host: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian | |
build: |- | |
set -e && | |
cd node && | |
pnpm build --target x86_64-unknown-linux-gnu && | |
strip *.node | |
- host: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine | |
build: set -e && cd node && pnpm build && strip *.node | |
- host: macos-latest | |
target: aarch64-apple-darwin | |
build: | | |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; | |
export CC=$(xcrun -f clang); | |
export CXX=$(xcrun -f clang++); | |
SYSROOT=$(xcrun --sdk macosx --show-sdk-path); | |
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; | |
pnpm build --target aarch64-apple-darwin | |
strip -x *.node | |
- host: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 | |
build: |- | |
set -e && | |
cd node && | |
pnpm build --target aarch64-unknown-linux-gnu && | |
aarch64-unknown-linux-gnu-strip *.node | |
- host: ubuntu-latest | |
target: armv7-unknown-linux-gnueabihf | |
architecture: x64 | |
setup: | | |
sudo apt-get update | |
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y | |
build: | | |
pnpm build --target=armv7-unknown-linux-gnueabihf | |
arm-linux-gnueabihf-strip *.node | |
- host: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
architecture: x64 | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine | |
build: |- | |
set -e && | |
rustup target add aarch64-unknown-linux-musl && | |
cd node && | |
pnpm build --target aarch64-unknown-linux-musl && | |
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node | |
name: napi - ${{ matrix.settings.target }} - node@16 | |
runs-on: ${{ matrix.settings.host }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/[email protected] | |
with: | |
version: 8 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
check-latest: true | |
cache: 'pnpm' | |
cache-dependency-path: '**/pnpm-lock.yaml' | |
architecture: ${{ matrix.settings.architecture }} | |
- uses: dtolnay/rust-toolchain@stable | |
if: ${{ !matrix.settings.docker }} | |
with: | |
targets: ${{ matrix.settings.target }} | |
- uses: Swatinem/rust-cache@v1 | |
if: ${{ matrix.settings.docker }} | |
with: | |
key: ${{ matrix.settings.target }} | |
- name: Setup toolchain | |
run: ${{ matrix.settings.setup }} | |
if: ${{ matrix.settings.setup }} | |
shell: bash | |
- name: Install dependencies | |
run: pnpm install -w --filter . | |
- 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:/root/.cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/root/.cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/root/.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: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: napi-${{ matrix.settings.target }} | |
path: node/${{ env.APP_NAME }}.*.node | |
if-no-files-found: error | |
publish: | |
defaults: | |
run: | |
working-directory: node | |
name: Publish | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/[email protected] | |
with: | |
version: 8 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
check-latest: true | |
cache: pnpm | |
cache-dependency-path: '**/pnpm-lock.yaml' | |
- name: Install dependencies | |
run: pnpm install -w --filter . | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: node/artifacts | |
- name: Move artifacts | |
run: pnpm artifacts | |
- name: List packages | |
run: ls -R ./npm | |
shell: bash | |
- name: Publish | |
run: | | |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | |
npm publish | |
jq '.name = "create-tauri" | .bin = { "create-tauri": .bin["create-tauri-app"] } | del(.scripts.prepublishOnly)' package.json > package.tmp | |
mv -f package.tmp package.json | |
npm publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.ORG_NPM_TOKEN }} | |
RELEASE_ID: ${{ github.event.client_payload.releaseId || inputs.releaseId }} |