name: CI
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- v*.*.*
jobs:
test:
name: Test
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Clippy
run: cargo clippy -- -D warnings
- name: Format
run: cargo fmt --check
- name: Test
run: cargo test
release:
name: Release
if: startsWith(github.ref, 'refs/tags/v')
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get version
run: echo VERSION=$(./version.sh) >> $GITHUB_ENV
- name: Check version
run: |
if [ $VERSION != ${GITHUB_REF_NAME#v} ]; then
echo "$VERSION != ${GITHUB_REF_NAME#v}"
exit 1
fi
- name: Get release note
run: |
echo "RELEASE_NOTE<<EOF" >> $GITHUB_ENV
./release-note.sh $VERSION >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Release
uses: ncipollo/release-action@v1
with:
name: ${{ github.ref_name }}
body: ${{ env.RELEASE_NOTE }}
allowUpdates: true
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate: true
omitDraftDuringUpdate: false
- name: Publish
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}