You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/auto-release.yml
+85-52Lines changed: 85 additions & 52 deletions
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,8 @@ on:
3
3
workflow_call:
4
4
inputs:
5
5
version:
6
-
description: 'Release version (e.g., 1.0.0)'
7
-
required: true
6
+
description: 'Release version (e.g., 1.0.0), keep empty to auto-increment from VERSION file'
7
+
required: false
8
8
type: string
9
9
name:
10
10
description: 'The name of the person to release the version'
@@ -16,7 +16,7 @@ on:
16
16
type: string
17
17
timezone:
18
18
description: 'The timezone in the debian changelog file'
19
-
required: false
19
+
required: true
20
20
type: string
21
21
default: 'Asia/Shanghai'
22
22
@@ -25,17 +25,6 @@ jobs:
25
25
create_changelog:
26
26
runs-on: ubuntu-latest
27
27
steps:
28
-
- name: 验证语义化版本号
29
-
id: validate_version
30
-
run: |
31
-
version="${{ github.event.inputs.version }}"
32
-
if [[ ! "$version" =~ ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
33
-
echo "无效的版本号格式,请使用语义化版本号: $version" >&2
34
-
exit 1
35
-
fi
36
-
version=${version#v}
37
-
echo "version=${version}" >> $GITHUB_OUTPUT
38
-
39
28
- name: 使用 GitHub App 进行身份验证
40
29
id: auth
41
30
uses: actions/create-github-app-token@v1
@@ -44,7 +33,56 @@ jobs:
44
33
private-key: ${{ secrets.APP_PRIVATE_KEY }}
45
34
owner: ${{ github.repository_owner }}
46
35
47
-
- name: 获取触发者的昵称
36
+
- name: 检出代码
37
+
uses: actions/checkout@v4
38
+
with:
39
+
fetch-depth: 0
40
+
token: ${{ steps.auth.outputs.token }}
41
+
42
+
- name: 验证语义化版本号
43
+
id: validate_version
44
+
run: |
45
+
version="${{ github.event.inputs.version }}"
46
+
47
+
# 如果没有提供版本号,尝试从 VERSION 文件读取并自动递增
48
+
if [ -z "$version" ]; then
49
+
if [ -f "VERSION" ]; then
50
+
current_version=$(cat VERSION | tr -d '\n\r')
51
+
echo "从 VERSION 文件读取到版本号: $current_version"
52
+
53
+
# 验证现有版本号格式
54
+
if [[ ! "$current_version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
if [[ ! "$version" =~ ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
0 commit comments