jdrouet/mrml

View on GitHub
.github/workflows/mrml-wasm-release.yml

Summary

Maintainability
Test Coverage
on:
  workflow_call:
    inputs:
      release_tag:
        description: "Release tag to use"
        type: string
        required: true
      publish:
        description: "Should publish to npm registry"
        type: boolean
        required: false
        default: false
  workflow_dispatch:
    inputs:
      release_tag:
        description: "Release tag to use"
        type: string
        required: true
      publish:
        description: "Should publish to npm registry"
        type: boolean
        required: false
        default: false

name: mrml-wasm release

defaults:
  run:
    working-directory: packages/mrml-wasm

env:
  RUSTFLAGS: "-Dwarnings"

jobs:
  release:
    runs-on: ubuntu-latest

    concurrency:
      group: ${{ github.ref }}-mrml-wasm-release
      cancel-in-progress: true

    steps:
      - uses: actions/checkout@v4

      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal

      # Setup .npmrc file to publish to npm
      - uses: actions/setup-node@v4
        with:
          node-version: latest
          registry-url: "https://registry.npmjs.org"

      - name: install wasm-pack
        run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-mrml-wasm-testing-${{ hashFiles('**/Cargo.lock') }}

      - name: build release
        run: bash build.sh

      - name: publish release
        if: inputs.publish
        run: cd pkg && npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

  notify:
    runs-on: ubuntu-latest
    needs: [release]

    steps:
      - name: notify mastodon
        uses: cbrgm/mastodon-github-action@v2
        with:
          message: |
            👋 Hey! I just released a new version of mrml for javascript!
            https://github.com/jdrouet/mrml/releases/tag/${{ inputs.release_tag }} and https://www.npmjs.com/package/mrml
          visibility: "public"
        env:
          MASTODON_URL: ${{ secrets.MASTODON_URL }}
          MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
        continue-on-error: true