Skip to content

Commit b5fe676

Browse files
authored
Merge pull request #87 from tinygrox/action_workflow
chore: 新增 Dev 分支手动打包工作流
2 parents 4f48cb5 + 512cc7b commit b5fe676

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/dev.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Create release (Dev)
2+
3+
on:
4+
workflow_dispatch: # 开启手动按钮
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
pack_dev:
11+
# 关键保护:如果当前运行的分支不是 dev,直接跳过,防止误操作
12+
if: github.ref == 'refs/heads/dev'
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
# 1. 生成临时版本号 (Dev 分支通常没有正式的 Changelog 版本,所以用时间戳)
20+
- name: Generate Dev Version
21+
id: dev_ver
22+
run: |
23+
# 生成格式如: dev-20231215-0830
24+
VER="dev-$(date +'%Y%m%d-%H%M')"
25+
echo "VERSION=$VER" >> $GITHUB_OUTPUT
26+
echo "正在构建 Dev 版本: $VER"
27+
28+
# 2. 打包
29+
- name: Create ZIP
30+
run: zip -r KSP_Chinese_Patches_${{ steps.dev_ver.outputs.VERSION }}.zip GameData
31+
32+
# 3. 上传 Artifact (构建产物,保留90天)
33+
- name: Upload Artifact
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: Dev_Build_${{ steps.dev_ver.outputs.VERSION }}
37+
path: KSP_Chinese_Patches_${{ steps.dev_ver.outputs.VERSION }}.zip
38+
39+
# 4. (可选) 创建一个 Pre-release 发布
40+
# 如果你只想在 Actions 页面下载 zip,可以删掉这一步
41+
- name: Create Pre-release
42+
uses: softprops/action-gh-release@v2
43+
with:
44+
tag_name: ${{ steps.dev_ver.outputs.VERSION }}
45+
name: Dev Build ${{ steps.dev_ver.outputs.VERSION }}
46+
body: |
47+
这是 Dev 分支的手动构建版本。
48+
触发者: @${{ github.actor }}
49+
构建时间: ${{ steps.dev_ver.outputs.VERSION }}
50+
files: KSP_Chinese_Patches_${{ steps.dev_ver.outputs.VERSION }}.zip
51+
prerelease: true # 标记为预发布
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)