-
Notifications
You must be signed in to change notification settings - Fork 2
293 lines (259 loc) · 10 KB
/
ci.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
name: release posichain
on:
push:
tags:
- v*
jobs:
check:
name: Per-check for current tag
runs-on: ubuntu-latest
continue-on-error: false
outputs:
tag_annotated: ${{ steps.check-tag-annotated.outputs.tag_annotated }}
steps:
- name: Checkout posichain core code
uses: actions/checkout@v2
with:
path: posichain
ref: ${{ github.ref }}
fetch-depth: 0
- name: Check tag annotated
id: check-tag-annotated
run: |
VERSION=$(git tag -l --sort=-v:refname | head -n 1)
if git rev-parse $VERSION^{tag} -- &>/dev/null
then
echo "::set-output name=tag_annotated::true"
else
echo "::set-output name=tag_annotated::false"
fi
working-directory: posichain
build:
name: Build posichain binary
needs: check
runs-on: ${{ matrix.os }}
if: needs.check.outputs.tag_annotated == 'true'
strategy:
matrix:
os: [ubuntu-latest, macos-12]
steps:
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASS }}
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.18.4
- name: Checkout dependence repo
uses: actions/checkout@v2
with:
repository: PositionExchange/mcl
path: mcl
- name: Checkout dependence repo
uses: actions/checkout@v2
with:
repository: PositionExchange/bls
path: bls
- name: Checkout posichain core code
uses: actions/checkout@v2
with:
path: posichain
ref: ${{ github.ref }}
fetch-depth: 0
- name: Get latest version and release
run: |
VERSION=$(git tag -l --sort=-v:refname | head -n 1 | tr -d v)
RELEASE=$(git describe --long | cut -f2 -d-)
echo "build_version=$VERSION" >> $GITHUB_ENV
echo "build_release=$RELEASE" >> $GITHUB_ENV
working-directory: posichain
- name: Build posichain binary and packages for Linux
if: matrix.os == 'ubuntu-latest'
run: |
make linux_static
make deb
echo %_signature gpg >> $HOME/.rpmmacros && echo "%_gpg_name Posichain (posichain.org)" >> $HOME/.rpmmacros
make rpm
mv ./bin/posichain ./bin/posichain-amd64
mv ./bin/bootnode ./bin/bootnode-amd64
mv $HOME/debbuild/posichain-$build_version-$build_release.deb ./bin/
mv $HOME/rpmbuild/RPMS/x86_64/posichain-$build_version-$build_release.x86_64.rpm ./bin/
./bin/posichain-amd64 config dump -n=mainnet ./bin/posichain-mainnet.conf
./bin/posichain-amd64 config dump -n=testnet ./bin/posichain-testnet.conf
./bin/posichain-amd64 config dump -n=devnet ./bin/posichain-devnet.conf
working-directory: posichain
- name: Build posichain binary and packages for MacOS
if: matrix.os == 'macos-12'
run: |
brew install bash
sudo rm -f /usr/local/opt/openssl
sudo ln -sf /usr/local/opt/openssl@1.1 /usr/local/opt/openssl
make
cd ./bin && mkdir ./lib && mv ./*.dylib ./lib && rm -f ./bootnode
gpg --detach-sign posichain
zip -qr ./posichain-macos.zip ./*
rm -rf `ls * | egrep -v posichain-macos.zip`
working-directory: posichain
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: posichain
path: posichain/bin/*
retention-days: 1
release-page:
name: Sign binary and create and publish release page
needs: [check, build]
runs-on: ubuntu-latest
if: needs.check.outputs.tag_annotated == 'true'
steps:
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PRIVATE_KEY_PASS }}
- name: Checkout posichain core code
uses: actions/checkout@v2
with:
path: posichain
ref: ${{ github.ref }}
fetch-depth: 0
- name: Get latest version
run: |
VERSION=$(git tag -l --sort=-v:refname | head -n 1 | tr -d v)
VERSION_LONG=$(git describe --always --long --dirty)
RELEASE=$(git describe --long | cut -f2 -d-)
echo "build_version=$VERSION" >> $GITHUB_ENV
echo "build_version_long=$VERSION_LONG" >> $GITHUB_ENV
echo "build_release=$RELEASE" >> $GITHUB_ENV
working-directory: posichain
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: posichain
- name: Signed amd64 posichain binary
run: |
gpg --detach-sign posichain-amd64
sha256sum posichain-amd64 >> posichain-amd64.sha256
- name: Signed macos posichain binary
run: |
shasum -a 256 posichain-macos.zip >> posichain-macos.zip.sha256
- name: Get tag message
env:
TAG_SHA: ${{ github.event.after }}
run: |
touch ./tag_message.md
TAG_MESSAGE=$(git cat-file tag v$build_version | tail -n+6)
echo -e "$TAG_MESSAGE\n\nThe released version: $build_version_long" >> ./tag_message.md
working-directory: posichain
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ env.build_version }}
draft: true
prerelease: false
body_path: ./posichain/tag_message.md
- name: Upload posichain amd64 binary for Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./posichain-amd64
asset_name: posichain-amd64
asset_content_type: application/octet-stream
- name: Upload sha256 signature of posichain amd64 binary for Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./posichain-amd64.sha256
asset_name: posichain-amd64.sha256
asset_content_type: text/plain
- name: Upload gpg signature of posichain amd64 binary for Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./posichain-amd64.sig
asset_name: posichain-amd64.sig
asset_content_type: application/octet-stream
- name: Upload posichain deb package for Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./posichain-${{ env.build_version }}-${{ env.build_release }}.deb
asset_name: posichain-${{ env.build_version }}.deb
asset_content_type: application/x-deb
- name: Upload posichain rpm package for Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./posichain-${{ env.build_version }}-${{ env.build_release }}.x86_64.rpm
asset_name: posichain-${{ env.build_version }}.x86_64.rpm
asset_content_type: application/x-rpm
- name: Upload posichain binary for MacOS
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./posichain-macos.zip
asset_name: posichain-macos-${{ env.build_version }}.zip
asset_content_type: application/zip
- name: Upload sha256 signature of posichain for MacOS
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./posichain-macos.zip.sha256
asset_name: posichain-macos.zip.sha256
asset_content_type: text/plain
- name: Upload bootnode amd64 binary for Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bootnode-amd64
asset_name: bootnode-amd64
asset_content_type: application/octet-stream
- name: Upload mainnet config
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./posichain-mainnet.conf
asset_name: posichain-mainnet.conf
asset_content_type: text/plain
- name: Upload testnet config
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./posichain-testnet.conf
asset_name: posichain-testnet.conf
asset_content_type: text/plain
- name: Upload devnet config
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./posichain-devnet.conf
asset_name: posichain-devnet.conf
asset_content_type: text/plain