From 31d58754255f7df81261a56bfb9720552f44cc24 Mon Sep 17 00:00:00 2001 From: Jasery Date: Wed, 19 Nov 2025 09:49:21 +0800 Subject: [PATCH] ci(release): Add Gitea Actions workflow and release configuration - Add `.gitea/release-config.json` to define conventional commit types and changelog sections - Add `.gitea/workflows/publish.yml` to automate version bumping, changelog generation, and Windows builds - Update `AUTOMATED_RELEASE.md` to reflect migration from GitHub Actions to Gitea Actions - Update documentation to specify Windows-only builds and Gitea Release creation - Add Gitea Token configuration instructions for repository setup - Configure workflow to run on main branch pushes with concurrency controls - Set up automated asset uploads for Windows executables and update files --- .gitea/release-config.json | 44 ++++++++++++++++++++ .gitea/workflows/publish.yml | 80 ++++++++++++++++++++++++++++++++++++ AUTOMATED_RELEASE.md | 20 +++++---- 3 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 .gitea/release-config.json create mode 100644 .gitea/workflows/publish.yml diff --git a/.gitea/release-config.json b/.gitea/release-config.json new file mode 100644 index 0000000..062e367 --- /dev/null +++ b/.gitea/release-config.json @@ -0,0 +1,44 @@ +{ + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactoring" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "test", + "section": "Tests" + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "CI" + }, + { + "type": "chore", + "section": "Chores" + } + ] +} diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..317ef07 --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -0,0 +1,80 @@ +name: Publish Release + +on: + push: + branches: + - main + +# 在同一个工作流中处理发布任务 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + publish: + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Configure Git + run: | + git config --global url."https://".insteadOf git:// + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + run_install: | + - recursive: true + args: [--frozen-lockfile=false] + + - name: Install dependencies + run: pnpm install --no-frozen-lockfile + env: + NPM_CONFIG_LEGACY_PEER_DEPS: true + + - name: Setup Git user + run: | + git config --global user.name 'gitea-actions[bot]' + git config --global user.email 'gitea-actions[bot]@users.noreply.gitea.com' + + - name: Bump version and generate changelog + shell: bash + run: | + # 根据 commit 信息自动更新版本和生成 changelog + pnpm release + + # 获取新版本号 + version=$(node -p "require('./package.json').version") + echo "VERSION=$version" >> $GITHUB_ENV + echo "Version set to: $version" + + - name: Push changes + run: | + git push origin main + git tag "v${{ env.VERSION }}" + git push origin "v${{ env.VERSION }}" + + - name: Build for Windows + run: | + pnpm build:win + env: + # 禁用 Windows 代码签名 + WIN_CSC_KEY_PASSWORD: '' + + - name: Upload Release Assets + uses: https://gitea.com/actions/release-action@main + with: + files: | + release/**/*.exe + release/**/*.exe.blockmap + release/**/latest.yml + release/**/app-update.yml diff --git a/AUTOMATED_RELEASE.md b/AUTOMATED_RELEASE.md index c2f5468..b95dac0 100644 --- a/AUTOMATED_RELEASE.md +++ b/AUTOMATED_RELEASE.md @@ -4,15 +4,15 @@ ## 工作流程 -当代码合并到 main 分支后,GitHub Actions 会自动执行以下步骤: +当代码合并到 main 分支后,Gitea Actions 会自动执行以下步骤: 1. 检出代码 2. 设置 Node.js 和 pnpm 环境 3. 安装依赖 4. 根据 Git 提交信息自动更新版本号 5. 生成变更日志 (CHANGELOG.md) -6. 构建应用程序 (所有平台) -7. 创建 GitHub Release +6. 构建应用程序 (Windows 平台) +7. 创建 Gitea Release 8. 上传构建产物 ## 提交信息规范 @@ -53,10 +53,16 @@ pnpm release:patch # 补丁更新 (1.1.1 -> 1.1.2) ## 配置文件 - `.versionrc.json` 或 `package.json` 中的 `standard-version` 配置定义了版本管理和变更日志生成规则 -- `.github/workflows/publish.yml` 包含了自动化发布的工作流程定义 +- `.gitea/workflows/publish.yml` 包含了自动化发布的工作流程定义 ## 重要说明 -1. 为了使自动化发布正常工作,必须正确配置 GitHub 仓库的 secrets,特别是用于发布构建产物的令牌。 -2. 构建过程会生成适用于多个平台(Windows、macOS、Linux)的应用程序包。 -3. 变更日志会自动包含在 GitHub Release 中。 +1. 为了使自动化发布正常工作,必须在 Gitea 仓库设置中配置 `GITEA_TOKEN` secret,用于推送代码和创建 Release。 +2. 构建过程会生成适用于 Windows 平台的应用程序包。 +3. 变更日志会自动包含在 Gitea Release 中。 + +## Gitea Token 配置 + +在 Gitea 仓库的 Settings -> Secrets 中添加以下 secret: + +- `GITEA_TOKEN`: 具有仓库写入权限的访问令牌,可在 Gitea 用户设置 -> 应用 -> 管理访问令牌中创建