-
-
Notifications
You must be signed in to change notification settings - Fork 42
209 lines (175 loc) · 6.03 KB
/
build.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
name: build
on:
push:
branches:
- main
paths-ignore:
- "**.md"
- "**.spec.js"
- ".idea"
- ".gitignore"
- ".github/**"
- "!.github/workflows/build.yml"
- "!.github/workflows/import_cert.sh"
pull_request:
branches:
- main
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: "bash"
jobs:
pre_job:
# continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
paths: |
[
".github/workflows/build.yml",
".github/workflows/import_cert.sh",
"app/package.json",
"app/package-lock.json",
"app/electron-builder.config.js",
"app/get_version.js",
"app/src/vite_main.config.js",
"app/src/vite_renderer.config.js",
"app/src/scripts/*",
"app/assets/*",
"server/build_server.sh",
"server/poetry.lock",
"server/pyoxidizer.bzl",
"server/pyproject.toml",
"server/requirements.txt"
]
get_metadata:
runs-on: ubuntu-latest
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.event_name == 'push' }}
outputs:
branch: ${{ steps.extract_branch.outputs.branch }}
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: extract_branch
- name: echo branch name
shell: bash
run: echo "Currently on branch '${{ steps.extract_branch.outputs.branch }}'"
build:
needs: [get_metadata, pre_job]
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: import and trust codesigning cert for macOS
if: startsWith(matrix.os, 'macos') # && (github.ref_name == 'main' || github.ref_type == 'tag')
shell: bash
run: ./.github/workflows/import_cert.sh
env:
MAC_KEY_PASSWORD: ${{ secrets.mac_key_password }}
MAC_KEY: ${{ secrets.mac_key }}
MAC_CERT: ${{ secrets.mac_cert }}
# Build server
- name: setup python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/
key: ${{ runner.os }}-cargo
- name: install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: install pyoxidizer
run: python3 -m pip install pyoxidizer
- name: install poetry
uses: snok/install-poetry@v1
- name: build server
run: ./server/build_server.sh
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: "npm"
cache-dependency-path: app/package-lock.json
- name: install npm dependencies
run: npm --prefix app/ ci
- name: delete outdated draft releases
uses: hugo19941994/[email protected]
continue-on-error: true
with:
threshold: 5d
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# From https://github.com/samuelmeuli/action-electron-builder/issues/42
- name: install libarchive-tools for pacman build # Related https://github.com/electron-userland/electron-builder/issues/4181
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install libarchive-tools
# Compile app and upload artifacts
- name: build & release electron app
uses: samuelmeuli/action-electron-builder@v1
with:
build_script_name: build
package_root: app/
args: --config electron-builder.config.js ${{ (github.event_name != 'push' || needs.get_metadata.outputs.branch != 'main') && '--publish never' || ''}}
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}
# If the commit is in the main branch and this does not run on a PR, release
release: ${{ github.event_name == 'push' && needs.get_metadata.outputs.branch == 'main' }}
# Sometimes the build may fail due to a connection problem with Apple, GitHub, etc. servers.
# This option will restart the build as many attempts as possible
max_attempts: 3
# Code Signing params
# Base64-encoded code signing certificate for Windows
# windows_certs: ''
# Password for decrypting `windows_certs`
# windows_certs_password: ''
# Base64-encoded code signing certificate for macOS
mac_certs: ${{ secrets.mac_certs }}
# Password for decrypting `mac_certs`
mac_certs_password: ${{ secrets.mac_certs_password }}
- name: upload artifacts to github actions
uses: actions/upload-artifact@v3
with:
name: build-${{matrix.os}}
path: |
app/dist/*.deb
app/dist/*.pacman
app/dist/*.AppImage
app/dist/*.rpm
app/dist/*.dmg
app/dist/*.zip
app/dist/*.exe
finalize:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: check that build succeeded or was skipped
shell: bash
run: "[[ '${{needs.build.result}}' == 'success' || '${{needs.build.result}}' == 'skipped' ]]"