-
Notifications
You must be signed in to change notification settings - Fork 3
382 lines (339 loc) · 14.8 KB
/
build-installers.yaml
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
name: Build & Release
on:
push:
branches:
- stage
tags:
- "**"
pull_request:
branches:
- "**"
workflow_dispatch: {}
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
jobs:
build:
name: 👷 ${{ matrix.config.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:
config:
- name: tokenization
app-name: climate-tokenization-chia
app-mode: registry
app-description: "Carbon tokenization application on the Chia blockchain"
add-to-apt: "true"
- name: explorer
app-name: climate-explorer-chia
app-mode: explorer
app-description: "Interface for tracking Chia on-chain carbon tokens"
add-to-apt: "true"
- name: client
app-name: climate-token-driver
app-mode: client
app-description: "Embedded climate token driver for carbon tokens on the Chia blockchain"
add-to-apt: "false"
- name: dev
app-name: dev-token-driver-chia
app-mode: dev
app-description: "Token driver in dev mode"
add-to-apt: "false"
os:
- name: Linux
matrix: linux
emoji: 🐧
runs-on:
arm: [ubuntu-22.04-arm]
intel: [ubuntu-latest]
artifact-os-name: linux
executable-extension: ""
- name: macOS
matrix: macos
emoji: 🍎
runs-on:
arm: [macos-13-arm64]
intel: [macos-13]
artifact-os-name: macos
executable-extension: ""
- name: Windows
matrix: windows
emoji: 🪟
runs-on:
intel: [windows-latest]
artifact-os-name: windows
executable-extension: ".exe"
arch:
- name: ARM
matrix: arm
artifact-name: arm64
deb-platform: arm64
electron-builder-options: --arm64
- name: Intel
matrix: intel
artifact-name: x64
deb-platform: amd64
electron-builder-options: --x64
preconfiguration:
- name: default
installer-string: ""
cadt-api-server-host: "https://observer.climateactiondata.org/api"
- name: testneta
installer-string: "-testneta"
cadt-api-server-host: "https://chia-cadt-demo.chiamanaged.com/observer"
exclude:
- os:
matrix: windows
arch:
matrix: arm
- config:
app-mode: registry
preconfiguration:
name: testneta
- config:
app-mode: explorer
preconfiguration:
name: testneta
- config:
app-mode: dev
preconfiguration:
name: testneta
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Setup Python
uses: Chia-Network/actions/setup-python@main
with:
python-version: "3.10"
- name: Create .env file
shell: bash
run: |
echo "MODE=${{ matrix.config.app-mode }}" > .env
echo 'CHIA_ROOT="~/.chia/mainnet"' >> .env
echo 'CONFIG_PATH="climate_token/config/config.yaml"' >> .env
echo 'SERVER_PORT=31999' >> .env
- name: Apply preconfigurations
if: matrix.preconfiguration.name != 'default'
shell: bash
run: |
perl -pi -e 's{CADT_API_SERVER_HOST:\ str\ =.*}{CADT_API_SERVER_HOST:\ str\ =\ \"${{ matrix.preconfiguration.cadt-api-server-host }}\"}g' app/config.py
perl -pi -e 's{CADT_API_SERVER_HOST:.*}{CADT_API_SERVER_HOST:\ \"${{ matrix.preconfiguration.cadt-api-server-host }}\"}g' config.yaml
cat config.yaml
- name: Install yq
if: startsWith(github.ref, 'refs/tags/') && contains( github.ref, '-rc')
run: pip install yq
- name: Change the pyproject.toml 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"
cat pyproject.toml | tomlq --toml-output ".tool.poetry.version=\"${tag}\"" > pyproject.tmp
mv pyproject.tmp pyproject.toml
- name: Create virtual environment
uses: Chia-Network/actions/create-venv@main
id: create-venv
- name: Activate virtual environment
uses: Chia-Network/actions/activate-venv@main
with:
directories: ${{ steps.create-venv.outputs.activate-venv-directories }}
- name: Install pyinstaller
run: pip install pyinstaller
- name: Create virtual environment for Poetry
uses: Chia-Network/actions/create-venv@main
id: create-poetry-venv
- name: Run poetry install
uses: Chia-Network/actions/poetry@main
with:
python-executable: ${{ steps.create-poetry-venv.outputs.python_executable }}
poetry-version: "1.8.5"
- name: Run pyinstaller
run: python -m PyInstaller --clean pyinstaller.spec
- name: Get tag name
id: tag-name
shell: bash
run: |
TAGNAME=$(echo $GITHUB_REF | cut -d / -f 3)
echo "TAGNAME=${TAGNAME}" >> $GITHUB_OUTPUT
echo "Tag is ${TAGNAME}"
echo "github.sha is ${{ github.sha }}"
- name: Install jinjanator
run: |
pip install jinjanator
- name: Rename binary
run: |
# no -p, we want to be sure this is clean so wildcards below don't get extra files
mkdir artifacts/
cp ./dist/main${{ matrix.os.executable-extension }} ./artifacts/${{ matrix.config.app-name }}${{ matrix.preconfiguration.installer-string }}_${{ steps.tag-name.outputs.TAGNAME || github.sha }}_${{ matrix.arch.artifact-name }}${{ matrix.os.executable-extension }}
- 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 }}"
# Windows Code Signing
- name: Sign windows artifacts
if: matrix.os.matrix == 'windows' && steps.check_secrets.outputs.HAS_SIGNING_SECRET
uses: chia-network/actions/digicert/windows-sign@main
env:
SM_TOOLS_DOWNLOAD_URL: ${{ vars.SM_TOOLS_DOWNLOAD_URL }}
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: ./artifacts/${{ matrix.config.app-name }}${{ matrix.preconfiguration.installer-string }}_${{ steps.tag-name.outputs.TAGNAME || github.sha }}_${{ matrix.arch.artifact-name }}.exe
- name: Create .deb Package
env:
APP_NAME: ${{ matrix.config.app-name }}
APP_VERSION: ${{ steps.tag-name.outputs.TAGNAME }}
PLATFORM: ${{ matrix.arch.deb-platform }}
APP_DESCRIPTION: ${{ matrix.config.app-description }}
run: |
DEB_BASE="${{ matrix.config.app-name }}${{ matrix.preconfiguration.installer-string }}_${{ steps.tag-name.outputs.TAGNAME || github.sha }}-1_${{ matrix.arch.deb-platform }}"
mkdir -p deb/$DEB_BASE/opt/${{ matrix.config.app-name }}
cp dist/main deb/$DEB_BASE/opt/${{ matrix.config.app-name }}/${{ matrix.config.app-name }}
chmod +x deb/$DEB_BASE/opt/${{ matrix.config.app-name }}/${{ matrix.config.app-name }}
mkdir -p deb/$DEB_BASE/DEBIAN
mkdir -p "deb/$DEB_BASE/etc/systemd/system"
mkdir -p deb/$DEB_BASE/usr/local/bin
jinjanate -o "deb/$DEB_BASE/DEBIAN/control" build-scripts/deb/control.j2
jinjanate -o "deb/$DEB_BASE/etc/systemd/system/${{ matrix.config.app-name }}@.service" build-scripts/deb/[email protected]
ln -s ../../../opt/${{ matrix.config.app-name }}/${{ matrix.config.app-name }} deb/$DEB_BASE/usr/local/bin/${{ matrix.config.app-name }}
dpkg-deb --build --root-owner-group "deb/$DEB_BASE"
if: matrix.os.matrix == 'linux'
- name: Upload deb
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.app-name }}${{ matrix.preconfiguration.installer-string }}_${{ steps.tag-name.outputs.TAGNAME || github.sha }}-1_${{ matrix.arch.deb-platform }}.deb
path: ${{ github.workspace }}/deb/*.deb
if-no-files-found: error
if: matrix.os.matrix == 'linux'
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.app-name }}${{ matrix.preconfiguration.installer-string }}-${{ matrix.os.artifact-os-name }}-${{ matrix.arch.artifact-name }}
path: ${{ github.workspace }}/artifacts/*
if-no-files-found: error
- name: Create zip files for release
uses: thedoctor0/[email protected]
with:
type: "zip"
filename: ${{ matrix.config.app-name }}${{ matrix.preconfiguration.installer-string }}_${{ matrix.os.artifact-os-name }}_${{ steps.tag-name.outputs.TAGNAME || github.sha }}_${{ matrix.arch.artifact-name }}.zip
directory: "artifacts"
if: startsWith(github.ref, 'refs/tags/')
# 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 executable
uses: softprops/action-gh-release@v2
with:
prerelease: ${{steps.is_latest.outputs.IS_PRERELEASE}}
make_latest: "${{steps.is_latest.outputs.IS_LATEST}}"
files: ./artifacts/${{ matrix.config.app-name }}${{ matrix.preconfiguration.installer-string }}_${{ matrix.os.artifact-os-name }}_${{ steps.tag-name.outputs.TAGNAME || github.sha }}_${{ matrix.arch.artifact-name }}.zip
if: startsWith(github.ref, 'refs/tags/')
- name: Release debs
uses: softprops/action-gh-release@v2
with:
prerelease: ${{steps.is_latest.outputs.IS_PRERELEASE}}
make_latest: "${{steps.is_latest.outputs.IS_LATEST}}"
files: |
${{ github.workspace }}/deb/${{ matrix.config.app-name }}${{ matrix.preconfiguration.installer-string }}_${{ steps.tag-name.outputs.TAGNAME || github.sha }}-1_${{ matrix.arch.deb-platform }}.deb
if: startsWith(github.ref, 'refs/tags/') && matrix.os.matrix == 'linux'
# Only do for Intel builds as we know we build ARM and can pass that info along to the apt update automation
- name: Create artifact with metadata for apt upload
shell: bash
run: |
echo "${{ matrix.config.app-name }}" > APTDATA_${{ matrix.config.app-name }}.dat
if: startsWith(github.ref, 'refs/tags/') && matrix.os.matrix == 'linux' && matrix.config.add-to-apt == 'true' && matrix.arch.name == 'Intel' && matrix.preconfiguration.name == 'default'
- name: Upload artifact to pass apt data to release job
uses: actions/upload-artifact@v4
with:
name: APTDATA_${{ matrix.config.app-name }}
path: APTDATA_${{ matrix.config.app-name }}.dat
if-no-files-found: error
retention-days: 1
if: startsWith(github.ref, 'refs/tags/') && matrix.os.matrix == 'linux' && matrix.config.add-to-apt == 'true' && matrix.arch.name == 'Intel' && matrix.preconfiguration.name == 'default'
apt-upload:
name: Trigger update in apt repo
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
steps:
- name: Get repo name to use for APT trigger
id: repo-name
run: |
echo "REPO_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2)" >>$GITHUB_OUTPUT
- name: Get tag name
id: tag-name
shell: bash
run: |
TAGNAME=$(echo $GITHUB_REF | cut -d / -f 3)
echo "TAGNAME=${TAGNAME}" >> $GITHUB_OUTPUT
echo "Tag is ${TAGNAME}"
echo "github.sha is ${{ github.sha }}"
- name: Get glue project
id: glue-project
shell: bash
run: |
if [[ "$GITHUB_REF" =~ "-rc" ]]; then
echo "release candidate tag matched"
GLUE_PROJECT='climate-tokenization-test'
else
echo "main branch release matched"
GLUE_PROJECT='climate-tokenization-test'
fi
echo "GLUE_PROJECT=${GLUE_PROJECT}" >> "$GITHUB_OUTPUT"
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Parse meta files for apt variables
id: apt-metadata
shell: bash
run: |
APPS_ARRAY="["
DIRECTORIES="./APTDATA*"
for d in $DIRECTORIES; do \
FILES="$d/*.dat"; \
for f in $FILES; do \
APP=`cat $f`; \
APPS_ARRAY="${APPS_ARRAY}\\\"${APP}\\\", "; \
done; \
done;
APPS_ARRAY=${APPS_ARRAY%??}
APPS_ARRAY="${APPS_ARRAY}]"
echo "Array being passed is ${APPS_ARRAY}"
echo "APPLICATIONS=${APPS_ARRAY}" >> $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":"${{ steps.apt-metadata.outputs.APPLICATIONS }}","release_version":"${{ steps.tag-name.outputs.TAGNAME }}","add_debian_version":"true","arm64":"available"}'
glue_url: ${{ secrets.GLUE_API_URL }}
glue_project: "${{steps.glue-project.outputs.GLUE_PROJECT}}"
glue_path: "trigger"