name: Publish
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type (patch, minor, major)'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
pull-requests: write
packages: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-release
run: cargo install cargo-release
- name: Get the version from Cargo.toml
run: |
VERSION=$(grep -Po '^version = "\K[0-9\.]+' Cargo.toml)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Cargo login
run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create Cargo Release
run: |
cargo release ${{ github.event.inputs.version_type }} --no-confirm --execute
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: Release v${{ env.VERSION }}
generate_release_notes: true