fixing version #342
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: Rust | |
on: | |
push: | |
branches: [main] | |
tags: | |
- 'v*' | |
- 'cli-v*' | |
- 'wasm-v*' | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
build-library: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/cli-v') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: Check Formatting | |
run: cargo fmt -- --check | |
- name: Security audit | |
run: cargo audit | |
- name: Build Library | |
run: cargo build --verbose | |
- name: Run Library Tests | |
run: cargo test --verbose | |
- name: Run Library Tests with plaintext before with enabled | |
run: cargo test --verbose -F plaintext-before-extension | |
- name: Lint with Clippy | |
run: | | |
rustup component add clippy | |
cargo clippy -- -D warnings | |
build-cli: | |
runs-on: ubuntu-latest | |
needs: build-library | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: Build CLI | |
run: | | |
cd cli/src | |
cargo build --verbose | |
- name: Run CLI Tests | |
run: | | |
cd cli/src | |
cargo test --verbose | |
- name: Lint CLI with Clippy | |
run: | | |
rustup component add clippy | |
cd cli/src | |
cargo clippy -- -D warnings | |
build-wasm: | |
runs-on: ubuntu-latest | |
needs: build-library | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: Build WASM | |
run: | | |
cd wasm | |
cargo build --verbose | |
- name: Run CLI Tests | |
run: | | |
cd wasm | |
cargo test --verbose | |
- name: Lint CLI with Clippy | |
run: | | |
rustup component add clippy | |
cd wasm | |
cargo clippy -- -D warnings | |
publish-library: | |
needs: build-library | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Publish Library to crates.io | |
uses: actions-rs/cargo@v1 | |
with: | |
command: publish | |
args: --token ${{ secrets.CRATESTOKEN }} | |
publish-cli: | |
needs: build-cli | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/cli-v') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Publish CLI to crates.io | |
run: | | |
cd cli/src | |
cargo publish --token ${{ secrets.CRATESTOKEN }} | |
publish-wasm: | |
needs: build-wasm | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
if: startsWith(github.ref, 'refs/tags/wasm-v') | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Install wasm-pack | |
run: cargo install wasm-pack | |
- name: Build wasm package | |
run: | | |
cd wasm | |
wasm-pack build --target bundler | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
token: ${{ secrets.NPM_TOKEN }} | |
- name: Install npm dependencies | |
run: | | |
cd wasm/pkg | |
npm install | |
npm ci | |
- name: Publish to npm | |
run: | | |
cd wasm/pkg | |
npm publish --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |