Skip to content

Instantly share code, notes, and snippets.

@ozbe
Last active May 16, 2020 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozbe/e66c97a90ef1bb40a7186bda4837c7fc to your computer and use it in GitHub Desktop.
Save ozbe/e66c97a90ef1bb40a7186bda4837c7fc to your computer and use it in GitHub Desktop.
Rust GitHub Actions
# Source: https://daniellockyer.com/automated-rust-releases/
name: Publish
on:
push:
tags:
- '*'
jobs:
publish:
name: Publish for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
name: [
linux,
windows,
macos
]
include:
- name: linux
os: ubuntu-latest
artifact_name: hq
asset_name: hq-linux
- name: windows
os: windows-latest
artifact_name: hq.exe
asset_name: hq-windows
- name: macos
os: macos-latest
artifact_name: hq
asset_name: hq-macos
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Build
run: cargo build --release --locked
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}
Rust Github Actions
# Source: https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
name: Verify
on:
push:
branches:
- '**'
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment