name: Release
on:
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: Release to crates.io
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Run tests before release
run: cargo test --all-features --verbose
- name: Install cargo-release
uses: taiki-e/install-action@v2
with:
tool: cargo-release
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Perform release
run: |
cargo release ${{ github.event.inputs.release_type }} --execute --no-confirm --no-publish
- name: Push changes
run: |
git push --follow-tags
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}