-
Notifications
You must be signed in to change notification settings - Fork 99
266 lines (254 loc) · 8.56 KB
/
ci.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
name: "test"
on:
pull_request:
workflow_dispatch:
inputs:
run_optional_build_desktop:
description: "Run the optional build_desktop job (yes/no)"
required: true
default: "no"
jobs:
changes:
runs-on: ubuntu-latest
outputs:
desktop: ${{steps.desktop.outputs.src}}
preview_folder: ${{steps.preview.outputs.folder}}
is-fork: ${{steps.check-fork.outputs.is-fork}}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: desktop
with:
filters: |
src:
- 'modules/desktop/**'
- 'modules/ui/**'
- name: get s3 preview folder
id: preview
run: echo "folder=${{ github.event.number }}-merge" >> $GITHUB_OUTPUT
- name: Check if PR is from fork
id: check-fork
run: |
echo "is-fork=$(if [ \"${{ github.event.pull_request.head.repo.full_name }}\" != \"${{ github.repository }}\" ]; then echo true; else echo false; fi)" >> $GITHUB_OUTPUT
shell: bash
test:
needs: changes
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: pkgxdev/dev@v0
- name: cache node_modules build
uses: actions/cache@v3
with:
key: test-mac
path: ./node_modules
- name: env file
run: |
cp .env.example svelte/.env
- name: install app dependencies
run: xc setup
- name: test build electron main process
run: npm run build:main
# TODO: fix
# - name: unit test
# run: pnpm --filter desktop run coverage
- name: lint
run: npm run lint
- name: check
run: npm run check
e2e_test:
needs: changes
runs-on: macos-latest
env:
# see: https://github.com/electron-userland/electron-builder/issues/3179
USE_HARD_LINKS: false
steps:
- uses: actions/checkout@v3
- uses: pkgxdev/dev@v0
- name: cache node_modules build
uses: actions/cache@v3
with:
key: e2e-macos
path: ./node_modules
- name: env file
run: cp .env.example svelte/.env
- name: install app dependencies
run: xc setup
- name: test build electron main process
run: xc build
env:
NOTARIZE: "false"
CSC_IDENTITY_AUTO_DISCOVERY: "false"
MAC_BUILD_TARGET: "dir"
- name: setup dev
run: |
mkdir -p /Users/runner/.pkgx/pkgx.app
touch /Users/runner/.pkgx/pkgx.app/dev
- name: e2e test
run: xc e2e
build_svelte:
needs: changes
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: pkgxdev/dev@v0
- name: cache node_modules build
uses: actions/cache@v3
with:
# key: ubuntu-latest-pnpm
key: mac-latest-pnpm
path: ./node_modules
- name: cache electron build
uses: actions/cache@v3
with:
key: mac-latest-electron
# key: ubuntu-latest-electron
path: |
./svelte/.svelte-kit
./svelte/build
- name: get gui version
id: gui-version
run: |
export version=$(echo $(cat package.json) | pkgx jq --raw-output .version)
export postfix=
if GIT_DIR=/path/to/repo/.git git rev-parse $1 >/dev/null 2>&1
then
echo "Found tag"
else
export postfix=-dev
fi
echo "version=$version$postfix" >> $GITHUB_OUTPUT
- name: build
run: xc build:lite
env:
PUBLIC_VERSION: ${{ steps.gui-version.outputs.version }}
BUILD_FOR: preview
build_desktop:
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.run_optional_build_desktop == 'yes')
needs: [changes, test]
# if: needs.changes.outputs.desktop == 'true'
strategy:
matrix:
platform:
# X86+64 is built with ARM64 also
- darwin+aarch64
uses: ./.github/workflows/build-sign-notarize.yml
with:
platform: ${{ matrix.platform }}
s3-prefix: ${{ needs.changes.outputs.preview_folder || 'dev-pr' }}
debug: 1
secrets: inherit
upload:
needs: [build_desktop, changes]
if: needs.changes.outputs.is-fork == 'false'
runs-on: ubuntu-latest
strategy:
matrix:
platform:
# x86 included already in aarch64
- name: darwin+aarch64
id: mac_m1
# - name: linux+x86-64
# id: linux
# - name: linux+aarch64
# id: linux_arm64
steps:
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: s3 artifact download
env:
S3_INSTALLER_KEY: ${{ needs.build_desktop.outputs.s3-custom-notarized-installers-key }}
run: aws s3 cp $S3_INSTALLER_KEY dist.tgz
- run: mkdir dist
- run: tar xzf dist.tgz -C dist
- name: get installer filenames of arm64 and x86+64
id: app_files
working-directory: ./dist
run: |
ARM64_ZIP=$(ls | grep -Ev blockmap | grep arm64-mac.zip)
X86_ZIP=$(ls | grep -Ev blockmap | grep -Ev arm64 | grep mac.zip)
ARM64_DMG=$(ls | grep -Ev blockmap | grep arm64.dmg)
X86_DMG=$(ls | grep -Ev blockmap | grep -Ev arm64 | grep dmg)
echo zip_arm64=$ARM64_ZIP >> $GITHUB_OUTPUT
echo zip_x86=$X86_ZIP >> $GITHUB_OUTPUT
echo dmg_arm64=$ARM64_DMG >> $GITHUB_OUTPUT
echo dmg_x86=$X86_DMG >> $GITHUB_OUTPUT
- name: build platform output
id: build_platform
env:
platform: ${{ matrix.platform.name }}
run: |
BUILD_PLATFORM=$(echo $platform | sed -e "s/darwin+//g" | sed -e "s/linux+//g")
EXTENSION=dmg
case $platform in
"linux+x86-64")
BUILD_PLATFORM="amd64"
EXTENSION="deb"
;;
"linux+aarch64")
BUILD_PLATFORM="aarch64"
EXTENSION="deb"
;;
"darwin+aarch64")
BUILD_PLATFORM="aarch64"
EXTENSION="dmg"
;;
"darwin+x86-64")
BUILD_PLATFORM="x64"
EXTENSION="dmg"
;;
*)
echo "Unknown platform $platform"
exit 1
;;
esac
echo "build_platform=$BUILD_PLATFORM" >> $GITHUB_OUTPUT
echo "extension=$EXTENSION" >> $GITHUB_OUTPUT
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: cp package images from prod to preview bucket
env:
prefix: ${{ needs.changes.outputs.preview_folder }}
bucket: ${{ secrets.BUILDS_S3_BUCKET }}
run: |
cd dist && \
aws s3 sync . "$bucket/$prefix/"
- name: comment install for Linux
if: startsWith(matrix.platform.name, 'linux')
uses: mshick/add-pr-comment@v2
with:
message-id: ${{ matrix.platform.id }}-comment
message: |
**installer for Linux ${{ matrix.platform.name }} is at**:
```bash
${{ secrets.BUILDS_S3_PUBLIC_DOMAIN }}/${{ needs.changes.outputs.preview_folder }}/${{ steps.build_platform.outputs.filename }}
```
copy-paste into a browser to download
- name: comment install for MacOS
if: startsWith(matrix.platform.name, 'darwin')
uses: mshick/add-pr-comment@v2
with:
message-id: darwin+aarch64-comment
message: |
**installers for MacOS darwin+aarch64 is at**:
```bash
${{ secrets.BUILDS_S3_PUBLIC_DOMAIN }}/${{ needs.changes.outputs.preview_folder }}/${{ steps.app_files.outputs.dmg_arm64 }}
```
copy-paste into a browser to download
- name: comment install for MacOS
if: startsWith(matrix.platform.name, 'darwin')
uses: mshick/add-pr-comment@v2
with:
message-id: darwin+x86-64-comment
message: |
**installers for MacOS darwin+x86-64 is at**:
```bash
${{ secrets.BUILDS_S3_PUBLIC_DOMAIN }}/${{ needs.changes.outputs.preview_folder }}/${{ steps.app_files.outputs.dmg_x86 }}
```
copy-paste into a browser to download