-
Notifications
You must be signed in to change notification settings - Fork 41
347 lines (292 loc) Β· 14.5 KB
/
pr-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
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
name: PR Build
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
build-and-upload:
if: github.event.pull_request.draft == false
runs-on: ${{ matrix.image }}
strategy:
matrix:
include:
- image: macos-13
id: macos
platform: macos
node: mac-amd64
arch: '' # x64
quicksync: macos
- image: windows-latest
id: windows
platform: windows
node: win-amd64
arch: '' # x64
quicksync: windows
- image: ubuntu-latest
id: linux
platform: linux
node: linux-amd64
arch: amd64
quicksync: linux
- image: [smapp]
id: macos-arm64
platform: macos
node: mac-arm64
arch: arm64
quicksync: macos-arm64
- image: ubuntu-latest-arm-8-cores
id: linux-arm64
platform: linux
node: linux-arm64
arch: arm64
quicksync: linux-arm64
outputs:
version: ${{ steps.package-version.outputs.version }}
steps:
- id: timestamp
run: echo "::set-output name=timestamp::$(date +'%s')"
- name: Check out Git repository
uses: actions/checkout@v2
with:
submodules: 'true'
- name: Install Node.js, NPM
id: setup-node
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
- name: Install Yarn
run: npm install -g [email protected]
- name: Get node_modules cache
uses: actions/[email protected]
id: node_modules
with:
path: |
**/node_modules
# Add node version as a cache key to avoid yarn recompilation for particular node as it doesn't change often
key: ${{ matrix.arch }}-${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}-${{ steps.setup-node.outputs.node-version }}
- name: Get Smapp version
id: cur-package-version
uses: tyankatsu0105/read-package-version-actions@v1
- name: Set package.json version
if: github.event_name == 'pull_request'
uses: HarmvZ/[email protected]
with:
version: ${{ steps.cur-package-version.outputs.version }}-pr.${{ github.event.pull_request.number }}
- name: yarn install
run: |
yarn config set network-timeout 300000
yarn install --prefer-offline --immutable
- name: yarn lint
run: yarn lint
# Download go-spacemesh
- name: Get specified Go-spacemesh version
id: latestNode
run: echo "::set-output name=version::$(cat ./node/use-version)"
- name: Get specified Quicksync version
id: latestQuicksync
run: echo "::set-output name=version::$(cat ./node/use-version-quicksync)"
- id: cache-gospacemesh
uses: actions/cache@v3
with:
path: |
./node/*
!./node/use-version
key: ${{ matrix.node }}-${{ hashFiles('./node/use-version') }}-${{ hashFiles('./node/use-version-quicksync') }}
restore-keys: ${{ matrix.node }}-${{ hashFiles('./node/use-version') }}-${{ hashFiles('./node/use-version-quicksync') }}
- name: Prepare link to go-spacemesh release archive
if: steps.cache-gospacemesh.outputs.cache-hit != 'true'
id: node-link
run: |
echo "::set-output name=link::https://storage.googleapis.com/go-spacemesh-release-builds/${{ steps.latestNode.outputs.version }}/go-spacemesh-${{ steps.latestNode.outputs.version }}-${{ matrix.node }}.zip"
- name: Check for go-spacemesh release archive existence
if: steps.cache-gospacemesh.outputs.cache-hit != 'true'
run: |
[[ $( curl -I -L -w "%{http_code}" -o ${{ matrix.platform == 'windows' && 'NUL' || '/dev/null'}} ${{ steps.node-link.outputs.link }} ) == "200" ]] &&
echo "Atifacts found: ${{ steps.node-link.outputs.link }}" && exit 0 ||
echo "Not found: ${{ steps.node-link.outputs.link }}" && exit 1
shell: bash
- id: platform
run: |
echo "::set-output name=dir::${{ matrix.platform == 'windows' && 'windows' || matrix.platform == 'macos' && 'mac' || 'linux'}}"
echo "::set-output name=ext::${{ matrix.platform == 'windows' && '.exe' || ''}}"
echo "::set-output name=rm_flag::${{ matrix.platform == 'windows' && '-Recurse -Force' || '-rf' }}"
- name: Download go-spacemesh release archive
if: steps.cache-gospacemesh.outputs.cache-hit != 'true'
run: |
curl -L --output ./node/release.zip --create-dirs ${{ steps.node-link.outputs.link }}
- name: Unzip archive & get rid of redundant files
if: steps.cache-gospacemesh.outputs.cache-hit != 'true'
run: |
7z e -onode/${{ steps.platform.outputs.dir }}/ ./node/release.zip 'go-spacemesh*' '*.dylib' 'Molt*' '*.so' '*.dll' '*.lib' '*.h' 'profiler*' -r -y
- name: Download quicksync tool
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: 'spacemeshos/quicksync-rs'
version: 'tags/${{ steps.latestQuicksync.outputs.version }}'
file: 'quicksync-${{ matrix.quicksync }}-${{ steps.latestQuicksync.outputs.version }}.zip'
target: 'node/quicksync.zip'
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Unzip archive & get rid of redundant files
if: steps.cache-gospacemesh.outputs.cache-hit != 'true'
run: |
7z e -onode/${{ steps.platform.outputs.dir }}/ ./node/quicksync.zip 'quicksync*' -r -y
- name: Set CHMOD on Go-Spacemesh and libs
if: matrix.platform != 'windows'
run: chmod -R +x ./node/${{ steps.platform.outputs.dir }}/*
- name: Disable quarantine for Go-Spacemesh and libs (macOS x64)
if: matrix.id == 'macos'
run: sudo xattr -rd com.apple.quarantine ./node/${{ steps.platform.outputs.dir }}/*
- name: Disable quarantine for Go-Spacemesh and libs (macOS ARM64)
if: matrix.id == 'macos-arm64'
run: sudo /Users/aviv/xattr.sh
- name: ls ./node
run: |
7z l ./node/release.zip
ls ${{ matrix.platform != 'windows' && '-la' || '' }} ./node/${{ steps.platform.outputs.dir }}/
- name: Install libOpenCL.so
if: matrix.platform == 'linux'
run: |
sudo apt update
sudo apt install ocl-icd-opencl-dev
- name: Install fpm
if: matrix.id == 'linux-arm64'
run: |
sudo apt-get install -y ruby ruby-dev rubygems build-essential
sudo gem install --no-document fpm
# Run tests
- name: yarn test
if: matrix.id == 'macos'
run: yarn test --forceExit
# Build
- name: yarn build
run: yarn build
# Create binaries
- if: matrix.platform == 'linux'
name: Build linux app
run: |
echo "USE_SYSTEM_FPM? $(echo $USE_SYSTEM_FPM)"
yarn package-linux
env:
USE_SYSTEM_FPM: ${{ matrix.id == 'linux-arm64' && 'true' }}
- if: matrix.platform == 'windows'
name: Build windows app
run: yarn package-win
env:
DONT_SIGN_APP: true # Do not sign the development artifacts
- if: matrix.platform == 'macos'
name: Build mac app
run: yarn package-mac
env:
DONT_SIGN_APP: true # Do not sign the development artifacts
- name: ls ./release
run: ls ${{ matrix.platform != 'windows' && '-la' || '' }} ./release
# Upload artifacts to GCS
- name: get-smapp-version
id: package-version
uses: tyankatsu0105/read-package-version-actions@v1
- name: Smapp version
run: |
echo "Version: ${{ steps.package-version.outputs.version }}"
- name: Set up GCloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- if: matrix.platform == 'macos'
name: upload macos build
uses: google-github-actions/upload-cloud-storage@v0
env:
preSuffix: ${{ matrix.arch != '' && '-' || '' }}
with:
path: ./release/Spacemesh-${{ steps.package-version.outputs.version }}${{ env.preSuffix }}${{ matrix.arch }}.dmg
destination: ${{ secrets.GCP_BUCKET }}/pr-${{ github.sha }}
- if: matrix.platform == 'windows'
name: upload windows build
uses: google-github-actions/upload-cloud-storage@v0
with:
path: ./release/Spacemesh Setup ${{ steps.package-version.outputs.version }}.exe
destination: ${{ secrets.GCP_BUCKET }}/pr-${{ github.sha }}
- if: matrix.platform == 'linux'
name: upload linux build
uses: google-github-actions/upload-cloud-storage@v0
env:
preSuffix: ${{ matrix.arch != '' && '_' || '' }}
with:
path: ./release/spacemesh_app_${{ steps.package-version.outputs.version }}${{ env.preSuffix }}${{ matrix.arch }}.deb
destination: ${{ secrets.GCP_BUCKET }}/pr-${{ github.sha }}
- if: matrix.platform == 'linux'
name: upload linux build
uses: google-github-actions/upload-cloud-storage@v0
env:
arch: ${{ matrix.arch == 'arm64' && '-arm64' || '' }}
with:
path: ./release/Spacemesh-${{ steps.package-version.outputs.version }}${{ env.arch }}.AppImage
destination: ${{ secrets.GCP_BUCKET }}/pr-${{ github.sha }}
# Upload artifacts to Cloudflare
- if: matrix.platform == 'windows'
name: aws cli windows
run: choco install awscli
- if: matrix.platform == 'linux'
name: aws cli linux
run: sudo apt install awscli
- name: Set Up AWS export_default_credentials
run: |
aws configure set aws_access_key_id ${{ secrets.CLOUDFLARE_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.CLOUDFLARE_SECRET_ACCESS_KEY }}
aws configure set region ${{ secrets.CLOUDFLARE_BUCKET_REGION }}
- if: matrix.platform == 'macos'
name: Upload macos build to R2
env:
preSuffix: ${{ matrix.arch != '' && '-' || '' }}
run: |
BUILD_PATH='Spacemesh-${{ steps.package-version.outputs.version }}${{ env.preSuffix }}${{ matrix.arch }}.dmg'
aws s3 cp ./release/${BUILD_PATH} s3://${{ secrets.CLOUDFLARE_BUCKET }}/dist/pr-${{ github.sha }}/${BUILD_PATH} \
--endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
- if: matrix.platform == 'windows'
name: Upload windows build to R2
run: |
$BUILD_PATH='Spacemesh Setup ${{ steps.package-version.outputs.version }}.exe'
aws s3 cp "./release/$BUILD_PATH" "s3://${{ secrets.CLOUDFLARE_BUCKET }}/dist/pr-${{ github.sha }}/$BUILD_PATH" --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
- if: matrix.platform == 'linux'
name: Upload linux build to R2
env:
preSuffix: ${{ matrix.arch != '' && '_' || '' }}
run: |
BUILD_PATH='spacemesh_app_${{ steps.package-version.outputs.version }}${{ env.preSuffix }}${{ matrix.arch }}.deb'
aws s3 cp ./release/${BUILD_PATH} s3://${{ secrets.CLOUDFLARE_BUCKET }}/dist/pr-${{ github.sha }}/${BUILD_PATH} \
--endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
- if: matrix.platform == 'linux'
name: Upload linux build to R2
env:
arch: ${{ matrix.arch == 'arm64' && '-arm64' || '' }}
run: |
BUILD_PATH='Spacemesh-${{ steps.package-version.outputs.version }}${{ env.arch }}.AppImage'
aws s3 cp ./release/${BUILD_PATH} s3://${{ secrets.CLOUDFLARE_BUCKET }}/dist/pr-${{ github.sha }}/${BUILD_PATH} \
--endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
post-links:
runs-on: ubuntu-latest
needs: build-and-upload
steps:
- name: Links to artifacts
run: |
echo "Windows (x64): https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/Spacemesh%20Setup%20${{ needs.build-and-upload.outputs.version }}.exe"
echo "macOS (x64): https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/Spacemesh-${{ needs.build-and-upload.outputs.version }}.dmg"
echo "macOS (arm64): https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/Spacemesh-${{ needs.build-and-upload.outputs.version }}-arm64.dmg"
echo "Linux (deb, amd64): https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/spacemesh_app_${{ needs.build-and-upload.outputs.version }}_amd64.deb"
echo "Linux (AppImage, amd64): https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/Spacemesh-${{ needs.build-and-upload.outputs.version }}.AppImage"
echo "Linux (deb, arm64): https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/spacemesh_app_${{ needs.build-and-upload.outputs.version }}_arm64.deb"
echo "Linux (AppImage, arm64): https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/Spacemesh-${{ needs.build-and-upload.outputs.version }}-arm64.AppImage"
- name: Post links to PR
if: github.event_name == 'pull_request'
uses: mshick/add-pr-comment@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: |
## Compiled Binaries
- Windows: [x64](https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/Spacemesh%20Setup%20${{ needs.build-and-upload.outputs.version }}.exe)
- macOS: [x64](https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/Spacemesh-${{ needs.build-and-upload.outputs.version }}.dmg) [arm64](https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/Spacemesh-${{ needs.build-and-upload.outputs.version }}-arm64.dmg)
- Linux
- AppImage [x64](https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/Spacemesh-${{ needs.build-and-upload.outputs.version }}.AppImage) [arm64](https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/Spacemesh-${{ needs.build-and-upload.outputs.version }}-arm64.AppImage)
- deb [x64](https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/spacemesh_app_${{ needs.build-and-upload.outputs.version }}_amd64.deb) [arm64](https://smapp.spacemesh.network/dist/pr-${{ github.sha }}/spacemesh_app_${{ needs.build-and-upload.outputs.version }}_arm64.deb)