68 lines
2.2 KiB
YAML
68 lines
2.2 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
|
|
permissions:
|
|
contents: write
|
|
releases: write
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
name: Release
|
|
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
# Local config wins, in this order. Download the shared file only when none exist.
|
|
- name: Resolve cliff.toml
|
|
id: cliff-config
|
|
env:
|
|
CLIFF_REPO: ${{ vars.CLIFF_CONFIG_REPO || 'gitea/global-workflow' }}
|
|
CLIFF_CONFIGS: cliff.toml .github/cliff.toml .gitea/cliff.toml
|
|
run: |
|
|
set -euo pipefail
|
|
for candidate in $CLIFF_CONFIGS; do
|
|
if [[ -f "$candidate" ]]; then
|
|
echo "Using ${candidate} from this repository"
|
|
echo "config=${candidate}" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
done
|
|
url="${GITHUB_API_URL}/repos/${CLIFF_REPO}/raw/cliff.toml?ref=main"
|
|
echo "No local cliff.toml; fetching ${url}"
|
|
curl --silent --show-error --fail --location --output cliff.toml "$url"
|
|
echo "config=cliff.toml" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Read envs from the runner
|
|
uses: https://git.sothink.vn/gitea/global-workflow/.gitea/actions/load-env@main
|
|
with:
|
|
names: GITHUB_TOKEN RELEASE_TOKEN
|
|
|
|
# Gitea's GITHUB_TOKEN is rejected by api.github.com. Pass a github.com PAT instead.
|
|
- name: Generate release notes
|
|
uses: orhun/git-cliff-action@v4
|
|
with:
|
|
config: ${{ steps.cliff-config.outputs.config }}
|
|
args: --latest --strip header
|
|
github_token: ${{ env.GITHUB_TOKEN }}
|
|
env:
|
|
OUTPUT: release-notes.md
|
|
|
|
- name: Create release
|
|
uses: softprops/action-gh-release@v3
|
|
with:
|
|
# prerelease only when the tag contains "-alpha", "-beta" or "-rc". ex: v1.0.0-alpha.1, v1.0.0-beta.1, v1.0.0-rc.1
|
|
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }}
|
|
body_path: release-notes.md
|
|
token: ${{ env.RELEASE_TOKEN }} # Use this token if you want user author is 'github-actions' bot
|
|
draft: false |