build #3
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: "build" | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Install wasm-pack | |
run: | | |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: Get package name and version | |
id: cargo_version | |
run: | | |
echo "NAME=$(grep '^name' Cargo.toml | sed -E 's/name = \"(.*)\"/\1/')" >> $GITHUB_ENV | |
echo "VERSION=$(grep '^version' Cargo.toml | sed -E 's/version = \"(.*)\"/\1/')" >> $GITHUB_ENV | |
- name: Build with wasm-pack | |
run: wasm-pack build --release --target nodejs | |
- name: Rename wasm file | |
run: | | |
mkdir -p dist | |
mv pkg/${{ env.NAME }}_bg.wasm pkg/${{ env.NAME }}_${{ env.VERSION }}.wasm | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
id: create_release | |
with: | |
token: ${{ github.token }} | |
tag_name: ${{ env.VERSION }} | |
name: Release v${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
- name: Upload release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: pkg/${{ env.NAME }}_${{ env.VERSION }}.wasm | |
asset_name: ${{ env.NAME }}_${{ env.VERSION }}.wasm | |
asset_content_type: application/wasm |