Files
gdt-tool/.github/workflows/publish.yml
T
zhanggy 18fc065a17 feat: add automated release workflow and configuration
- Introduced a new release configuration file to define commit types and sections for changelog generation.
- Created a publish workflow to automate the release process on main branch pushes, including version bumping, changelog generation, and GitHub release creation.
- Added a separate release workflow to build artifacts for multiple platforms and upload them as release assets.
- Documented the automated release process, including commit message conventions and local release commands in AUTOMATED_RELEASE.md.
2025-10-29 10:24:39 +08:00

87 lines
2.4 KiB
YAML

name: Publish Release
on:
push:
branches:
- main
# 在同一个工作流中处理发布任务
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Setup Git user
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Bump version and generate changelog
run: |
# 根据 commit 信息自动更新版本和生成 changelog
pnpm release
# 获取新版本号
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Push changes
run: |
git push origin main
git push origin v${{ env.VERSION }}
- name: Build for all platforms
run: pnpm build:all
env:
# 在 macOS 上禁用代码签名
CSC_IDENTITY_AUTO_DISCOVERY: false
# GitHub token 用于发布
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: Release v${{ env.VERSION }}
body_path: CHANGELOG.md
draft: false
prerelease: false
files: |
release/${{ env.VERSION }}/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}