-
Notifications
You must be signed in to change notification settings - Fork 1.9k
286 lines (256 loc) · 12 KB
/
build-and-release.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
name: Build And Release
on:
push:
branches:
- release*
tags:
- '*'
jobs:
# job 1
build-and-upload:
runs-on: ${{ matrix.os }}-latest
env:
ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron
ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder
strategy:
fail-fast: false
matrix:
os:
- windows
- ubuntu
- macos
node:
- 22
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: 'Setup Node.js "${{ matrix.node }}.x" environment'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
registry-url: https://npm.pkg.github.com/
cache: pnpm
- name: Setup Python environment (Mac) Because of electron-builder install-app-deps requires Python setup tools
if: matrix.os == 'macos'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Get package info
id: package-info
uses: luizfelipelaviola/get-package-info@v1
with:
path: ./packages/mitmproxy
- name: Print
run: |
echo "version = ${{ steps.package-info.outputs.version }}";
echo "github.ref_type = ${{ github.ref_type }}";
echo "github.ref = ${{ github.ref }}";
echo "github.ref_name = ${{ github.ref_name }}";
- name: 'npm -v | pnpm -v | python --version'
run: |
echo "======================================================================";
echo "npm -v";
echo "--------------------";
npm -v;
echo "======================================================================";
echo "pnpm -v";
echo "--------------------";
pnpm -v;
echo "======================================================================";
echo "python --version";
echo "--------------------";
python --version;
- name: Setup electron cahce
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.cache/electron
key: ${{ runner.os }}-electron-cache-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-electron-cache-
- name: Setup electron-builder cahce
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.cache/electron-builder
key: ${{ runner.os }}-electron-builder-cache-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-electron-builder-cache-
- name: "'pnpm install --force' Because we need to install optional dependencies"
run: |
echo "======================================================================";
dir || ls -lah;
echo "======================================================================";
echo "pnpm install";
echo "--------------------";
pnpm install;
- name: 'npm run electron:build'
run: |
echo "======================================================================";
echo "cd packages/gui";
echo "--------------------";
cd packages/gui;
dir || ls -lah;
echo "======================================================================";
echo "npm run electron:build";
echo "--------------------";
npm run electron:build;
- name: 'Print dir "packages/gui/dist_electron/"'
run: |
echo "======================================================================";
echo "cd packages/gui/dist_electron";
echo "--------------------";
cd packages/gui/dist_electron;
dir || ls -lah;
# Rename artifacts
- name: 'Rename artifacts - Windows'
if: ${{ matrix.os == 'windows' }}
run: |
cd packages/gui/dist_electron;
ren DevSidecar-${{ steps.package-info.outputs.version }}-ia32.exe DevSidecar-${{ steps.package-info.outputs.version }}-windows-ia32.exe;
ren DevSidecar-${{ steps.package-info.outputs.version }}-x64.exe DevSidecar-${{ steps.package-info.outputs.version }}-windows-x64.exe;
ren DevSidecar-${{ steps.package-info.outputs.version }}-arm64.exe DevSidecar-${{ steps.package-info.outputs.version }}-windows-arm64.exe;
dir;
- name: 'Rename artifacts - Linux'
if: ${{ matrix.os == 'ubuntu' }}
run: |
cd packages/gui/dist_electron;
mv DevSidecar-${{ steps.package-info.outputs.version }}-amd64.deb DevSidecar-${{ steps.package-info.outputs.version }}-linux-amd64.deb;
mv DevSidecar-${{ steps.package-info.outputs.version }}-arm64.deb DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.deb;
mv DevSidecar-${{ steps.package-info.outputs.version }}-x86_64.AppImage DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.AppImage;
mv DevSidecar-${{ steps.package-info.outputs.version }}-arm64.AppImage DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.AppImage;
ls -lah;
- name: 'Rename artifacts - macOS'
if: ${{ matrix.os == 'macos' }}
run: |
cd packages/gui/dist_electron;
mv DevSidecar-${{ steps.package-info.outputs.version }}-universal.dmg DevSidecar-${{ steps.package-info.outputs.version }}-macos-universal.dmg;
ls -lah;
#region Upload artifacts - Windows
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-windows-ia32.exe'
uses: actions/[email protected]
if: ${{ matrix.os == 'windows' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-windows-ia32.exe
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-windows-ia32.exe'
if-no-files-found: error
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-windows-x64.exe'
uses: actions/[email protected]
if: ${{ matrix.os == 'windows' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-windows-x64.exe
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-windows-x64.exe'
if-no-files-found: error
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-windows-arm64.exe'
uses: actions/[email protected]
if: ${{ matrix.os == 'windows' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-windows-arm64.exe
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-windows-arm64.exe'
if-no-files-found: error
#endregion Upload artifacts - Windows
#region Upload artifacts - Linux
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-linux-amd64.deb'
uses: actions/[email protected]
if: ${{ matrix.os == 'ubuntu' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-linux-amd64.deb
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-amd64.deb'
if-no-files-found: error
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.deb'
uses: actions/[email protected]
if: ${{ matrix.os == 'ubuntu' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.deb
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.deb'
if-no-files-found: error
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.AppImage'
uses: actions/[email protected]
if: ${{ matrix.os == 'ubuntu' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.AppImage
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.AppImage'
if-no-files-found: error
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.AppImage'
uses: actions/[email protected]
if: ${{ matrix.os == 'ubuntu' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.AppImage
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.AppImage'
if-no-files-found: error
#endregion Upload artifacts - Linux
# Upload artifacts - macOS
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-macos-universal.dmg'
uses: actions/[email protected]
if: ${{ matrix.os == 'macos' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-macos-universal.dmg
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-macos-universal.dmg'
if-no-files-found: error
# job 2
download-and-release:
runs-on: ubuntu-latest
needs:
- build-and-upload
steps:
- name: Checkout
uses: actions/[email protected]
- name: Get package info
id: package-info
uses: luizfelipelaviola/get-package-info@v1
with:
path: ./packages/mitmproxy
- name: 'Make "release" dir'
run: mkdir release
# Download artifacts
- name: 'Download DevSidecar-${{ steps.package-info.outputs.version }}-windows-ia32.exe'
uses: actions/[email protected]
with:
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-windows-ia32.exe'
path: release
- name: 'Download DevSidecar-${{ steps.package-info.outputs.version }}-windows-x64.exe'
uses: actions/[email protected]
with:
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-windows-x64.exe'
path: release
- name: 'Download DevSidecar-${{ steps.package-info.outputs.version }}-windows-arm64.exe'
uses: actions/[email protected]
with:
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-windows-arm64.exe'
path: release
- name: 'Download DevSidecar-${{ steps.package-info.outputs.version }}-linux-amd64.deb'
uses: actions/[email protected]
with:
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-amd64.deb'
path: release
- name: 'Download DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.deb'
uses: actions/[email protected]
with:
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.deb'
path: release
- name: 'Download DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.AppImage'
uses: actions/[email protected]
with:
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.AppImage'
path: release
- name: 'Download DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.AppImage'
uses: actions/[email protected]
with:
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.AppImage'
path: release
- name: 'Download DevSidecar-${{ steps.package-info.outputs.version }}-macos-universal.dmg'
uses: actions/[email protected]
with:
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-macos-universal.dmg'
path: release
- name: 'Print files from "release" dir'
run: |
ls -lah release;
- name: Create a draft release
uses: wangliang181230/github-action-ghr@master
env:
GITHUB_TOKEN: ${{ github.token }}
GHR_PATH: release/
GHR_TITLE: ${{ github.ref_name }}
GHR_REPLACE: true
GHR_DRAFT: true