Skip to content

Rust

Rust #363

Workflow file for this run

name: Rust
on:
schedule:
- cron: '0 0 * * 0'
push:
branches:
- '*'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+**'
pull_request:
jobs:
rustfmt:
name: Rustfmt
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup `stable-x86_64-unknown-linux-gnu`
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-unknown-linux-gnu
default: true
profile: minimal
components: rustfmt
- name: Rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
build:
strategy:
fail-fast: false
matrix:
toolchain:
- stable-x86_64-pc-windows-msvc
- stable-x86_64-apple-darwin
- stable-x86_64-unknown-linux-gnu
include:
- { toolchain: stable-x86_64-pc-windows-msvc , additional-target: '' , os: windows-2019 }
- { toolchain: stable-x86_64-apple-darwin , additional-target: '' , os: macos-10.15 }
- { toolchain: stable-x86_64-unknown-linux-gnu, additional-target: x86_64-unknown-linux-musl, os: ubuntu-18.04 }
name: ${{ matrix.toolchain }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup `${{ matrix.toolchain }}`
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.additional-target }}
default: true
profile: minimal
components: clippy
- name: Install `cross`
uses: actions-rs/cargo@v1
with:
command: install
args: cross --debug
if: matrix.os == 'ubuntu-18.04'
- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast --verbose
upload:
strategy:
fail-fast: false
matrix:
toolchain:
- stable-x86_64-pc-windows-msvc
- stable-x86_64-apple-darwin
- stable-x86_64-unknown-linux-gnu
include:
- { toolchain: stable-x86_64-pc-windows-msvc , target-triple: x86_64-pc-windows-msvc , os: windows-2019 }
- { toolchain: stable-x86_64-apple-darwin , target-triple: x86_64-apple-darwin , os: macos-10.15 }
- { toolchain: stable-x86_64-unknown-linux-gnu, target-triple: x86_64-unknown-linux-gnu, os: ubuntu-18.04 }
name: Upload (${{ matrix.target-triple }})
runs-on: ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: 'Setup `${{ matrix.toolchain }}`'
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
default: true
profile: minimal
- name: '`cargo install --path . -v --locked`'
uses: actions-rs/cargo@v1
with:
command: install
args: --path . -v --locked
- name: Create an asset
id: asset
run: |
if ${{ contains(matrix.target-triple, 'pc-windows') }}; then
DOT_EXE=.exe
fi
BIN_TARGET=cargo-atcoder
ASSET_STEM="$BIN_TARGET-${GITHUB_REF#refs/tags/}-${{ matrix.target-triple }}"
git archive -o "./$ASSET_STEM.tar" --prefix "$ASSET_STEM/" HEAD
tar -xf "./$ASSET_STEM.tar"
mv "$HOME/.cargo/bin/$BIN_TARGET$DOT_EXE" "./$ASSET_STEM/"
if ${{ contains(matrix.target-triple, 'pc-windows') }}; then
ASSET="$ASSET_STEM.zip"
7z a "$ASSET" "./$ASSET_STEM"
zipinfo "./$ASSET"
else
ASSET="$ASSET_STEM.tar.gz"
tar -czvf "./$ASSET" "./$ASSET_STEM"
fi
echo "::set-output name=asset::$ASSET"
shell: bash
- name: Upload the asset
uses: actions/upload-artifact@v2
with:
name: assets
path: ${{ steps.asset.outputs.asset }}
release:
name: GitHub Release
runs-on: ubuntu-18.04
needs: [rustfmt, build, upload]
steps:
- name: Download the assets
uses: actions/download-artifact@v2
with:
name: assets
path: ./assets
- name: GH Release
uses: softprops/action-gh-release@v1
with:
files: ./assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}