lunatic-runtime 0.13.2

An actor platform built on WebAssembly
Documentation
# This workflow does 2 things:
# - For every push & pull request it will run the tests.
# - For every tag it will create a release.
#   The tags must be in the following format: "vX.Y.Z", where X.Y.Z is the release version.

on:
  push:
  pull_request:

name: Test & (release)

jobs:
  test_or_release:
    name: Test & (release)
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target_name: lunatic
            asset_name: lunatic-linux-amd64.tar.gz
            content_type: application/gzip
          - os: macos-11
            target_name: lunatic
            asset_name: lunatic-macos-universal.tar.gz
            content_type: application/gzip
          - os: windows-latest
            target_name: lunatic.exe
            asset_name: lunatic-windows-amd64.zip
            content_type: application/zip
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Install latest Rust
        if: runner.os != 'macOS'
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
          components: rustfmt, clippy
      - name: Install latest Rust with an additional AArch64 target on macOS
        if: runner.os == 'macOS'
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: aarch64-apple-darwin
          override: true
          components: rustfmt, clippy
      # Rust builds can take some time, cache them.
      - uses: Swatinem/rust-cache@v2
      - name: "Run clippy check"
        run: cargo clippy --examples --tests --benches -- -D warnings
      - name: "Check formatting"
        run: cargo fmt -- --check
      - name: "Run tests"
        run: cargo test --all

      # Create a release:
      # - The next steps will only run if a tag was added during the push
      - name: Build project on Linux and Windows
        if: startsWith(github.ref, 'refs/tags/') && runner.os != 'macOS'
        run: |
          cargo build --release
          mv ./target/release/${{ matrix.target_name }} ${{ matrix.target_name }}
      - name: Build project on macOs and package into universal binary
        if: startsWith(github.ref, 'refs/tags/') && runner.os == 'macOS'
        run: |
          cargo build --release --target x86_64-apple-darwin
          cargo build --release --target aarch64-apple-darwin
          lipo -create -output lunatic target/aarch64-apple-darwin/release/lunatic target/x86_64-apple-darwin/release/lunatic
      - name: Tar release on Unix
        if: startsWith(github.ref, 'refs/tags/') && runner.os != 'Windows'
        run: tar czf ${{ matrix.asset_name }} README.md LICENSE-MIT LICENSE-APACHE ${{ matrix.target_name }}
      - name: Zip release on Windows
        if: startsWith(github.ref, 'refs/tags/') && runner.os == 'Windows'
        uses: vimtor/action-zip@v1
        with:
          files: README.md LICENSE-MIT LICENSE-APACHE ${{ matrix.target_name }}
          dest: ${{ matrix.asset_name }}
      - name: Get release name
        if: startsWith(github.ref, 'refs/tags/')
        id: getReleaseName
        run: echo "RELEASE_NAME=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
      - name: Generate release notes
        if: startsWith(github.ref, 'refs/tags/')
        run: |
          awk '/^## v[0-9]+\.[0-9]+\.[0-9]+/ && STATE=="show" { exit }
              STATE=="show";
              /^## ${{ steps.getReleaseName.outputs.RELEASE_NAME }}/ { STATE="catch" }
              /^Released [0-9]+-[0-9]+-[0-9]+/ && STATE=="catch" { STATE="show" }' CHANGELOG.md \
          | awk 'NF { SHOW=1 } SHOW' > RELEASE_NOTES.md
      - name: Release
        if: startsWith(github.ref, 'refs/tags/')
        uses: softprops/action-gh-release@v1
        with:
          tag_name: ${{ steps.getReleaseName.outputs.RELEASE_NAME }}
          name: Lunatic ${{ steps.getReleaseName.outputs.RELEASE_NAME }}
          body_path: RELEASE_NOTES.md
          draft: true
          files: ${{ matrix.asset_name }}