Skip to content

publish-napi

publish-napi #145

Workflow file for this run

# 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
build: pnpm build --target x86_64-apple-darwin
- host: windows-latest
build: pnpm build --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: windows-latest
build: pnpm build --target i686-pc-windows-msvc
target: i686-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build: cd node && pnpm build --target x86_64-unknown-linux-gnu
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: cd node && pnpm build --target x86_64-unknown-linux-musl
- host: macos-latest
target: aarch64-apple-darwin
build: pnpm build --target aarch64-apple-darwin
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
build: cd node && pnpm build --target aarch64-unknown-linux-gnu
- host: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
setup: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf -y
build: pnpm build --target armv7-unknown-linux-gnueabihf
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: |-
set -e &&
cd node &&
rustup target add aarch64-unknown-linux-musl &&
pnpm build --target aarch64-unknown-linux-musl
- host: windows-latest
target: aarch64-pc-windows-msvc
build: pnpm build --target aarch64-pc-windows-msvc
name: stable - ${{ matrix.settings.target }} - node@20
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- run: corepack enable
- name: Setup node
uses: actions/setup-node@v4
if: ${{ !matrix.settings.docker }}
with:
node-version: 20
cache: pnpm
- 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 }}
- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' || matrix.settings.target == 'armv7-unknown-linux-musleabihf' }}
with:
version: 0.11.0
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Setup node x86
if: matrix.settings.target == 'i686-pc-windows-msvc'
run: pnpm config set supportedArchitectures.cpu "ia32"
shell: bash
- name: Install dependencies
run: pnpm install
- name: Setup node x86
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: 20
cache: pnpm
architecture: x86
- 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
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: napi-${{ matrix.settings.target }}
path: node/${{ env.APP_NAME }}.*.node
if-no-files-found: error
build-universal-macOS:
name: Build universal macOS binary
needs:
- build
runs-on: macos-latest
defaults:
run:
working-directory: node
steps:
- uses: actions/checkout@v4
- run: corepack enable
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Download macOS x64 artifact
uses: actions/download-artifact@v4
with:
name: napi-x86_64-apple-darwin
path: node/artifacts
- name: Download macOS arm64 artifact
uses: actions/download-artifact@v4
with:
name: napi-aarch64-apple-darwin
path: node/artifacts
- name: Combine binaries
run: pnpm universal
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: napi-universal-apple-darwin
path: node/${{ env.APP_NAME }}.darwin-universal.node
if-no-files-found: error
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- build-universal-macOS
defaults:
run:
working-directory: node
steps:
- uses: actions/checkout@v3
- run: corepack enable
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: node/artifacts
- name: List artifacts
run: ls artifacts
shell: bash
- 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 }}