forked from duolabmeng6/qtAutoUpdateApp
-
Notifications
You must be signed in to change notification settings - Fork 1
146 lines (138 loc) · 4.36 KB
/
cd.yaml
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
name: 持续交付
on:
push: # 代码推送到main分支自动触发工作流
branches:
- main
workflow_dispatch: # 允许手动触发
inputs:
environment:
type: choice
description: 'Action'
required: false
default: Just Release
options:
- Release
- Release ann Deploy
permissions: write-all # 给所有工作写权限
jobs:
jobs_v:
name: 构建版本号和变更信息
runs-on: ubuntu-latest
outputs:
version: ${{ steps.create_version.outputs.tag_name }} # 版本号
body: ${{ steps.create_version.outputs.body }} # 版本变更内容
steps:
- name: 生成版本号
id: tag_name
uses: mathieudutour/github-tag-action@v6.1
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
- name: 查看变量
run: |
echo ${{ format('version={0}', steps.create_version.outputs.tag_name ) }}
jobs_window:
needs: jobs_v # 等待 jobs_v 任务完成才执行
name: 构建window软件
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: 读入环境信息
run: |
echo ${{ format('version {0}', env.version ) }} # 版本号
- name: 编译环境设置 Python 3.9.13
uses: actions/setup-python@v4
with:
python-version: "3.9.13"
architecture: "x64"
cache: 'pip'
- name: 下载依赖文件
run: pip install -r requirements.txt
- name: 编译exe
run: |
python run_write_version.py
pyinstaller --noconfirm --onefile --windowed --icon "app.ico" "my_app.py"
- name: 测试运行情况
uses: GuillaumeFalourd/assert-command-line-output@v2
with:
command_line: ./dist/my_app.exe test
contains: app run success
expected_result: PASSED
- name: 上传产物
uses: actions/upload-artifact@v3
with:
name: window
path: ./dist/*.exe
jobs_macos:
needs: jobs_v
name: 构建macos软件
runs-on: macos-12
env:
version: ${{ needs.jobs_v.outputs.version }}
body: ${{ needs.jobs_v.outputs.body }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: 读入环境信息
run: |
echo ${{ format('version {0}', env.version ) }}
- name: 编译环境设置 Python 3.9.13
uses: actions/setup-python@v4
with:
python-version: "3.9.13"
architecture: "x64"
cache: 'pip'
- name: 下载依赖文件
run: pip install -r requirements.txt
- name: 编译 MacOS.app
run: |
python run_write_version.py
pyinstaller my_app_macos.spec
- name: 测试运行情况
uses: GuillaumeFalourd/assert-command-line-output@v2
with:
command_line: ./dist/my_app.app/Contents/MacOS/my_app test
contains: app run success
expected_result: PASSED
- name: 创建压缩包
run: |
cd ./dist
zip -r ./my_app_MacOS.zip ./my_app.app
- name: 上传产物
uses: actions/upload-artifact@v3
with:
name: macos
path: ./dist/*.zip
jobs4:
needs: [ jobs_v,jobs_window,jobs_macos ]
name: 发布版本
runs-on: ubuntu-latest
env:
version: ${{ needs.jobs_v.outputs.version }}
body: ${{ needs.jobs_v.outputs.body }}
steps:
- 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.TOKEN_GITHUB }}
allowUpdates: true # 覆盖文件
#draft: true # 草稿 自己可见 版本号会保持一样 默认是自动发布 latest
#prerelease: true # 预发布 别人可以看到 版本号会继续加
tag: ${{ env.version }} # 版本号 v0.1.0
body: ${{ env.body }} # 输出的内容
artifacts: "window/*.exe,macos/*.zip"