ci: add release npm cli

This commit is contained in:
LongYinan 2023-07-18 10:38:53 +08:00
parent 4e0c9b14e4
commit 092f9d5290
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
11 changed files with 179 additions and 221 deletions

View file

@ -14,8 +14,8 @@ on:
pull_request: pull_request:
jobs: jobs:
build_and_test: test:
name: nightly - ubuntu - node@16 name: Address sanitizer
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:

View file

@ -1,35 +0,0 @@
name: Check NAPI-RS features
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_and_test:
strategy:
fail-fast: false
matrix:
settings:
- features: 'napi1,napi2,napi3,napi4,napi5,napi6,napi7,napi8,experimental,async,chrono_date,latin1,full'
package: 'napi'
- features: 'compat-mode,strict,type-def,noop,full,default'
package: 'napi-derive'
name: stable - ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Check build
run: cargo check -p ${{ matrix.settings.package }} -F ${{ matrix.settings.features }}

View file

@ -1,52 +0,0 @@
name: Cli Build Binary
env:
DEBUG: 'napi:*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
pull_request:
jobs:
build_binary_crate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-cargo-cache-build-binary
- name: 'Install dependencies'
run: yarn install --mode=skip-build --immutable
- name: Build and run binary
run: |
yarn workspace binary build
./examples/binary/napi-examples-binary
yarn workspace binary build --profile napi-rs-custom
env:
RUST_BACKTRACE: 1

View file

@ -1,56 +0,0 @@
name: Lint
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint SourceCode
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: lint-cargo-cache
- name: 'Install dependencies'
run: yarn install --immutable --mode=skip-build
- name: 'Lint JS/TS'
run: yarn lint
- name: Cargo fmt
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache

View file

@ -1,66 +0,0 @@
name: Linux-armv7
env:
DEBUG: 'napi:*'
RUST_BACKTRACE: 1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: stable - armv7-unknown-linux-gnu - node@18
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: armv7-unknown-linux-gnueabihf
- name: Install ziglang
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.10.1
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-linux-armv7-gnu-node@18-cargo-cache
- name: Install dependencies
run: |
yarn config set --json supportedArchitectures.cpu '["arm", "current"]'
yarn install --immutable --mode=skip-build
- name: Cross build native tests
run: yarn build:test -- --target armv7-unknown-linux-gnueabihf --cross-compile
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: node:lts-bullseye-slim
options: --platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build
run: yarn test

View file

@ -1,4 +1,4 @@
name: Test name: Test & Release
env: env:
DEBUG: 'napi:*' DEBUG: 'napi:*'
@ -9,6 +9,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
permissions:
contents: write
id-token: write
on: on:
push: push:
branches: branches:
@ -16,6 +20,45 @@ on:
pull_request: pull_request:
jobs: jobs:
lint:
name: Lint SourceCode
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: lint-cargo-cache
- name: 'Install dependencies'
run: yarn install --immutable --mode=skip-build
- name: 'Lint JS/TS'
run: yarn lint
- name: Cargo fmt
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy
build_and_test: build_and_test:
strategy: strategy:
fail-fast: false fail-fast: false
@ -324,3 +367,131 @@ jobs:
image: ${{ steps.image-name.outputs.docker-image }} image: ${{ steps.image-name.outputs.docker-image }}
options: ${{ matrix.settings.args }} -v ${{ github.workspace }}:/build -w /build options: ${{ matrix.settings.args }} -v ${{ github.workspace }}:/build -w /build
run: yarn test run: yarn test
build-and-test-linux-armv7:
name: stable - armv7-unknown-linux-gnu - node@18
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: armv7-unknown-linux-gnueabihf
- name: Install ziglang
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.10.1
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-linux-armv7-gnu-node@18-cargo-cache
- name: Install dependencies
run: |
yarn config set --json supportedArchitectures.cpu '["arm", "current"]'
yarn install --immutable --mode=skip-build
- name: Cross build native tests
run: yarn build:test -- --target armv7-unknown-linux-gnueabihf --cross-compile
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: node:lts-bullseye-slim
options: --platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build
run: yarn test
build_binary_crate:
runs-on: ubuntu-latest
name: Test cli build binary
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-cargo-cache-build-binary
- name: 'Install dependencies'
run: yarn install --mode=skip-build --immutable
- name: Build and run binary
run: |
yarn workspace binary build
./examples/binary/napi-examples-binary
yarn workspace binary build --profile napi-rs-custom
check-all-features:
strategy:
fail-fast: false
matrix:
settings:
- features: 'napi1,napi2,napi3,napi4,napi5,napi6,napi7,napi8,experimental,async,chrono_date,latin1,full'
package: 'napi'
- features: 'compat-mode,strict,type-def,noop,full,default'
package: 'napi-derive'
name: stable - ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Check build
run: cargo check -p ${{ matrix.settings.package }} -F ${{ matrix.settings.features }}
release-npm:
runs-on: ubuntu-latest
if: "startsWith(github.event.head_commit.message, 'chore(release): publish')"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Publish
run: |
yarn install --mode=skip-build
yarn build
npm config set provenance true
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
yarn lerna publish from-package --pre-dist-tag canary --yes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

View file

@ -3,4 +3,5 @@ node_modules
scripts scripts
triples/index.js triples/index.js
examples/napi/index.d.ts examples/napi/index.d.ts
.yarn .yarn
yarn.lock

View file

@ -1,6 +1,6 @@
{ {
"name": "@napi-rs/cli", "name": "@napi-rs/cli",
"version": "3.0.0-alpha.3", "version": "3.0.0-alpha.4",
"description": "Cli tools for napi-rs", "description": "Cli tools for napi-rs",
"author": "LongYinan <lynweklm@gmail.com>", "author": "LongYinan <lynweklm@gmail.com>",
"homepage": "https://github.com/napi-rs/napi-rs", "homepage": "https://github.com/napi-rs/napi-rs",

View file

@ -1,5 +1,5 @@
{ {
"version": "independent", "version": "independent",
"npmClient": "yarn", "npmClient": "yarn",
"message": "chore: publish" "message": "chore(release): publish"
} }

View file

@ -60,11 +60,6 @@
"cargo fmt --" "cargo fmt --"
] ]
}, },
"husky": {
"hooks": {
"pre-commit": "lint-staged && cargo fmt --all"
}
},
"devDependencies": { "devDependencies": {
"@napi-rs/cli": "workspace:*", "@napi-rs/cli": "workspace:*",
"@rollup/plugin-alias": "^5.0.0", "@rollup/plugin-alias": "^5.0.0",

View file

@ -1,6 +1,6 @@
{ {
"name": "@napi-rs/triples", "name": "@napi-rs/triples",
"version": "2.0.0-alpha.1", "version": "2.0.0-alpha.2",
"description": "Rust target triples objects", "description": "Rust target triples objects",
"keywords": [ "keywords": [
"Rust", "Rust",