Skip to content

Publish

Publish #16

Workflow file for this run

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
- name: Install git-cliff
uses: taiki-e/install-action@git-cliff
- 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 }}
chmod +x .github/scripts/get-version.rs
VERSION=$(.github/scripts/get-version.rs --path ./nyanpasu_service/Cargo.toml | head -n 1)
echo "$VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Generate a changelog for the new version
shell: bash
id: build-changelog
run: |
git-cliff --config cliff.toml --verbose --strip header --unreleased --tag v${{ steps.update-version.outputs.version }} > /tmp/changelog.md
if [ -z $? ]; then
CONTENT=$(cat /tmp/changelog.md)
CONTENT >> ./CHANGELOG.md
echo "content=$CONTENT" >> $GITHUB_OUTPUT
echo "version=${{ steps.update-version.outputs.version }}" >> $GITHUB_OUTPUT
else
echo "Failed to generate changelog"
exit 1
fi
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 }}