name: 'Release'
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
pre-release:
name: Pre-release checks
runs-on: ubuntu-18.04
steps:
- name: Detect version
id: version
run: |
if [[ "$GITHUB_REF" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "VERSION=${BASH_REMATCH[1]}" >> "$GITHUB_ENV"
echo "::set-output name=version::${BASH_REMATCH[1]}"
else
exit 1
fi
- name: Shallow checkout
uses: actions/checkout@v3
- name: Check version bump
run: scripts/gh-run-version-checks
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
profile: minimal
components: rustfmt, clippy
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --locked
- name: Check rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Check clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --locked --all-targets --all-features -- --no-deps
- name: Create release
uses: softprops/action-gh-release@v1
outputs:
version: ${{ steps.version.outputs.version }}
release:
name: Release ${{ matrix.job.name }}
needs:
- pre-release
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: true
matrix:
job:
- name: linux-x86_64
os: ubuntu-20.04
target: x86_64-unknown-linux-musl
use-cross: false
- name: macos-x86_64
os: macos-11
target: x86_64-apple-darwin
use-cross: false
- name: macos-aarch64
os: macos-11
target: aarch64-apple-darwin
use-cross: false
steps:
- name: Install macOS tools
if: startsWith(matrix.job.os, 'macos')
run: brew install coreutils gnu-sed pandoc
- name: Install Ubuntu tools
if: startsWith(matrix.job.os, 'ubuntu')
run: sudo apt-get install -y pandoc
- name: Shallow checkout
uses: actions/checkout@v3
- name: Extract project info
run: scripts/gh-project-info | tee -a "$GITHUB_ENV"
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.job.target }}
override: true
profile: minimal
- name: Build binary
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: build
args: --locked --release --target ${{ matrix.job.target }}
- name: Build manual page
run: scripts/build-manual-page
- name: Build tarball
id: build-tarball
run: scripts/gh-make-tarball
env:
BUILD_NAME: ${{ matrix.job.name }}
TARGET_ARCH: ${{ matrix.job.target }}
GITHUB_OUTPUTS: true
- name: Add artifacts to release
uses: softprops/action-gh-release@v1
with:
files: |
${{ steps.build-tarball.outputs.tarball-path }}
cargo-publish:
name: Publish to crates.io
needs:
- release
runs-on: ubuntu-18.04
steps:
- name: Shallow checkout
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
profile: minimal
- name: Publish
uses: actions-rs/cargo@v1
with:
command: publish
args: --locked
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}