name: Release
on:
push:
branches:
- "main"
- "master"
tags:
- '*'
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Check that the tag is the same as the version in Cargo.toml
if: startsWith(github.ref, 'refs/tags/')
run: |
if ! grep -q "version = \"${{ github.ref_name }}\"" Cargo.toml; then
echo "Cargo.toml does not contain the current tag as the version."
exit 1
fi
- name: Install fmt
run: rustup component add rustfmt
- name: Check formatting
run: cargo fmt -- --check
- name: Install Clippy
run: rustup component add clippy
- name: Run clippy
run: cargo clippy
- name: Build
run: cargo check --verbose
- name: Run tests
run: cargo test --verbose
- name: Build no_std
run: cargo check --verbose --no-default-features
- name: Build alloc
run: cargo check --verbose --no-default-features --features="alloc"
- name: Check semver uses: obi1kenobi/cargo-semver-checks-action@v2
with:
rust-toolchain: stable
feature-group: default-features
- name: Clean up the repository
run: rm -rfd semver-checks - name: Check that the CHANGELOG.md has been updated
if: startsWith(github.ref, 'refs/tags/')
run: |
if ! grep -q "## \[${{ github.ref_name }}\]" CHANGELOG.md; then
echo "CHANGELOG.md does not contain a section for the current tag."
exit 1
fi
- name: Create Release Notes
if: startsWith(github.ref, 'refs/tags/')
run: sed -n '/^##\s\[/,/^##\s\[/p' CHANGELOG.md | sed '$d' > /tmp/release-notes.md
- name: Check that the release notes are reasonable
if: startsWith(github.ref, 'refs/tags/')
run: |
if ! grep -q "## \[${{ github.ref_name }}\]" /tmp/release-notes.md; then
echo "/tmp/release-notes.md does not contain a section for the current tag."
exit 1
fi
- name: Creating Release on Github
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
prerelease: false
draft: false
body_path: /tmp/release-notes.md