-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.23 KB
/
publish-release.yml
File metadata and controls
74 lines (63 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Reusable Publish Release Workflow
on:
workflow_call:
inputs:
tag_name:
description: 'Tag name for the release'
required: true
type: string
repository_name:
description: 'Repository name'
required: true
type: string
# 统一配置权限,调用方无需声明
permissions:
contents: write
actions: read
checks: write
packages: write
jobs:
publish-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0 # 获取所有提交历史,用于生成完整的changelog
persist-credentials: false # 使用 token 进行操作
- name: Set up Git user
run: |
git config --global user.email "${{ vars.GIT_USER_EMAIL }}"
git config --global user.name "${{ vars.GIT_USER_NAME }}"
# 解决 git fetch 报错
- name: Force fetch tags
run: git fetch --tags --force
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "lts/*"
- name: Install Dependencies
run: |
# 备份 package.json
cp package.json package.json.bak
# 临时移除 dependencies 以避免 npm 尝试安装不存在的 Unity 依赖
node -e "let pkg=require('./package.json'); delete pkg.dependencies; require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2))"
# 安装开发依赖
npm install
# 恢复原始 package.json (确保发布时包含 dependencies)
mv package.json.bak package.json
# 新增步骤:下载远程配置
- name: Download shared configuration
run: |
curl -L https://raw.githubusercontent.com/GameFrameX/public-github-actions/main/.releaserc -o .releaserc
# 修复包配置
- name: fix package
run: npm pkg fix
- name: Run semantic-release
run: npx semantic-release
env:
# cnb.cool 发布令牌
NPM_TOKEN: ${{ secrets.CNB_NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.CNB_NPM_TOKEN }}
# GitHub令牌(自动生成,用于创建Tag/Release)
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}