monster-rs 0.4.1

Monster is a symbolic execution engine for 64-bit RISC-U code
Documentation
name: Release

on:
  push:
    branches:
      - release
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  build:
    name: Build Release
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        toolchain: [1.52.0]
        os: [ubuntu-20.04, macos-10.15, windows-2019]
        include:
          - platform: linux
            os: ubuntu-20.04
            features: z3,boolector
            target: x86_64-unknown-linux-gnu
            extension: ""
          - platform: macos
            os: macos-10.15
            features: z3,boolector
            target: x86_64-apple-darwin
            extension: ""
          - platform: windows
            os: windows-2019
            features: z3
            target: x86_64-pc-windows-msvc
            extension: ".exe"
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install Rust ${{ matrix.toolchain }}
        uses: actions-rs/toolchain@v1
        with:
          profile: default
          toolchain: ${{ matrix.toolchain }}
          target: ${{ matrix.target }}
          override: true

      - name: Compute new Version
        id: compute_version
        uses: mathieudutour/github-tag-action@v5.2
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          release_branches: .*
          dry_run: true

      - name: Install Sed on Windows
        if: ${{ contains(matrix.os, 'windows') }}
        run: choco install sed -y

      - name: Update Version in Manifest
        shell: bash
        run: |
          ${{ format('sed -i -e "s/^version[[:space:]]*=[[:space:]]*\"[[:digit:]]*.[[:digit:]]*.[[:digit:]]*\"/version = \"{0}\"/g" Cargo.toml', steps.compute_version.outputs.new_version) }}

      # Sync lock file for build with --locked flag
      - name: Update Lock File to New Manifest Version
        uses: actions-rs/cargo@v1
        with:
          command: update
          args: --package monster-rs

      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --target ${{ matrix.target }} --features ${{ matrix.features }} --locked

      - name: Rename Binary
        shell: bash
        run: mv target/${{ matrix.target }}/release/monster${{ matrix.extension }} ./monster-${{ matrix.target }}${{ matrix.extension }}

      - name: Upload Binary Artifact
        uses: actions/upload-artifact@v2
        with:
          name: monster-${{ matrix.platform }}
          path: monster-${{ matrix.target }}${{ matrix.extension }}
          if-no-files-found: error

  # TODO: Sign bot commits, once this is supported:
  # https://github.com/actions/runner/issues/667
  release:
    name: Semantic Release
    needs: build
    # secrets of this environment are needed
    environment: Release
    runs-on: ubuntu-20.04
    env:
      # Configure author for bot commits using the github-actions bot credentials
      GIT_AUTHOR_NAME: "Github Action"
      GIT_AUTHOR_EMAIL: "action@github.com"
      GIT_COMMITTER_NAME: "Github Action"
      GIT_COMMITTER_EMAIL: "action@github.com"
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          # use credentials, that are allowed to commit to release branch
          ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          # full history needed by semantic release (analysis commit messages)
          fetch-depth: 0

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: 1.52.0
          override: true

      - name: Install Semantic Release for Rust
        uses: actions-rs/cargo@v1
        with:
          command: install
          args: semantic-release-rust --version 1.0.0-alpha.8 --locked

      # The release build is used in the Semantic Release step
      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --all-features --locked

      # Download all binary artifacts to release
      - uses: actions/download-artifact@v2
        with:
          name: monster-linux

      - uses: actions/download-artifact@v2
        with:
          name: monster-windows

      - uses: actions/download-artifact@v2
        with:
          name: monster-macos

      # Executes the following sub steps:
      # 1. analyze Git commit messages (conventional commits) and tags
      # 2. compute a new version based on commit message types and the latest git tag
      # 3. compute the release notes based on commit messages (feat and fix types are included)
      # 4. adjust the version in the manifest (Cargo.toml)
      # 5. create a Git tag with new version
      # 6. create a Github Release with version, release notes and release binaries
      # 7. publish the package monster-rs on crates.io
      # 8. commit modified Cargo.toml and Cargo.lock on release branch
      # 9. merge release branch back into main
      # 10. notify developers in Slack
      - name: Semantic Release
        uses: cycjimmy/semantic-release-action@v2
        with:
          semantic_version: 17.4.1
          extra_plugins: |
            @semantic-release/exec@5.0
            @semantic-release/git@9.0
            @saithodev/semantic-release-backmerge@1.2
            semantic-release-slack-bot@2.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
          SLACK_WEBHOOK: ${{ secrets.SEMANTIC_RELEASE_SLACK_WEBHOOK }}

  publish-book:
    name: Publish Book
    # secrets of this environment are needed
    environment: github-pages
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          # use credentials, that are allowed to commit to gh-pages branch
          ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}

      - name: Install Graphviz
        run: |
          sudo apt-get update
          sudo apt-get install -y graphviz

      - name: Install mdbook and Dependencies
        run: |
          cargo install mdbook --locked || true
          cargo install mdbook-linkcheck --locked || true
          cargo install --git https://github.com/dylanowen/mdbook-graphviz || true

      - name: Generate Book as Html
        run: mdbook build book

      - name: Deploy on Github Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          publish_dir: ./book/book/html
          user_name: "Github Action"
          user_email: "action@github.com"