chore: wasm npm package #432
Workflow file for this run
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: CI/CD | |
on: | |
push: | |
paths-ignore: | |
- README.md | |
branches: [main] | |
tags: [v*.*.*] | |
pull_request: {} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Test | |
run: cargo test -F bin,wasm | |
- name: Lint | |
run: cargo clippy -F bin,wasm | |
version: | |
runs-on: ubuntu-latest | |
needs: test | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Compute package version | |
id: version | |
run: echo "version=${GITHUB_REF##refs/tags/v}" >> $GITHUB_OUTPUT | |
build: | |
runs-on: ubuntu-latest | |
needs: version | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Override version | |
run: sed -i 's/^version = ".+"$/version = "${{ needs.version.outputs.version }}"/' Cargo.toml | |
- name: Install cross | |
run: cargo install cross --git https://github.com/cross-rs/cross | |
- uses: oven-sh/setup-bun@v1 | |
- name: Install npm packages | |
run: bun install --frozen-lockfile | |
- name: Build cross platforms | |
run: | | |
cross build --release --locked --target aarch64-unknown-linux-gnu | |
cross build --release --locked --target aarch64-unknown-linux-musl | |
cross build --release --locked --target x86_64-unknown-linux-gnu | |
cross build --release --locked --target x86_64-unknown-linux-musl | |
cross build --release --locked --target x86_64-pc-windows-gnu | |
mkdir tmp/ | |
mv ./target/aarch64-unknown-linux-gnu/release/base-converter ./tmp/base-converter-aarch64-unknown-linux-gnu | |
mv ./target/aarch64-unknown-linux-musl/release/base-converter ./tmp/base-converter-aarch64-unknown-linux-musl | |
mv ./target/x86_64-unknown-linux-gnu/release/base-converter ./tmp/base-converter-x86_64-unknown-linux-gnu | |
mv ./target/x86_64-unknown-linux-musl/release/base-converter ./tmp/base-converter-x86_64-unknown-linux-musl | |
mv ./target/x86_64-pc-windows-gnu/release/base-converter ./tmp/base-converter-x86_64-pc-windows-gnu | |
- name: Build wasm | |
run: bun run build | |
- name: Publish on npmjs.com | |
working-directory: pkg/ | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
cp ../.npmrc . | |
npm version --no-git-tag-version '${{ needs.version.outputs.version }}' | |
npm publish | |
- name: Publish on crates.io | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
run: cargo publish --allow-dirty --locked | |
- name: Github Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
generate_release_notes: true | |
fail_on_unmatched_files: true | |
files: | | |
./tmp/base-converter-aarch64-unknown-linux-gnu | |
./tmp/base-converter-aarch64-unknown-linux-musl | |
./tmp/base-converter-x86_64-unknown-linux-gnu | |
./tmp/base-converter-x86_64-unknown-linux-musl | |
./tmp/base-converter-x86_64-pc-windows-gnu | |
body: | | |
# Rust Doc | |
https://docs.rs/base-converter/${{ steps.version.outputs.version }}/base_converter/ | |
# NPM Package | |
https://www.npmjs.com/package/@ctison/base-converter/v/${{ steps.version.outputs.version }} |