6
6
- ' main'
7
7
workflow_dispatch :
8
8
9
+ env :
10
+ VERSION : 1.0.${{ github.run_number }} # 动态版本号,基于当前工作流运行次数
11
+
9
12
jobs :
10
13
linux :
11
14
runs-on : ubuntu-latest
12
15
steps :
13
- - name : checkout
16
+ - name : Checkout code
14
17
uses : actions/checkout@v3
15
18
with :
16
19
fetch-depth : 0
17
20
21
+ - name : Set version
22
+ run : |
23
+ sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" package.json
24
+
18
25
- name : Install dependencies with Yarn
19
26
run : yarn install
20
27
21
- - name : make
22
- run : yarn make
28
+ - name : Build for Linux
29
+ run : |
30
+ yarn make
31
+
32
+ - name : Upload Linux Artifact
33
+ uses : actions/upload-artifact@v3
34
+ with :
35
+ name : linux-artifact
36
+ path : out/make
23
37
24
38
windows :
25
39
runs-on : windows-latest
26
40
steps :
27
- - name : checkout
41
+ - name : Checkout code
28
42
uses : actions/checkout@v3
29
43
with :
30
44
fetch-depth : 0
31
45
46
+ - name : Set version
47
+ run : |
48
+ powershell -Command "(gc package.json) -replace '\\\"version\\\": \".*\\\"', '\\\"version\\\": \"$VERSION\"' | Set-Content package.json"
49
+
32
50
- name : Install dependencies with Yarn
33
51
run : yarn install
34
52
35
- - name : make
53
+ - name : Build for Windows
36
54
run : yarn make
37
55
56
+ - name : Upload Windows Artifact
57
+ uses : actions/upload-artifact@v3
58
+ with :
59
+ name : windows-artifact
60
+ path : out/make
61
+
38
62
macos :
39
63
runs-on : macos-latest
40
64
steps :
41
- - name : checkout
65
+ - name : Checkout code
42
66
uses : actions/checkout@v3
43
67
with :
44
68
fetch-depth : 0
45
69
70
+ - name : Set version
71
+ run : |
72
+ sed -i '' "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" package.json
73
+
46
74
- name : Install dependencies with Yarn
47
75
run : yarn install
48
76
49
- - name : make
50
- run : yarn make
77
+ - name : Build for macOS
78
+ run : yarn make
79
+
80
+ - name : Upload macOS Artifact
81
+ uses : actions/upload-artifact@v3
82
+ with :
83
+ name : macos-artifact
84
+ path : out/make
85
+
86
+ release :
87
+ needs : [linux, windows, macos]
88
+ runs-on : ubuntu-latest
89
+ steps :
90
+ - name : Download Linux Artifact
91
+ uses : actions/download-artifact@v3
92
+ with :
93
+ name : linux-artifact
94
+ path : dist/linux
95
+
96
+ - name : Download Windows Artifact
97
+ uses : actions/download-artifact@v3
98
+ with :
99
+ name : windows-artifact
100
+ path : dist/windows
101
+
102
+ - name : Download macOS Artifact
103
+ uses : actions/download-artifact@v3
104
+ with :
105
+ name : macos-artifact
106
+ path : dist/macos
107
+
108
+ - name : Create Release
109
+ uses : actions/create-release@v1
110
+ env :
111
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
112
+ with :
113
+ tag_name : v${{ env.VERSION }}
114
+ release_name : Git Helper v${{ env.VERSION }}
115
+ draft : false
116
+ prerelease : false
117
+
118
+ - name : Upload Linux Asset
119
+ uses : actions/upload-release-asset@v1
120
+ env :
121
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
122
+ with :
123
+ upload_url : ${{ steps.create_release.outputs.upload_url }}
124
+ asset_path : dist/linux
125
+ asset_name : linux.zip
126
+ asset_content_type : application/zip
127
+
128
+ - name : Upload Windows Asset
129
+ uses : actions/upload-release-asset@v1
130
+ env :
131
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
132
+ with :
133
+ upload_url : ${{ steps.create_release.outputs.upload_url }}
134
+ asset_path : dist/windows
135
+ asset_name : windows.zip
136
+ asset_content_type : application/zip
137
+
138
+ - name : Upload macOS Asset
139
+ uses : actions/upload-release-asset@v1
140
+ env :
141
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
142
+ with :
143
+ upload_url : ${{ steps.create_release.outputs.upload_url }}
144
+ asset_path : dist/macos
145
+ asset_name : macos.zip
146
+ asset_content_type : application/zip
0 commit comments