Skip to content

Commit 87a08e1

Browse files
author
dompl
committed
update
1 parent d180252 commit 87a08e1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

.github/workflows/build-release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,43 @@ jobs:
177177
name: TrollScript-${{ steps.version.outputs.release_tag }}
178178
path: release/*.tipa
179179
retention-days: 30
180+
181+
# 7.5 将构建产物提交到 release 分支(覆盖模式)
182+
- name: Commit Build Artifacts to release Branch
183+
env:
184+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
185+
REPO: ${{ github.repository }}
186+
RELEASE_TAG: ${{ steps.version.outputs.release_tag }}
187+
run: |
188+
set -e
189+
git config user.name "github-actions[bot]"
190+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
191+
192+
# 使用 token 更新 origin URL 以便推送
193+
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git"
194+
git fetch origin --prune
195+
196+
# 若远程已有 release 分支则基于远程分支检出并替换为本地 HEAD,否则创建孤儿分支
197+
if git ls-remote --heads origin release | grep -q refs/heads/release; then
198+
git checkout -B release origin/release
199+
else
200+
git checkout --orphan release
201+
git rm -rf . || true
202+
git clean -fdx || true
203+
fi
204+
205+
# 确认有要提交的 release 目录
206+
if [ ! -d release ]; then
207+
echo "❌ release 目录不存在,无法提交" >&2
208+
exit 1
209+
fi
210+
211+
# 强制添加并提交 release 目录(覆盖模式)
212+
git add -f release
213+
git commit -m "chore(release): add build artifacts ${RELEASE_TAG}" || echo "No changes to commit"
214+
215+
# 强制推送覆盖远程 release 分支
216+
git push -f origin release
180217
181218
# 8. 在本项目创建 Tag 并提交到 Release
182219
- name: Create GitHub Release

0 commit comments

Comments
 (0)