Skip to content

fix(ci): depend on build #7

fix(ci): depend on build

fix(ci): depend on build #7

Workflow file for this run

name: CI
env:
DEBUG: napi:*
APP_NAME: iroh
MACOSX_DEPLOYMENT_TARGET: "10.13"
CARGO_INCREMENTAL: "1"
"on":
push:
branches:
- main
tags-ignore:
- "**"
paths-ignore:
- "**/*.md"
- LICENSE
- "**/*.gitignore"
pull_request: null
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "latest"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Install dependencies
run: bun install
- name: Cargo fmt
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
build: bun run build --target x86_64-apple-darwin
- host: windows-latest
build: bun run build --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: bun run build --target x86_64-unknown-linux-gnu --use-napi-cross
- host: macos-latest
target: aarch64-apple-darwin
build: bun run build --target aarch64-apple-darwin
name: stable - ${{ matrix.settings.target }} - bun
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v6
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "latest"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
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/
~/.napi-rs
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- uses: mlugg/setup-zig@v2
if: ${{ contains(matrix.settings.target, 'musl') }}
with:
version: 0.14.1
- name: Install cargo-zigbuild
uses: taiki-e/install-action@v2
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: Install dependencies
run: bun install
- name: Build
run: ${{ matrix.settings.build }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v5
with:
name: bindings-${{ matrix.settings.target }}
path: |
${{ env.APP_NAME }}.*.node
${{ env.APP_NAME }}.*.wasm
if-no-files-found: error
publish:
name: Publish
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # required for trusted publishing
needs:
- lint
- build
steps:
- uses: actions/checkout@v6
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "latest"
- name: Install dependencies
run: bun install
- name: Create npm dirs
run: bun run napi create-npm-dirs
- name: Download all artifacts
uses: actions/download-artifact@v6
with:
path: artifacts
- name: Move artifacts
run: bun run artifacts
- name: List packages
run: ls -R ./npm
shell: bash
- name: Publish (Trusted Publishers)
run: |
# Enable provenance (REQUIRED)
npm config set provenance true
# Only publish on applicable commit messages
VERSION_REGEX="^[0-9]+\.[0-9]+\.[0-9]+$"
NEXT_REGEX="^[0-9]+\.[0-9]+\.[0-9]+"
COMMIT_MSG=$(git log -1 --pretty=%B)
if echo "$COMMIT_MSG" | grep -qE "$VERSION_REGEX"; then
npm publish --access public
elif echo "$COMMIT_MSG" | grep -qE "$NEXT_REGEX"; then
npm publish --tag next --access public
else
echo "Not a release commit. Skipping publish."
fi