Files
fscan/.github/workflows/release.yml
T
ZacharyZcR 08a87b3128
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
ci: 完善发版流程
- release workflow 自动读取 .github/release-notes/<tag>.md 覆盖 body
- 移除手动 prerelease input(goreleaser auto 模式根据 tag 后缀判断)
- 新增 RELEASE.md 发版流程文档
2026-06-01 08:42:17 +08:00

73 lines
1.9 KiB
YAML

name: 发布
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
snapshot:
description: '仅测试构建(不发布)'
type: boolean
default: false
draft:
description: '创建草稿发布'
type: boolean
default: false
permissions:
contents: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- name: 检出代码
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 准备 Release Notes
if: ${{ !inputs.snapshot }}
run: |
TAG="${GITHUB_REF_NAME}"
NOTES_FILE=".github/release-notes/${TAG}.md"
if [ -f "$NOTES_FILE" ]; then
echo "📝 找到版本 Release Notes: $NOTES_FILE"
cp "$NOTES_FILE" /tmp/release-notes.md
else
echo "⚠️ 未找到 $NOTES_FILE,使用自动生成的 changelog"
echo "" > /tmp/release-notes.md
fi
echo "RELEASE_NOTES_FILE=/tmp/release-notes.md" >> $GITHUB_ENV
- name: 构建和发布
uses: ./.github/actions/build-release
with:
mode: ${{ inputs.snapshot && 'snapshot' || 'release' }}
go-version: '1.20'
retention-days: '90'
release-args: ${{ inputs.draft && '--draft' || '' }}
- name: 更新 Release Notes
if: ${{ !inputs.snapshot && env.RELEASE_NOTES_FILE != '' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${GITHUB_REF_NAME}"
NOTES_FILE="${RELEASE_NOTES_FILE}"
if [ -s "$NOTES_FILE" ]; then
echo "📝 更新 Release Notes..."
# 用版本特定的 notes 替换 goreleaser 生成的 body
gh release edit "$TAG" --notes-file "$NOTES_FILE"
echo "✅ Release Notes 已更新"
fi