-
Notifications
You must be signed in to change notification settings - Fork 3
328 lines (292 loc) · 13.5 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
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: [Linux, ARM64]
intel: [ubuntu-latest]
artifact-os-name: linux
executable-extension: ''
- name: macOS
matrix: macos
emoji: 🍎
runs-on:
arm: [macOS, ARM64]
intel: [macos-latest]
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
cadt-api-server-host: 'https://observer.climateactiondata.org/api'
- name: 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@v3
with:
submodules: 'recursive'
- name: Setup Python
uses: Chia-Network/actions/setup-python@main
with:
python-version: '3.10'
- name: Create .env file
run: |
echo "MODE=${{ matrix.config.app-mode }}" > .env
echo 'CHIA_ROOT="~/.chia/mainnet"' >> .env
echo 'CONFIG_PATH="climate_token/config/config.yaml"' >> .env
- name: Apply preconfigurations
if: matrix.preconfiguration.name != 'default'
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: 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 }}
- 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 j2
run: |
pip install j2cli
- 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 }}_${{ steps.tag-name.outputs.TAGNAME || github.sha }}_${{ matrix.arch.artifact-name }}${{ matrix.os.executable-extension }}
# Windows Code Signing
- name: Sign windows artifacts
if: matrix.os.matrix == 'windows'
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 }}_${{ 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 }}_${{ 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
j2 -o "deb/$DEB_BASE/DEBIAN/control" build-scripts/deb/control.j2
j2 -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@v3
with:
name: ${{ matrix.config.app-name }}_${{ 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' && matrix.preconfiguration.name == 'default'
- name: Upload preconfigured deb
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.config.app-name }}-${{ matrix.preconfiguration.name }}_${{ 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' && matrix.preconfiguration.name != 'default'
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.config.app-name }}-${{ matrix.os.artifact-os-name }}-${{ matrix.arch.artifact-name }}
path: ${{ github.workspace }}/artifacts/*
if-no-files-found: error
if: matrix.preconfiguration.name == 'default'
- name: Upload preconfigured binary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.config.app-name }}-${{ matrix.preconfiguration.name }}-${{ matrix.os.artifact-os-name }}-${{ matrix.arch.artifact-name }}
path: ${{ github.workspace }}/artifacts/*
if-no-files-found: error
if: matrix.preconfiguration.name != 'default'
- name: Create zip files for release
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: ${{ matrix.config.app-name }}_${{ 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/') && matrix.preconfiguration.name == 'default'
- name: Release executable
uses: softprops/[email protected]
with:
files: ./artifacts/${{ matrix.config.app-name }}_${{ matrix.os.artifact-os-name }}_${{ steps.tag-name.outputs.TAGNAME || github.sha }}_${{ matrix.arch.artifact-name }}.zip
if: startsWith(github.ref, 'refs/tags/') && matrix.preconfiguration.name == 'default'
- name: Release debs
uses: softprops/[email protected]
with:
files: |
${{ github.workspace }}/deb/${{ matrix.config.app-name }}_${{ steps.tag-name.outputs.TAGNAME || github.sha }}-1_${{ matrix.arch.deb-platform }}.deb
if: startsWith(github.ref, 'refs/tags/') && matrix.os.matrix == 'linux' && matrix.preconfiguration.name == 'default'
# 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
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@v3
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
if: startsWith(github.ref, 'refs/tags/')
- 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: Download all artifacts
uses: actions/download-artifact@v3
- name: Parse meta files for apt variables
id: apt-metadata
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: Gets JWT Token from GitHub
uses: Chia-Network/actions/github/jwt@main
- name: Trigger apt repo update
run: |
curl -s -XPOST -H "Authorization: Bearer ${{ env.JWT_TOKEN }}" --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"}' ${{ secrets.GLUE_API_URL }}/api/v1/climate-tokenization/${{ github.sha }}/start
curl -s -XPOST -H "Authorization: Bearer ${{ env.JWT_TOKEN }}" --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"}' ${{ secrets.GLUE_API_URL }}/api/v1/climate-tokenization/${{ github.sha }}/success/deploy
if: startsWith(github.ref, 'refs/tags/')