forked from Chia-Network/chia-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (216 loc) · 10.9 KB
/
build-windows-installer.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
name: Build Installer - Windows 10
on:
push:
branches:
- main
- 'release/**'
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
jobs:
build:
name: Windows 10 Installer
runs-on: [windows-2019]
timeout-minutes: 50
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Set git urls to https instead of ssh
run: |
git config --global url."https://github.com/".insteadOf ssh://[email protected]/
- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache npm
uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
# We can't upgrade to Python 3.8 until we have a miniupnpc binary
- uses: actions/setup-python@v2
name: Install Python 3.9
with:
python-version: "3.9"
- name: Setup Node 16.x
uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: Test for secrets access
id: check_secrets
shell: bash
run: |
unset HAS_SIGNING_SECRET
unset HAS_AWS_SECRET
if [ -n "$SIGNING_SECRET" ]; then HAS_SIGNING_SECRET='true' ; fi
echo "::set-output name=HAS_SIGNING_SECRET::${HAS_SIGNING_SECRET}"
if [ -n "$AWS_SECRET" ]; then HAS_AWS_SECRET='true' ; fi
echo ::set-output name=HAS_AWS_SECRET::${HAS_AWS_SECRET}
env:
SIGNING_SECRET: "${{ secrets.WIN_CODE_SIGN_CERT }}"
AWS_SECRET: "${{ secrets.INSTALLER_UPLOAD_KEY }}"
- name: Decode code signing cert into an encrypted file
if: steps.check_secrets.outputs.HAS_SIGNING_SECRET
uses: kitek/[email protected]
with:
encoded-value: ${{ secrets.WIN_CODE_SIGN_CERT }}
destination-file: .\chia-blockchain-gui\win_code_sign_cert.p12
# Create our own venv outside of the git directory JUST for getting the ACTUAL version so that install can't break it
- name: Get version number
id: version_number
run: |
python -m venv ..\venv
. ..\venv\Scripts\Activate.ps1
pip3 install setuptools_scm
$env:CHIA_INSTALLER_VERSION = python .\build_scripts\installer-version.py -win
echo "$env:CHIA_INSTALLER_VERSION"
echo "::set-output name=CHIA_INSTALLER_VERSION::$env:CHIA_INSTALLER_VERSION"
deactivate
# Get the most recent release from chia-plotter-madmax
- uses: actions/github-script@v6
id: 'latest-madmax'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const release = await github.rest.repos.getLatestRelease({
owner: 'Chia-Network',
repo: 'chia-plotter-madmax',
});
return release.data.tag_name;
- name: Get latest madmax plotter
run: |
mkdir "$env:GITHUB_WORKSPACE\madmax"
Invoke-WebRequest https://github.com/Chia-Network/chia-plotter-madmax/releases/download/${{ steps.latest-madmax.outputs.result }}/chia_plot-${{ steps.latest-madmax.outputs.result }}.exe -OutFile "$env:GITHUB_WORKSPACE\madmax\chia_plot.exe"
Invoke-WebRequest https://github.com/Chia-Network/chia-plotter-madmax/releases/download/${{ steps.latest-madmax.outputs.result }}/chia_plot_k34-${{ steps.latest-madmax.outputs.result }}.exe -OutFile "$env:GITHUB_WORKSPACE\madmax\chia_plot_k34.exe"
# Get the most recent release from bladebit
- uses: actions/github-script@v6
id: 'latest-bladebit'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const release = await github.rest.repos.getLatestRelease({
owner: 'Chia-Network',
repo: 'bladebit',
});
return release.data.tag_name;
- name: Get latest bladebit plotter
run: |
mkdir "$env:GITHUB_WORKSPACE\bladebit"
Invoke-WebRequest https://github.com/Chia-Network/bladebit/releases/download/${{ steps.latest-bladebit.outputs.result }}/bladebit-${{ steps.latest-bladebit.outputs.result }}-windows-x86-64.zip -OutFile "$env:GITHUB_WORKSPACE\bladebit\bladebit.zip"
Expand-Archive -Path "$env:GITHUB_WORKSPACE\bladebit\bladebit.zip" -DestinationPath "$env:GITHUB_WORKSPACE\bladebit\"
rm "$env:GITHUB_WORKSPACE\bladebit\bladebit.zip"
- name: Build Windows installer with build_scripts\build_windows.ps1
env:
CHIA_INSTALLER_VERSION: ${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}
WIN_CODE_SIGN_PASS: ${{ secrets.WIN_CODE_SIGN_PASS }}
HAS_SECRET: ${{ steps.check_secrets.outputs.HAS_SIGNING_SECRET }}
run: |
$env:path="C:\Program` Files` (x86)\Microsoft` Visual` Studio\2019\Enterprise\SDK\ScopeCppSDK\vc15\VC\bin\;$env:path"
$env:path="C:\Program` Files` (x86)\Windows` Kits\10\App` Certification` Kit;$env:path"
git -C .\chia-blockchain-gui status
.\build_scripts\build_windows.ps1
- name: Upload Windows exe's to artifacts
uses: actions/upload-artifact@v3
with:
name: chia-installers-windows-exe-intel
path: ${{ github.workspace }}\chia-blockchain-gui\Chia-win32-x64\
- name: Upload Installer to artifacts
uses: actions/upload-artifact@v3
with:
name: Windows-Installers
path: ${{ github.workspace }}\chia-blockchain-gui\release-builds\
- name: Install AWS CLI
if: steps.check_secrets.outputs.HAS_AWS_SECRET
run: |
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
- name: Configure AWS Credentials
if: steps.check_secrets.outputs.HAS_AWS_SECRET
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.INSTALLER_UPLOAD_KEY }}
aws-secret-access-key: ${{ secrets.INSTALLER_UPLOAD_SECRET }}
aws-region: us-west-2
- name: Upload to s3
if: steps.check_secrets.outputs.HAS_AWS_SECRET
env:
CHIA_INSTALLER_VERSION: ${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}
shell: bash
run: |
GIT_SHORT_HASH=$(echo "${GITHUB_SHA}" | cut -c1-8)
CHIA_DEV_BUILD=${CHIA_INSTALLER_VERSION}-$GIT_SHORT_HASH
echo ::set-output name=CHIA_DEV_BUILD::${CHIA_DEV_BUILD}
echo ${CHIA_DEV_BUILD}
pwd
aws s3 cp chia-blockchain-gui/release-builds/windows-installer/ChiaSetup-${CHIA_INSTALLER_VERSION}.exe s3://download.chia.net/dev/ChiaSetup-${CHIA_DEV_BUILD}.exe
- name: Create Checksums
env:
CHIA_INSTALLER_VERSION: ${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}
run: |
certutil.exe -hashfile ${{ github.workspace }}\chia-blockchain-gui\release-builds\windows-installer\ChiaSetup-${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}.exe SHA256 > ${{ github.workspace }}\chia-blockchain-gui\release-builds\windows-installer\ChiaSetup-${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}.exe.sha256
ls ${{ github.workspace }}\chia-blockchain-gui\release-builds\windows-installer\
- name: Install py3createtorrent
if: startsWith(github.ref, 'refs/tags/')
run: |
pip3 install py3createtorrent
- name: Create torrent
if: startsWith(github.ref, 'refs/tags/')
run: |
py3createtorrent -f -t udp://tracker.opentrackr.org:1337/announce ${{ github.workspace }}\chia-blockchain-gui\release-builds\windows-installer\ChiaSetup-${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}.exe -o ${{ github.workspace }}\chia-blockchain-gui\release-builds\windows-installer\ChiaSetup-${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}.exe.torrent --webseed https://download.chia.net/install/ChiaSetup-${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}.exe
ls
- name: Upload Beta Installer
if: steps.check_secrets.outputs.HAS_AWS_SECRET && github.ref == 'refs/heads/main'
env:
CHIA_INSTALLER_VERSION: ${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}
run: |
aws s3 cp ${{ github.workspace }}\chia-blockchain-gui\release-builds\windows-installer\ChiaSetup-${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}.exe s3://download.chia.net/beta/ChiaSetup-latest-beta.exe
aws s3 cp ${{ github.workspace }}\chia-blockchain-gui\release-builds\windows-installer\ChiaSetup-${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}.exe.sha256 s3://download.chia.net/beta/ChiaSetup-latest-beta.exe.sha256
- name: Upload Release Files
if: steps.check_secrets.outputs.HAS_AWS_SECRET && startsWith(github.ref, 'refs/tags/')
env:
AWS_ACCESS_KEY_ID: ${{ secrets.INSTALLER_UPLOAD_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.INSTALLER_UPLOAD_SECRET }}
run: |
aws s3 cp ${{ github.workspace }}\chia-blockchain-gui\release-builds\windows-installer\ChiaSetup-${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}.exe s3://download.chia.net/install/
aws s3 cp ${{ github.workspace }}\chia-blockchain-gui\release-builds\windows-installer\ChiaSetup-${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}.exe.sha256 s3://download.chia.net/install/
aws s3 cp ${{ github.workspace }}\chia-blockchain-gui\release-builds\windows-installer\ChiaSetup-${{ steps.version_number.outputs.CHIA_INSTALLER_VERSION }}.exe.torrent s3://download.chia.net/torrents/
- name: Get tag name
if: startsWith(github.ref, 'refs/tags/')
id: tag-name
run: |
echo "::set-output name=TAG_NAME::$(echo ${{ github.ref }} | cut -d'/' -f 3)"
echo "::set-output name=REPO_NAME::$(echo ${{ github.repository }} | cut -d'/' -f 2)"
- name: Mark installer complete
if: startsWith(github.ref, 'refs/tags/')
run: |
$headers = @{
Authorization="Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}"
}
$data = @{
chia_ref='${{ steps.tag-name.outputs.TAG_NAME }}'
}
$json = $data | ConvertTo-Json
$response = Invoke-RestMethod '${{ secrets.GLUE_API_URL }}/api/v1/${{ steps.tag-name.outputs.REPO_NAME }}/${{ steps.tag-name.outputs.TAG_NAME }}/success/build-windows' -Method Post -Body $json -ContentType 'application/json' -Headers $headers