ffi_utils 0.17.0

FFI utilities
Documentation
# Push to master workflow.
#
# Runs when a PR has been merged to the master branch.
#
# 1. Generates a release build.
# 2. If the last commit is a version change, publish.

name: Master

on:
  push:
    branches:
      - master

env:
  # Run all cargo commands with --verbose.
  CARGO_TERM_VERBOSE: true
  RUST_BACKTRACE: 1

jobs:
  build:
    name: Build
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
    steps:
      - uses: actions/checkout@v2
      # Install Rust
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true

      # Generate Cargo.lock, needed for the cache.
      - name: Generate Cargo.lock
        run: cargo generate-lockfile

      # Cache.
      - name: Cargo cache registry, index and build
        uses: actions/cache@v2
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-cache-${{ hashFiles('**/Cargo.lock') }}

      # Make sure the code builds.
      - name: Cargo Build
        run: cargo build --release

  publish:
    name: Publish
    runs-on: ubuntu-latest
    needs: build
    # Is this a version change commit?
    if: startsWith(github.event.head_commit.message, 'Version change')
    steps:
      - uses: actions/checkout@v2
      # checkout with fetch-depth: '0' to be sure to retrieve all commits to look for the semver commit message
        with:
          fetch-depth: '0'
      # Install Rust
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true

      # Set the tag.
      - shell: bash
        id: versioning
        run: |
          version=$(grep "^version" < Cargo.toml | head -n 1 | awk '{ print $3 }' | sed 's/\"//g')
          echo "Current version: $version"
          echo "::set-output name=version::$version"
      - name: Push version tag
        uses: anothrNick/github-tag-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CUSTOM_TAG: ${{ steps.versioning.outputs.version }}

      # Publish to crates.io.
      - name: Cargo package
        run: cargo package
      - name: Cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
        run: cargo publish --token $CARGO_REGISTRY_TOKEN