forked from tari-project/tari
-
Notifications
You must be signed in to change notification settings - Fork 0
331 lines (301 loc) · 13.4 KB
/
base_node_binaries.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
name: Build Matrix of Binaries
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
branches:
- build-*
schedule:
- cron: "05 00 * * *"
workflow_dispatch:
inputs:
customTag:
description: "Development Tag"
required: true
default: "development-tag"
env:
TBN_FILENAME: "tari_base_node"
jobs:
builds:
name: Build and deploy tari_base_node
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, macos-10.15, windows-2019]
# https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
target_cpu: ["x86-64"]
# https://github.com/zkcrypto/curve25519-dalek-ng/pull/14
# target_cpu: ["haswell"]
# exclude:
# - os: "macos-10.15"
# target_cpu: "haswell"
# include:
# - os: "macos-10.15"
# target_cpu: "x86-64"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Declare Global Variables 4 GHA ${{ github.event_name }}
id: vars
shell: bash
run: |
echo "VBRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
echo "VSHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "CARGO_HTTP_MULTIPLEXING=false" >> $GITHUB_ENV
- name: Default Destination Folder
run: |
echo "S3DESTOVERRIDE=" >> $GITHUB_ENV
- name: Scheduled Destination Folder Override
if: ${{ github.event_name == 'schedule' && github.event.schedule == '05 00 01 * *' }}
run: |
echo "S3DESTOVERRIDE=daily/" >> $GITHUB_ENV
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-09-18
components: rustfmt
override: true
- name: Install Linux dependencies - Ubuntu
if: startsWith(runner.os,'Linux')
run: |
sudo apt-get update
sudo apt-get -y install \
openssl \
libssl-dev \
pkg-config \
libsqlite3-dev \
clang-10 \
git \
cmake \
libc++-dev \
libc++abi-dev \
libprotobuf-dev \
protobuf-compiler \
libncurses5-dev \
libncursesw5-dev \
zip
# sudo apt-get -y upgrade
- name: Install macOS dependencies
if: startsWith(runner.os,'macOS')
run: brew install cmake zip coreutils
- name: Install Windows dependencies
if: startsWith(runner.os,'Windows')
run: |
vcpkg.exe install sqlite3:x64-windows zlib:x64-windows
choco upgrade llvm zip psutils openssl strawberryperl -y
- name: Set environment variables - Nix
if: "!startsWith(runner.os,'Windows')"
run: |
echo "SHARUN=shasum --algorithm 256" >> $GITHUB_ENV
echo "CC=gcc" >> $GITHUB_ENV
echo "TBN_EXT=" >> $GITHUB_ENV
echo "S3DESTDIR=linux" >> $GITHUB_ENV
echo "TBN_DIST=/dist" >> $GITHUB_ENV
- name: Set environment variables - macOS
if: startsWith(runner.os,'macOS')
run: |
echo "S3DESTDIR=osx" >> $GITHUB_ENV
- name: Set environment variables - Windows
if: startsWith(runner.os,'Windows')
shell: bash
run: |
echo "SHARUN=pwsh C:\ProgramData\chocolatey\lib\psutils\tools\psutils-master\shasum.ps1 --algorithm 256" >> $GITHUB_ENV
echo "TBN_EXT=.exe" >> $GITHUB_ENV
echo "TBN_DIST=\dist" >> $GITHUB_ENV
echo "S3DESTDIR=windows" >> $GITHUB_ENV
echo "SQLITE3_LIB_DIR=C:\vcpkg\installed\x64-windows\lib" >> $GITHUB_ENV
echo "OPENSSL_DIR=C:\Program Files\OpenSSL-Win64" >> $GITHUB_ENV
echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" >> $GITHUB_ENV
echo "C:\Strawberry\perl\bin" >> $GITHUB_PATH
- name: Caching
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.os }}-${{ matrix.target_cpu }}-${{ matrix.features }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Build binaries
env:
RUSTFLAGS: "-C target_cpu=${{ matrix.target_cpu }}"
ROARING_ARCH: "${{ matrix.target_cpu }}"
run: |
echo "Cache Key: ${{ runner.os }}-${{ matrix.os }}-${{ matrix.target_cpu }}-${{ matrix.features }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}"
#cd applications/tari_base_node
#cargo build --release --bin tari_base_node --features ${{ matrix.features}}
cargo build --release
# - name: Prepare Archives
# shell: bash
# run: |
# ls -la "$GITHUB_WORKSPACE"
# mkdir -p "$GITHUB_WORKSPACE${TBN_DIST}/archives"
# export distDir="$GITHUB_WORKSPACE${TBN_DIST}/archives"
# "$GITHUB_WORKSPACE/scripts/build_dists_tarball.sh" noBuild
- name: Prepare binaries
shell: bash
run: |
mkdir -p "$GITHUB_WORKSPACE${TBN_DIST}"
cd "$GITHUB_WORKSPACE${TBN_DIST}"
VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/[\"]/, "", $2); printf("%s",$2) }' "$GITHUB_WORKSPACE/applications/tari_base_node/Cargo.toml")
echo "Branch: ${VBRANCH}"
echo "Sha: ${VSHA_SHORT}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VSHA_SHORT=${VSHA_SHORT}" >> $GITHUB_ENV
#BINFILE="${TBN_FILENAME}-${VERSION}-${VSHA_SHORT}-${{ matrix.os }}-${{ matrix.target_cpu }}-${{ matrix.features }}${TBN_EXT}"
BINFILE="${TBN_FILENAME}-${VERSION}-${VSHA_SHORT}-${{ matrix.os }}-${{ matrix.target_cpu }}${TBN_EXT}"
echo "BINFILE=${BINFILE}" >> $GITHUB_ENV
echo "Copying files for ${BINFILE} to $(pwd)"
#cp -v "$GITHUB_WORKSPACE/target/release/${TBN_FILENAME}${TBN_EXT}" "./${BINFILE}"
ls -la "$GITHUB_WORKSPACE/target/release/"
cp -v "$GITHUB_WORKSPACE/target/release/tari_base_node${TBN_EXT}" .
cp -v "$GITHUB_WORKSPACE/target/release/tari_console_wallet${TBN_EXT}" .
cp -v "$GITHUB_WORKSPACE/target/release/tari_merge_mining_proxy${TBN_EXT}" .
cp -v "$GITHUB_WORKSPACE/target/release/tari_mining_node${TBN_EXT}" .
- name: Build the macos pkg
if: startsWith(runner.os,'macOS')
env:
MACOS_KEYCHAIN_PASS: ${{ secrets.MACOS_KEYCHAIN_PASS }}
MACOS_APPLICATION_CERT: ${{ secrets.MACOS_APPLICATION_CERT }}
MACOS_APPLICATION_PASS: ${{ secrets.MACOS_APPLICATION_PASS }}
MACOS_INSTALLER_CERT: ${{ secrets.MACOS_INSTALLER_CERT }}
MACOS_INSTALLER_PASS: ${{ secrets.MACOS_INSTALLER_PASS }}
run: |
echo $MACOS_APPLICATION_CERT | base64 --decode > application.p12
echo $MACOS_INSTALLER_CERT | base64 --decode > installer.p12
security create-keychain -p $MACOS_KEYCHAIN_PASS build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p $MACOS_KEYCHAIN_PASS build.keychain
security import application.p12 -k build.keychain -P $MACOS_APPLICATION_PASS -T /usr/bin/codesign
security import installer.p12 -k build.keychain -P $MACOS_INSTALLER_PASS -T /usr/bin/pkgbuild
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $MACOS_KEYCHAIN_PASS build.keychain
cd buildtools
./create_osx_install_zip.sh unused nozip
FILES=("tari_base_node" "tari_console_wallet" "tari_mining_node" "tari_merge_mining_proxy")
for FILE in "${FILES[@]}"; do
codesign --force -s "Developer ID Application: Tari Labs, LLC (8XGMD9X2H2)" "/tmp/tari_testnet/runtime/$FILE" -v
codesign --verify --deep --display --verbose=4 "/tmp/tari_testnet/runtime/$FILE"
done
pkgbuild --root /tmp/tari_testnet \
--identifier "com.tarilabs.pkg" \
--version "$VERSION" \
--install-location "/tmp/tari" \
--scripts "/tmp/tari_testnet/scripts" \
--sign "Developer ID Installer: Tari Labs, LLC (8XGMD9X2H2)" \
"${{ github.workspace }}${{ env.TBN_DIST }}/tari-${{ env.VERSION }}.pkg"
- name: Artifact macos pkg
if: startsWith(runner.os,'macOS')
uses: actions/upload-artifact@v2
with:
name: tari-${{ env.VERSION }}.pkg
path: "${{ github.workspace }}${{ env.TBN_DIST }}/tari-${{ env.VERSION }}.pkg"
# unlike inno script studio, iscc.exe doesn't run the [precompile] step generate_config.bat
- name: Build the windows installer
shell: cmd
if: startsWith(runner.os,'Windows')
run: |
cd buildtools
call generate_config.bat
"%programfiles(x86)%\Inno Setup 6\iscc.exe" "/DMyAppVersion=${{ env.VERSION }}-${{ env.VSHA_SHORT }}-release" "windows_inno_installer.iss"
- name: Upload artifact for Windows installer
uses: actions/upload-artifact@v2
if: startsWith(runner.os,'Windows')
with:
name: "tari_windows_installer"
path: "${{ github.workspace }}/buildtools/Output/*"
- name: Archive and Sign Binaries
shell: bash
run: |
echo "Archive ${{ env.BINFILE }} too ${{ env.BINFILE }}.zip"
cd "$GITHUB_WORKSPACE${{ env.TBN_DIST }}"
#zip -j "${{ env.BINFILE }}.zip" "${{ env.BINFILE }}"
zip -j "${{ env.BINFILE }}.zip" *
echo "Compute shasum"
${SHARUN} "${{ env.BINFILE }}.zip" >> "${{ env.BINFILE }}.zip.sha256"
cat "${{ env.BINFILE }}.zip.sha256"
echo "Verifications is "
${SHARUN} --check "${{ env.BINFILE }}.zip.sha256"
#rm -f "${BINFILE}"
- name: Artifact archive
uses: actions/upload-artifact@v2
with:
#name: ${{ env.TBN_FILENAME }}-${{ env.VERSION }}-${{ env.VSHA_SHORT }}-${{ matrix.os }}-${{ matrix.target_cpu }}-${{ matrix.features }}
name: tari_binary_archive-${{ matrix.os }}-${{ matrix.target_cpu }}
path: "${{ github.workspace }}${{ env.TBN_DIST }}/${{ env.BINFILE }}.zip*"
- name: Artifact miner
uses: actions/upload-artifact@v2
with:
name: tari_mining_node-${{ matrix.os }}-${{ matrix.target_cpu }}
path: "${{ github.workspace }}${{ env.TBN_DIST }}/tari_mining_node${{ env.TBN_EXT}}"
- name: Sync dist to S3 - Bash
continue-on-error: true # Don't break if s3 upload fails
if: ${{ env.AWS_SECRET_ACCESS_KEY != '' && matrix.os != 'self-hosted' }}
shell: bash
run: |
echo "Starting upload ... ${{ env.SOURCE }}"
if [ "$RUNNER_OS" == "Windows" ]; then
echo "No ls for 'D:' on Windows"
else
ls -al ${{ env.SOURCE }}
fi
aws s3 ${{ env.S3CMD }} --region ${{ secrets.AWS_REGION }} \
"${{ env.SOURCE }}" \
s3://${{ secrets.AWS_S3_BUCKET }}/${{ env.DEST_DIR }} \
${{ env.S3OPTIONS }}
echo "Done - $?"
exit 0
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE: "${{ github.workspace }}${{ env.TBN_DIST }}"
DEST_DIR: "${{ env.S3DESTOVERRIDE }}${{ env.S3DESTDIR }}/"
S3CMD: "cp"
S3OPTIONS: '--recursive --exclude "*" --include "*.zip*"'
# S3OPTIONS: '--recursive --exclude "*" --include "*.zip*"'
# S3OPTIONS: '--acl public-read'
- name: Copy tags to latest s3 - Bash
# if: ${{ env.AWS_SECRET_ACCESS_KEY != '' && matrix.os != 'self-hosted' }}
if: ${{ env.AWS_SECRET_ACCESS_KEY != '' && matrix.os != 'self-hosted' && startsWith(github.ref, 'refs/tags/v') }}
shell: bash
run: |
echo "Starting upload ... ${{ env.SOURCE }}"
if [ "$RUNNER_OS" == "Windows" ]; then
echo "No ls for 'D:' on Windows"
else
ls -al ${{ env.SOURCE }}
fi
aws s3 ${{ env.S3CMD }} --region ${{ secrets.AWS_REGION }} \
"${{ env.SOURCE }}" \
s3://${{ secrets.AWS_S3_BUCKET }}/current/${{ env.DEST_DIR }} \
${{ env.S3OPTIONS }}
aws s3 rm --region ${{ secrets.AWS_REGION }} \
s3://${{ secrets.AWS_S3_BUCKET }}/latest/${{ env.DEST_DIR }}/*
aws s3 ${{ env.S3CMD }} --region ${{ secrets.AWS_REGION }} \
"${{ env.SOURCE }}" \
s3://${{ secrets.AWS_S3_BUCKET }}/latest/${{ env.DEST_DIR }} \
${{ env.S3OPTIONS }}
echo "Done - $?"
exit 0
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE: "${{ github.workspace }}${{ env.TBN_DIST }}"
DEST_DIR: "${{ env.S3DESTOVERRIDE }}${{ env.S3DESTDIR }}/"
S3CMD: "cp"
S3OPTIONS: '--recursive --exclude "*" --include "*.zip*"'
# S3OPTIONS: '--recursive --exclude "*" --include "*.zip*"'
# S3OPTIONS: '--acl public-read'
create-release:
runs-on: ubuntu-latest
needs: builds
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Download binaries
uses: actions/download-artifact@v2
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "tari_*/**/*"
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
draft: true