Publish #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
versionType: | |
type: choice | |
description: "<major|minor|patch>" | |
required: true | |
default: "patch" | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
publish: | |
name: Publish ${{ inputs.versionType }} release | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- run: rustup toolchain install nightly --profile minimal --component clippy rustfmt && rustup default nightly && cargo install cargo-edit | |
name: Install Rust nightly toolchain | |
- uses: Swatinem/rust-cache@v2 | |
name: Setup Rust cache | |
with: | |
shared-key: ${{ runner.os }}-ci | |
save-if: ${{ github.ref == 'refs/heads/main' }} | |
- id: update-version | |
shell: bash | |
name: Bump version | |
# Use npm because yarn is for some reason not able to output only the version name | |
run: | | |
cargo set-version --workspace --bump ${{ inputs.versionType }} |& > /tmp/bump-version.txt | |
echo "Output from cargo set-version:" | |
cat /tmp/bump-version.txt | |
VERSION=$(cat /tmp/bump-version.txt | awk '/Upgrading/ {print $6; exit}') | |
echo "Extracted version: $VERSION" | |
if [ ! -n "$VERSION" ]; then | |
echo "Failed to extract version" | |
exit 1 | |
fi | |
echo "version=$VERSION" >> $GITHUB_ENV | |
- name: Generate a changelog for the new version | |
uses: orhun/git-cliff-action@v3 | |
id: build-changelog | |
with: | |
config: cliff.toml | |
args: -vv --strip header --unreleased --tag v${{ steps.update-version.outputs.version }} --prepend CHANGELOG.md | |
env: | |
GITHUB_REPO: ${{ github.repository }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Commit changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "chore: bump version to v${{ steps.update-version.outputs.version }}" | |
commit_user_name: "github-actions[bot]" | |
commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com" | |
tagging_message: "v${{ steps.update-version.outputs.version }}" | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
body: ${{steps.build-changelog.outputs.content}} | |
name: Clash Nyanpasu v${{steps.update-version.outputs.version}} | |
tag_name: ${{steps.build-changelog.outputs.version}} | |
# target_commitish: ${{ steps.tag.outputs.sha }} |