Skip to content

WASM Release

WASM Release #58

Workflow file for this run

name: WASM Release
on:
workflow_dispatch:
inputs:
changelog:
description: "Changelog (optional)"
required: false
default: ""
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
jobs:
release:
name: WASM Release and Publish
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
environment: release-wasm
# Restrict execution to specific users
if: contains(fromJson('["mtbitcr", "zupzup", "tompro", "cleot"]'), github.actor)
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Create Github App token
id: app-token
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
with:
app-id: ${{ vars.PRIVATE_REPO_ACCESS_APP_ID }}
private-key: ${{ secrets.PRIVATE_REPO_ACCESS_APP_PRIVATE_KEY }}
owner: BitcreditProtocol
- name: Git auth with app token
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git config --global url."https://x-access-token:${GH_TOKEN}@github.com/".insteadOf "https://github.com/"
- name: Extract version from Cargo.toml
id: get_version
run: |
VERSION=$(grep -m 1 '^version =' Cargo.toml | cut -d '"' -f2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Detected version: v$VERSION"
- name: Ensure tag does not already exist
run: |
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
echo "Error: Tag v${{ env.VERSION }} already exists!"
exit 1
fi
- name: Install Node.js
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: 24.12.0
registry-url: "https://registry.npmjs.org"
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
with:
toolchain: stable
- name: Install wasm-pack
run: |
cd scripts
bash install-wasm-pack.sh
- name: Build with wasm-pack
env:
RUSTFLAGS: '--cfg getrandom_backend="wasm_js"'
run: |
cd crates/bcr-ebill-wasm
wasm-pack build --target web --scope bitcredit --out-name index
- name: Copy LICENSE into pkg/
run: |
cp LICENSE crates/bcr-ebill-wasm/pkg/
- name: Create and push git tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "v${{ env.VERSION }}"
git push origin "v${{ env.VERSION }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
tag_name: v${{ env.VERSION }}
name: v${{ env.VERSION }}
body: |
${{ inputs.changelog }}
**Version:** v${{ env.VERSION }}
draft: false
prerelease: false
- name: Upload WASM artifacts to Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
cd crates/bcr-ebill-wasm/pkg
for file in *; do
if [[ "$file" != ".gitignore" ]]; then
gh release upload "v${{ env.VERSION }}" "$file"
fi
done
- name: Publish to npm
run: |
cd crates/bcr-ebill-wasm/pkg
npm publish --access public --provenance --tag latest