-
Notifications
You must be signed in to change notification settings - Fork 41
326 lines (312 loc) · 11.2 KB
/
release.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
name: Provenance Build and Release
on:
pull_request:
paths:
- "**.go"
- "go.mod"
- "go.sum"
- "**.mk"
- "Makefile"
- "gon.json"
- "scripts/**"
- ".github/workflows/release.yml"
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5
# Set concurrency for this workflow to cancel in-progress jobs if retriggered.
# The github.ref is only available when triggered by a PR so fall back to github.run_id for other cases.
# The github.run_id is unique for each run, giving each such invocation it's own unique concurrency group.
# Basically, if you push to a PR branch, jobs that are still running for that PR will be cancelled.
# But jobs started because of a merge to main or a release tag push are not cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
build_init:
runs-on: ubuntu-latest
name: Build Init
steps:
- name: Define Variables
id: vars
# ${GITHUB_REF##*/} removes everything before the last slash. E.g. 'refs/tags/v1.8.0' becomes 'v1.8.0'
# ${GITHUB_SHA:0:7} gets the first 7 characters. E.g. `3e9928920f5a64c8fc4884ee085efe1983071c90` becomes `3e99289'
run: |
version="${GITHUB_SHA:0:7}"
is_release='false'
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]; then
version=${GITHUB_REF##*/}
is_release='true'
fi
prerelease=false
if [[ "$version" =~ -rc ]]; then
prerelease=true
fi
echo "Setting output: version=$version"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Setting output: is_release=$is_release"
echo "is_release=$is_release" >> "$GITHUB_OUTPUT"
echo "Setting output: prerelease=$prerelease"
echo "prerelease=$prerelease" >> "$GITHUB_OUTPUT"
outputs:
version: ${{ steps.vars.outputs.version }}
is_release: ${{ steps.vars.outputs.is_release }}
prerelease: ${{ steps.vars.outputs.prerelease }}
go_version: '1.20'
build_osx:
runs-on: macos-latest
needs:
- build_init
name: Build OSX
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ needs.build_init.outputs.go_version }}
- name: Build osx binary
run: |
export VERSION=${{ needs.build_init.outputs.version }}
export WITH_CLEVELDB=false
export WITH_ROCKSDB=false
make build-release-zip
- name: Provenanced version
run: build/provenanced version --long
- uses: actions/upload-artifact@v3
with:
name: osx-zip
path: build/*.zip
build_linux:
runs-on: ubuntu-20.04
needs:
- build_init
name: Build Linux
env:
LD_LIBRARY_PATH: /usr/local/lib:/usr/local/lib/x86_64-linux-gnu
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ needs.build_init.outputs.go_version }}
- name: Install deps
run: |
sudo apt-get update
sudo apt-get install -y libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
- name: Build and install cleveldb
run: make cleveldb
- name: Build linux binary
run: |
export VERSION=${{ needs.build_init.outputs.version }}
export WITH_CLEVELDB=true
make build-release-zip
- name: Provenanced version
run: build/provenanced version --long
- uses: actions/upload-artifact@v3
with:
name: linux-zip
path: build/provenance*.zip
build_dbmigrate:
runs-on: ubuntu-20.04
needs:
- build_init
name: Build dbmigrate
env:
LD_LIBRARY_PATH: /usr/local/lib:/usr/local/lib/x86_64-linux-gnu
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ needs.build_init.outputs.go_version }}
- name: Install deps
run: |
sudo apt-get update
sudo apt-get install -y libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
- name: Build and install cleveldb
run: make cleveldb
- name: Build dbmigrate binary
run: |
export VERSION=${{ needs.build_init.outputs.version }}
export WITH_CLEVELDB=true
export WITH_ROCKSDB=false
export WITH_BADGERDB=false
make build-dbmigrate-zip
- name: dbmigrate --help
run: build/dbmigrate --help
- uses: actions/upload-artifact@v3
with:
name: dbmigrate-zip
path: build/dbmigrate*.zip
buf_push:
needs:
- build_init
if: needs.build_init.outputs.is_release == 'true'
runs-on: ubuntu-latest
name: Protobuf Push
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Buf setup action
uses: bufbuild/[email protected]
- name: Buf push 'proto/'
uses: bufbuild/buf-push-action@v1
with:
input: 'proto'
buf_token: ${{ secrets.BUF_TOKEN }}
create_release:
needs:
- build_init
- build_linux
- build_dbmigrate
if: needs.build_init.outputs.is_release == 'true'
runs-on: ubuntu-latest
name: Create Release
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create release ${{ needs.build_init.outputs.version }}
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: ${{ needs.build_init.outputs.prerelease }}
body_path: RELEASE_CHANGELOG.md
outputs:
release_url: ${{ steps.create_release.outputs.upload_url }}
update_release:
needs:
- build_init
- create_release
if: needs.build_init.outputs.is_release == 'true'
runs-on: ubuntu-latest
name: Attach Release Artifacts
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ needs.build_init.outputs.go_version }}
- name: Download linux zip artifact
uses: actions/download-artifact@v3
with:
name: linux-zip
path: build/
- name: Download dbmigrate zip artifact
uses: actions/download-artifact@v3
with:
name: dbmigrate-zip
path: build/
- name: Create release items
id: create-items
run: |
make VERSION=${{ needs.build_init.outputs.version }} build-release-checksum build-release-plan build-release-proto
- name: Upload linux zip artifact
if: always() && steps.create-items.outcome == 'success'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.release_url }}
asset_path: ./build/provenance-linux-amd64-${{ needs.build_init.outputs.version }}.zip
asset_name: provenance-linux-amd64-${{ needs.build_init.outputs.version }}.zip
asset_content_type: application/octet-stream
- name: Upload dbmigrate zip artifact
if: always() && steps.create-items.outcome == 'success'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.release_url }}
asset_path: ./build/dbmigrate-linux-amd64-${{ needs.build_init.outputs.version }}.zip
asset_name: dbmigrate-linux-amd64-${{ needs.build_init.outputs.version }}.zip
asset_content_type: application/octet-stream
- name: Upload release checksum
if: always() && steps.create-items.outcome == 'success'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.release_url }}
asset_path: ./build/sha256sum.txt
asset_name: sha256sum.txt
asset_content_type: application/octet-stream
- name: Upload release plan
if: always() && steps.create-items.outcome == 'success'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.release_url }}
asset_path: ./build/plan-${{ needs.build_init.outputs.version }}.json
asset_name: plan-${{ needs.build_init.outputs.version }}.json
asset_content_type: application/octet-stream
- name: Upload release protos
if: always() && steps.create-items.outcome == 'success'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.release_url }}
asset_path: ./build/protos-${{ needs.build_init.outputs.version }}.zip
asset_name: protos-${{ needs.build_init.outputs.version }}.zip
asset_content_type: application/octet-stream
java_kotlin_release:
needs:
- build_init
if: needs.build_init.outputs.is_release == 'true'
runs-on: ubuntu-latest
name: Java/Kotlin Proto Publishing
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Java Setup
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
server-id: github
- name: GPG Setup
env:
GPG_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
run: |
export GPG_TTY=$(tty)
echo -n "$GPG_KEY" | base64 --decode | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
echo -n "$GPG_KEY" | base64 --decode > $GITHUB_WORKSPACE/release.gpg
- name: Build and Publish
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
run: |
cd protoBindings
./gradlew publish closeAndReleaseSonatypeStagingRepository \
-PartifactVersion=$(echo "${{ needs.build_init.outputs.version }}" | sed -e 's/^v//') \
-Psigning.keyId=B7D30ABE \
-Psigning.password="${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}" \
-Psigning.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg \
--info
npm_release:
needs:
- build_init
if: needs.build_init.outputs.is_release == 'true'
runs-on: ubuntu-latest
name: NPM Proto Publishing
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Publish
uses: provenance-io/[email protected]
with:
api-version: ${{ needs.build_init.outputs.version }}
npm-token: ${{ secrets.NPM_TOKEN }}
tag: alpha