name: CI
on:
schedule:
- cron: '0 0 * * 0'
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+**'
pull_request:
jobs:
rustfmt:
name: Rustfmt
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: 'Set up `stable`'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
profile: minimal
components: rustfmt
- name: cargo-fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
build:
strategy:
fail-fast: false
matrix:
channel:
- stable
target:
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- x86_64-unknown-linux-gnu
include:
- { channel: stable, target: x86_64-pc-windows-msvc , os: windows-2019 }
- { channel: stable, target: x86_64-apple-darwin , os: macos-10.15 }
- { channel: stable, target: x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
name: Build (${{ matrix.channel }}-${{ matrix.target }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: 'Set up `${{ matrix.channel }}`'
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.channel }}
target: ${{ matrix.target }}
override: true
profile: minimal
components: clippy
- name: cargo-clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --target ${{ matrix.target }} -- -D warnings
- name: cargo-test
uses: actions-rs/cargo@v1
with:
command: test
args: --target ${{ matrix.target }} --no-fail-fast
env:
RUST_BACKTRACE: full
gh-release:
name: GH Release
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Prepare release notes
run: |
from pathlib import Path
output = ''
if Path('./CHANGELOG.md').exists():
with open('./CHANGELOG.md') as file:
changelog = file.read()
inside_subsection = False
for line in changelog.splitlines():
is_h2 = line.startswith('## ')
if not inside_subsection and is_h2:
inside_subsection = True
elif inside_subsection and not is_h2:
output += line + '\n'
elif inside_subsection:
break
with open('./release-notes.md', 'w') as file:
file.write(output)
shell: python
- name: GH Release
uses: softprops/action-gh-release@v1
with:
body_path: ./release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}