Merge pull request 'fix: 修正CD错误' (#27) from feature/route into develop
Reviewed-on: #27
This commit was merged in pull request #27.
This commit is contained in:
@@ -15,8 +15,6 @@ jobs:
|
|||||||
- name: Auto-tag from merged PR
|
- name: Auto-tag from merged PR
|
||||||
id: autotag
|
id: autotag
|
||||||
run: |
|
run: |
|
||||||
set -e
|
|
||||||
|
|
||||||
# 已有标签 → 跳过
|
# 已有标签 → 跳过
|
||||||
EXISTING=$(git tag --points-at HEAD | grep '^v' | head -n1)
|
EXISTING=$(git tag --points-at HEAD | grep '^v' | head -n1)
|
||||||
if [ -n "$EXISTING" ]; then
|
if [ -n "$EXISTING" ]; then
|
||||||
@@ -25,7 +23,7 @@ jobs:
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 非 merge commit → 跳过(直接 push 不处理)
|
# 非 merge commit → 跳过
|
||||||
PARENTS=$(git log --format="%P" -1 | wc -w)
|
PARENTS=$(git log --format="%P" -1 | wc -w)
|
||||||
if [ "$PARENTS" -lt 2 ]; then
|
if [ "$PARENTS" -lt 2 ]; then
|
||||||
echo "Not a merge commit, skip auto-tag"
|
echo "Not a merge commit, skip auto-tag"
|
||||||
@@ -34,7 +32,7 @@ jobs:
|
|||||||
|
|
||||||
# 从 merge commit message 提取 PR 号
|
# 从 merge commit message 提取 PR 号
|
||||||
COMMIT_MSG=$(git log --format="%B" -1)
|
COMMIT_MSG=$(git log --format="%B" -1)
|
||||||
PR_NUM=$(echo "$COMMIT_MSG" | grep -oP '#\K\d+' | head -1)
|
PR_NUM=$(echo "$COMMIT_MSG" | grep -oP '#\K\d+' | head -1) || true
|
||||||
if [ -z "$PR_NUM" ]; then
|
if [ -z "$PR_NUM" ]; then
|
||||||
echo "No PR number found in merge message"
|
echo "No PR number found in merge message"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -55,16 +53,22 @@ jobs:
|
|||||||
VERSION="$PR_BODY"
|
VERSION="$PR_BODY"
|
||||||
echo "Found version: $VERSION"
|
echo "Found version: $VERSION"
|
||||||
|
|
||||||
# 创建本地标签
|
# 检查远端是否已有此标签
|
||||||
|
if git ls-remote --tags origin "$VERSION" 2>/dev/null | grep -q .; then
|
||||||
|
echo "Tag $VERSION already exists on remote, skipping push"
|
||||||
|
git tag "$VERSION" 2>/dev/null || true
|
||||||
|
echo "tag=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 创建并推送标签
|
||||||
git config user.email "ci@datarouter"
|
git config user.email "ci@datarouter"
|
||||||
git config user.name "DataRouter CI"
|
git config user.name "DataRouter CI"
|
||||||
git tag -a "$VERSION" -m "Release $VERSION"
|
git tag -a "$VERSION" -m "Release $VERSION"
|
||||||
echo "Created local tag: $VERSION"
|
echo "Created local tag: $VERSION"
|
||||||
|
|
||||||
# 推送到远端(不会触发本 workflow — 仅匹配 branches: [main])
|
# 使用 origin remote(actions/checkout 已配置好认证)
|
||||||
ORIGIN=$(git config --get remote.origin.url)
|
git push origin "$VERSION" 2>&1
|
||||||
PUSH_URL="https://oauth2:${TOKEN}@${ORIGIN#https://}"
|
|
||||||
git push "$PUSH_URL" "$VERSION"
|
|
||||||
echo "Pushed tag: $VERSION"
|
echo "Pushed tag: $VERSION"
|
||||||
echo "tag=$VERSION" >> "$GITHUB_OUTPUT"
|
echo "tag=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user