-
Notifications
You must be signed in to change notification settings - Fork 30
214 lines (202 loc) · 6.31 KB
/
发布软件.yml
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: 发布软件
on:
workflow_dispatch:
push:
paths-ignore:
- '**/*.md'
- '**/*.yml'
- .gitignore
- .editorconfig
permissions: write-all # 给所有工作写权限
jobs:
jobs_v:
name: 构建版本号和变更信息
runs-on: ubuntu-latest
outputs:
version: ${{ steps.create_version.outputs.NewVersion }} # 版本号
body: ${{ steps.create_body.outputs.Body }} # 版本变更内容
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: 检查是否 "发布"
run: |
latest_commit_message=$(git log -1 --pretty=%B)
if [[ $latest_commit_message == *"发布"* ]]; then
echo "找到发布关键字继续工作流"
else
echo "没有找到发布关键字停止工作流"
exit 1 # 停止工作流程
fi
- name: 递增版本号
id: create_version
uses: duolabmeng6/action-autotag-python@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: 获取更新日志
id: create_body
uses: duolabmeng6/action-Releases-log@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE: .github/releasesText.md
KEYS: bug,改进,优化,新增,删除
- name: 查看版本号和更新日志
run: |
echo ${{ format('version={0}', steps.create_version.outputs.NewVersion ) }}
echo "${{ steps.create_body.outputs.Body }}"
jobs_macos:
# 暂停
#if: false
needs: [ jobs_v ]
name: 构建macos软件
runs-on: macos-12
env:
version: ${{ needs.jobs_v.outputs.version }}
body: ${{ needs.jobs_v.outputs.Body }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: 构建缓存
uses: actions/cache@v3
with:
path: |
/Users/runner/.npm
key: ${{ runner.os }}-js-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-js-
- name: 查看文件
run: |
pwd
ls -la
echo "New Body: ${{ env.body }}"
- name: 安装 go
uses: actions/setup-go@v4
with:
go-version: '^1.21.0'
cache-dependency-path: |
**/go.sum
**/go.mod
go-version-file: 'go.mod'
- run: go version
- name: 安装 wails 工具
run: |
go install github.com/wailsapp/wails/v2/cmd/wails@latest
wails
- name: 生成 Version.go 文件
run: |
echo -e "package mymodel\n\nvar Version = \"${version}\"" > GoEasyDesigner/mymodel/Version.go
cat GoEasyDesigner/mymodel/Version.go
- name: 编译
run: |
pwd
cd GoEasyDesigner
wails build
ls -la
- name: 查看编译的文件保存
run: |
ls -la
mkdir -p /tmp/artifacts
cp -r GoEasyDesigner/build/bin/GoEasyDesigner.app /tmp/artifacts/GoEasyDesigner.app
cp -r GoEasyDesigner/build/dmg.sh /tmp/artifacts/dmg.sh
chmod +x /tmp/artifacts/GoEasyDesigner.app/Contents/MacOS/GoEasyDesigner
- name: 创建压缩包
run: |
cd /tmp/artifacts/
./dmg.sh
zip -r ./GoEasyDesigner_MacOS.zip ./GoEasyDesigner.app
- name: 上传产物
uses: actions/upload-artifact@v3
with:
name: macos
path: |
/tmp/artifacts/*.zip
/tmp/artifacts/*.dmg
jobs_window:
needs: jobs_v # 等待 jobs_v 任务完成才执行
name: 构建window软件
timeout-minutes: 20
runs-on: windows-2022
env:
version: ${{ needs.jobs_v.outputs.version }}
body: ${{ needs.jobs_v.outputs.Body }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: 构建缓存
uses: actions/cache@v3
with:
path: |
C:\npm\cache
key: ${{ runner.os }}-js-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-js-
- name: 读入环境信息
run: |
echo ${{ format('version {0}', env.version ) }} # 版本号
- name: 安装 go
uses: actions/setup-go@v4
with:
go-version: '^1.21.0'
cache-dependency-path: |
**/go.sum
**/go.mod
go-version-file: 'go.mod'
- run: go version
- name: 安装 UPX
uses: crazy-max/ghaction-upx@v2
with:
install-only: true
- name: 安装 wails 工具
run: |
go install github.com/wailsapp/wails/v2/cmd/wails@latest
wails
- name: 生成 Version.go 文件
shell: bash
run: |
echo -e "package mymodel\n\nvar Version = \"${version}\"" > GoEasyDesigner/mymodel/Version.go
cat GoEasyDesigner/mymodel/Version.go
- name: 编译exe
run: |
cd GoEasyDesigner
wails build -webview2 embed -upx
ls
- name: 上传产物
uses: actions/upload-artifact@v3
with:
name: window
path: |
GoEasyDesigner/build/bin/*.exe
jobs4:
needs: [ jobs_v,jobs_macos,jobs_window ]
name: 发布版本
runs-on: ubuntu-latest
env:
version: ${{ needs.jobs_v.outputs.version }}
body: ${{ needs.jobs_v.outputs.Body }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: 下载产物
id: download
uses: actions/download-artifact@v3
with:
path: ./
- name: 读入环境信息
run: |
echo ${{ format('version {0}', env.version ) }}
echo ${{steps.download.outputs.download-path}}
ls -R
- name: 发布文件
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true # 覆盖文件
#draft: true # 草稿 自己可见 版本号会保持一样 默认是自动发布 latest
#prerelease: true # 预发布 别人可以看到 版本号会继续加
tag: ${{ env.version }} # 版本号 v0.1.0
body: ${{ env.body }}
artifacts: "macos/*.zip,macos/*.dmg,window/*.exe,window/*.zip"