File tree 2 files changed +85
-0
lines changed
2 files changed +85
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : meta
2
+
3
+ on :
4
+ workflow_call :
5
+ outputs :
6
+ is_release :
7
+ value : ${{ jobs.set.outputs.is_release }}
8
+ tag :
9
+ value : ${{ jobs.set.outputs.tag }}
10
+ version :
11
+ value : ${{ jobs.set.outputs.version }}
12
+
13
+ jobs :
14
+ set :
15
+ runs-on : ubuntu-latest
16
+ steps :
17
+ - uses : actions/checkout@v4
18
+ with :
19
+ fetch-depth : 0
20
+ - id : set
21
+ run : |
22
+ is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
23
+ commit_hash=$(git rev-parse --short HEAD)
24
+
25
+ if $is_release; then
26
+ tag=$(git describe --tags || true)
27
+ else
28
+ tag=$(git describe --tags --match "v*" --exclude "*-post*" || true)
29
+ fi
30
+ if [[ $tag != v* ]]; then
31
+ if $is_release; then echo "::error::Failed to get tag on releasing" && exit 1; fi
32
+ ver_core=$(curl -sX GET "https://api.github.com/repos/MaaXYZ/MaaFramework/releases/latest" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | awk '/tag_name/{print $4}' FS='["]' || true)
33
+ tag=$(date "+$ver_core-1%m%d-${commit_hash}")
34
+ if [[ $tag != v* ]]; then
35
+ tag=$(date "+v%Y.%-m.%-d-2%H%M-${commit_hash}")
36
+ fi
37
+ fi
38
+
39
+ if $is_release; then
40
+ version=${tag#v}
41
+ else
42
+ ver_core=${tag%-*-*}
43
+ suffixs=(${tag//-/ })
44
+ tag=${ver_core}-post.${suffixs[-2]}-ci.${{ github.run_id }}
45
+ version=${tag#v}+${commit_hash}.$(date +%Y%m%d)
46
+ fi
47
+
48
+ echo "tag=$tag
49
+ version=$version
50
+ is_release=$is_release" | tee -a "$GITHUB_OUTPUT"
51
+ outputs :
52
+ is_release : ${{ steps.set.outputs.is_release }}
53
+ tag : ${{ steps.set.outputs.tag }} # v<release version> | v<ci version>
54
+ version : ${{ steps.set.outputs.version }} # <release version> | <ci version>+<build> e.g ↓
55
+ # 主版本号.次版本号.修订号[-(alpha|beta|rc).预发布号]
56
+ # [-post.发布后号[-ci.${{ github.run_id }}]+${commit_hash}.${dateY%m%d}]
57
+ # 1.7.0
58
+ # 1.7.0-beta.1
59
+ # 1.7.0-post.6-ci.8678478007+gf5e12a1c.20240413
Original file line number Diff line number Diff line change
1
+ name : release
2
+
3
+ on :
4
+ push :
5
+ tags :
6
+ - " v*"
7
+
8
+ workflow_dispatch :
9
+
10
+ jobs :
11
+ meta :
12
+ uses : ./.github/workflows/meta.yml
13
+
14
+ release :
15
+ if : ${{ needs.meta.outputs.is_release == 'true' }}
16
+ needs : meta
17
+ runs-on : ubuntu-latest
18
+
19
+ steps :
20
+ - name : Checkout
21
+ uses : actions/checkout@v4
22
+
23
+ - name : Release
24
+ uses : softprops/action-gh-release@v2
25
+ with :
26
+ tag_name : ${{ needs.meta.outputs.tag }}
You can’t perform that action at this time.
0 commit comments