-
Notifications
You must be signed in to change notification settings - Fork 2
323 lines (288 loc) · 12.1 KB
/
build-installers.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
name: 📦🚀 Build & Release
on:
push:
tags:
- '**'
pull_request:
branches:
- '**'
concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }}
cancel-in-progress: true
permissions:
id-token: write
contents: write
defaults:
run:
shell: bash
jobs:
build:
name: 👷 ${{ matrix.os.emoji }} ${{ matrix.preconfiguration.name }} ${{ matrix.os.name }} ${{ matrix.arch.name }}
runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }}
strategy:
fail-fast: false
matrix:
configuration:
- token-driver-artifact-ref: '' # Set to blank string for latest version. Use taga only - job artifacts are not accessible
python-version: [3.9]
os:
# TODO: use old versions for improved compatibility?
- name: Linux
matrix: linux
emoji: 🐧
runs-on:
arm: [Linux, ARM64]
intel: [ubuntu-latest]
electron-builder-options: --linux
electron-builder-unpacked: linux-unpacked
executable-extension: ''
build-result-pattern: '"climate-wallet"*".deb"'
artifact-name: linux
- name: macOS
matrix: macos
emoji: 🍎
runs-on:
arm: [macOS, ARM64]
intel: [macos-latest]
electron-builder-options: --macos
electron-builder-unpacked: mac
executable-extension: ''
build-result-pattern: '"Climate Wallet-"*".dmg"'
artifact-name: macos
- name: Windows
matrix: windows
emoji: 🪟
runs-on:
intel: [windows-latest]
electron-builder-options: --windows
electron-builder-unpacked: win-unpacked
executable-extension: '.exe'
build-result-pattern: '"Climate Wallet Setup "*".exe"'
artifact-name: windows
arch:
- name: ARM
matrix: arm
artifact-name: arm64
electron-builder-options: --arm64
- name: Intel
matrix: intel
artifact-name: x64
electron-builder-options: --x64
preconfiguration:
- name: default
cadt-api-server-host: 'https://observer.climateactiondata.org/api'
cadt-ui-host: 'https://observer.climateactiondata.org'
filename-string: ''
- name: testneta
cadt-api-server-host: 'https://chia-cadt-demo.chiamanaged.com/observer'
cadt-ui-host: 'https://chia-cadt-demo.chiamanaged.com/'
filename-string: '-testneta'
exclude:
- os:
matrix: windows
arch:
matrix: arm
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node 18.x
uses: actions/setup-node@v4
with:
node-version: '18'
- name: install dmg-license
if: matrix.os.matrix == 'macos'
run: |
npm install dmg-license
- name: Download Token Driver Client from release
env:
GH_TOKEN: ${{ secrets.GH_READ_REPOS }}
DESTINATION: extraResources/token-driver-client${{ matrix.os.executable-extension }}
shell: bash
run: |
# Figure out the version string to use
if [ -z ${{ matrix.configuration.token-driver-artifact-ref }} ]; then
echo "No version specified - getting latest version number from Github"
location_string=$(curl -sI https://github.com/Chia-Network/climate-token-driver/releases/latest | grep -i 'Location:' | tr -d '\r')
token_driver_version=$(echo "$location_string" | awk -F '/' '{print $NF}')
else
token_driver_version=${{ matrix.configuration.token-driver-artifact-ref }}
fi
echo "Token Driver version to download: ${token_driver_version}"
mkdir -p downloaded-artifacts
curl -L -o downloaded-artifacts/climate-token-driver${{ matrix.preconfiguration.filename-string }}_${{ matrix.os.matrix}}_${token_driver_version}_${{ matrix.arch.artifact-name }}.zip https://github.com/Chia-Network/climate-token-driver/releases/download/${token_driver_version}/climate-token-driver${{ matrix.preconfiguration.filename-string }}_${{ matrix.os.matrix}}_${token_driver_version}_${{ matrix.arch.artifact-name }}.zip
pushd downloaded-artifacts
unzip *.zip
rm -f *.zip
popd
mkdir -p extraResources/
mv downloaded-artifacts/* "${DESTINATION}"
chmod a+x "${DESTINATION}"
ls -la extraResources/ || true
- name: Prep .env file
run: |
cp .env.example .env
- name: Populate .env file for custom builds
run: |
perl -pi -e 's{CADT_API_SERVER_HOST=.*}{CADT_API_SERVER_HOST=${{ matrix.preconfiguration.cadt-api-server-host }}}g' .env
perl -pi -e 's{CADT_UI_HOST=.*}{CADT_UI_HOST=${{ matrix.preconfiguration.cadt-ui-host }}}g' .env
cat .env
if: matrix.preconfiguration.name != 'default'
- name: Test for secrets access
id: check_secrets
shell: bash
run: |
unset HAS_SIGNING_SECRET
if [ -n "$SIGNING_SECRET" ]; then HAS_SIGNING_SECRET='true' ; fi
echo "HAS_SIGNING_SECRET=${HAS_SIGNING_SECRET}" >> "$GITHUB_OUTPUT"
env:
SIGNING_SECRET: "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}"
- name: Change the package.json version if an RC tag
if: startsWith(github.ref, 'refs/tags/') && contains( github.ref, '-rc')
shell: bash
run: |
echo "Github ref: $GITHUB_REF"
IFS='/' read -r base directory tag <<< "$GITHUB_REF"
echo "Extracted tag is $tag"
jq ".version = \"${tag}\"" package.json > package.tmp
mv package.tmp package.json
- name: Import Apple installer signing certificate
if: matrix.os.matrix == 'macos' && steps.check_secrets.outputs.HAS_SIGNING_SECRET
uses: Apple-Actions/import-codesign-certs@v3
with:
p12-file-base64: ${{ secrets.APPLE_DEV_ID_APP }}
p12-password: ${{ secrets.APPLE_DEV_ID_APP_PASS }}
- name: Prepare for Linux ARM electron-builder
if: matrix.os.matrix == 'linux' && matrix.arch.matrix == 'arm'
run: |
# TODO: make this an action?
# https://github.com/Chia-Network/chia-blockchain/blob/9b8cdd36daebf2efe8777c98e212e564f4cdd475/build_scripts/build_linux_deb-2-installer.sh#L72
#
# Install Ruby Version Manager
gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm reload
# Install ruby3
rvm install ruby-3.2.1
rvm use ruby-3.2.1
ruby --version
gem install public_suffix -v 4.0.7
gem install fpm
echo "USE_SYSTEM_FPM=true" >> "${GITHUB_ENV}"
- name: Build electron app
if: (matrix.os.matrix == 'linux' && matrix.arch.matrix == 'intel') || matrix.os.matrix == 'windows'
run: |
npm install
npm run build
npm run package-none -- ${{ matrix.os.electron-builder-options }} ${{ matrix.arch.electron-builder-options }}
- name: Build electron app (Linux ARM)
if: matrix.os.matrix == 'linux' && matrix.arch.matrix == 'arm'
run: |
source ~/.rvm/scripts/rvm
npm install
npm run build
npm run package-none -- ${{ matrix.os.electron-builder-options }} ${{ matrix.arch.electron-builder-options }}
- name: Build electron app (macOS)
if: matrix.os.matrix == 'macos'
env:
# macos
CSC_FOR_PULL_REQUEST: 'true'
run: |
npm install
npm run build
npm run package-none -- ${{ matrix.os.electron-builder-options }} ${{ matrix.arch.electron-builder-options }}
- name: Copy to artifacts/
run: |
ls -la dist || true
mkdir -p artifacts/
cp -v dist/${{ matrix.os.build-result-pattern }} artifacts/
- name: Notarize
if: matrix.os.matrix == 'macos' && steps.check_secrets.outputs.HAS_SIGNING_SECRET
run: |
DMG_FILE=$(find ${{ github.workspace }}/artifacts/ -type f -name '*.dmg')
xcrun notarytool submit \
--wait \
--apple-id "${{ secrets.APPLE_NOTARIZE_USERNAME }}" \
--password "${{ secrets.APPLE_NOTARIZE_PASSWORD }}" \
--team-id "${{ secrets.APPLE_TEAM_ID }}" \
"$DMG_FILE"
# Windows Code Signing
- name: Get installer name for signing
if: matrix.os.matrix == 'windows'
shell: bash
run: |
FILE=$(find artifacts -type f -maxdepth 1 -name '*.exe')
echo "Installer file is $FILE"
echo "INSTALLER_FILE=$FILE" >> "$GITHUB_ENV"
- name: Sign windows artifacts
if: matrix.os.matrix == 'windows' && steps.check_secrets.outputs.HAS_SIGNING_SECRET
uses: chia-network/actions/digicert/windows-sign@main
with:
sm_api_key: ${{ secrets.SM_API_KEY }}
sm_client_cert_file_b64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}
sm_client_cert_password: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
sm_code_signing_cert_sha1_hash: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}
file: '${{ github.workspace }}/${{ env.INSTALLER_FILE }}'
# RC release should not be set as latest
- name: Decide if release should be set as latest
id: is_latest
shell: bash
run: |
unset IS_LATEST
echo "Github ref is $GITHUB_REF"
if [[ "$GITHUB_REF" =~ "-rc" ]]; then
echo "release candidate tag matched"
IS_LATEST='false'
IS_PRERELEASE='true'
else
echo "main branch release matched"
IS_LATEST='true'
IS_PRERELEASE='false'
fi
echo "IS_LATEST=${IS_LATEST}" >> "$GITHUB_OUTPUT"
echo "IS_PRERELEASE=${IS_PRERELEASE}" >> "$GITHUB_OUTPUT"
- name: Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
fail_on_unmatched_files: true
target_commitish: ${{ github.sha }}
prerelease: ${{steps.is_latest.outputs.IS_PRERELEASE}}
make_latest: "${{steps.is_latest.outputs.IS_LATEST}}"
if: startsWith(github.ref, 'refs/tags/')
# Create aritifacts so we have builds to test from pull requests
- name: Upload installer to artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os.artifact-name }}-${{ matrix.arch.artifact-name}}${{ matrix.preconfiguration.filename-string }}-installer
path: 'artifacts/*'
# We want to delete this no matter what happened in the previous steps (failures, success, etc)
- name: Delete signing keychain
if: always()
run: security delete-keychain signing_temp.keychain || true
release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && !contains( github.ref, '-rc')
needs:
- build
steps:
- name: Get repo name
id: repo-name
shell: bash
run: |
echo "REPO_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2)" >>$GITHUB_OUTPUT
- name: Get tag name
id: tag-name
shell: bash
run: |
echo "TAGNAME=$(echo $GITHUB_REF | cut -d / -f 3)" >>$GITHUB_OUTPUT
- name: Trigger apt repo update
uses: Chia-Network/actions/github/glue@main
with:
json_data: '{"climate_tokenization_repo":"${{ steps.repo-name.outputs.REPO_NAME }}","application_name":"[\"climate-wallet\"]","release_version":"${{ steps.tag-name.outputs.TAGNAME }}","add_debian_version":"false","arm64":"available"}'
glue_url: ${{ secrets.GLUE_API_URL }}
glue_project: 'climate-tokenization'
glue_path: 'trigger'