## 概要
1. [[rust-toolchain Action]]で[[Rust]]環境を準備
2. [[Rust Cache Action]]でキャッシュを利用
3. [[Rust cargo Action]]でビルド
4. [[Upload files to a GitHub release]]でリリース/成果物配置
## YAMLファイル
```yaml
name: Release
on:
push:
tags:
- '*'
jobs:
build:
name: Release binary
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: hibou
asset_name: hibou-x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: hibou
asset_name: hibou-x86_64-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: hibou.exe
asset_name: hibou-x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: hibou
asset_name: hibou-x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
# targetを設定してもsqlite3などOS依存のものはビルドに失敗する
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- name: Build
uses: actions-rs/cargo@v1
with:
# use-crossを外すとmuslのようなディストリビューション違いがビルドできない
use-cross: true
command: build
args: --release --target ${{ matrix.target }} --all-features --verbose
- name: Upload binaries to release
uses: svenstaro/
[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}
overwrite: true
```