-
Notifications
You must be signed in to change notification settings - Fork 140
55 lines (47 loc) · 1.79 KB
/
Copy pathrelease-trigger.yml
File metadata and controls
55 lines (47 loc) · 1.79 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
name: Release Trigger
permissions:
contents: read
on:
pull_request:
types: [closed]
jobs:
trigger_release:
if: ${{ github.event.pull_request.merged == true }}
permissions:
actions: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Extract version from PR title
id: extract
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
echo "PR Title: $PR_TITLE"
# 尝试匹配 "release-stable: VERSION" 或 "beta-release: VERSION" 格式,支持 SemVer(可选 v 前缀)
if [[ "$PR_TITLE" =~ (release-stable|beta-release):\ ?[vV]?([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?) ]]; then
VERSION="${BASH_REMATCH[2]}"
RELEASE_TYPE="${BASH_REMATCH[1]}"
if [[ "$RELEASE_TYPE" == "beta-release" ]]; then
IS_BETA="true"
else
IS_BETA="false"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "is_beta=$IS_BETA" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION, is_beta: $IS_BETA"
else
echo "Error: PR title does not match expected format 'release-stable: VERSION' or 'beta-release: VERSION' (SemVer)"
exit 1
fi
- name: Trigger Release Workflow
run: |
CONFIGURATION="Release"
if [[ "${{ steps.extract.outputs.is_beta }}" == "true" ]]; then
CONFIGURATION="Beta"
fi
gh workflow run release-publish.yml \
-f version=${{ steps.extract.outputs.version }} \
-f configuration="${CONFIGURATION}" \
-f prerelease=${{ steps.extract.outputs.is_beta }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}