-
Notifications
You must be signed in to change notification settings - Fork 31
235 lines (207 loc) · 7.19 KB
/
build.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
name: Build binaries
on:
pull_request:
push:
branches:
- "master"
- "dev"
tags:
- "v*"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
name: Build binary packages
runs-on: macos-11
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
# Check https://github.com/livepeer/go-livepeer/pull/1891
# for ref value discussion
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v3
with:
node-version: "18"
cache: "yarn"
- name: Tags
id: tags
uses: livepeer/action-gh-release-tags@latest
- name: restore lerna
id: cache-lerna
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: restore pkg cache
id: cache-pkg
uses: actions/cache@v3
with:
path: "~/.pkg-cache"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: yarn install
run: yarn install --frozen-lockfile --silent
- name: build pkgs
# I want to do --parallel here, but the binary downloads conflict with each other
run: |
echo RELEASE_PATH="${GITHUB_WORKSPACE}/releases" >> "${GITHUB_ENV}"
echo BIN_PATH="${GITHUB_WORKSPACE}/bin" >> "${GITHUB_ENV}"
yarn run lerna-run pkg
- name: Rename and move built binaries
run: |
mkdir -p "${RELEASE_PATH}" "${BIN_PATH}"
for arch in linux-arm64 linux-x64 macos-arm64 macos-x64 win-x64; do
package="api"
in_name="$package-$arch"
out_name="livepeer-$package"
archive_name="livepeer-$(echo $in_name | sed -e 's/x64/amd64/;s/win/windows/;s/macos/darwin/')"
cd ./packages/$package/bin
case "$arch" in
win-x64)
in_name="$in_name.exe"
out_name="$out_name.exe"
mv "./$in_name" "./$out_name"
zip -q9 "${RELEASE_PATH}/${archive_name}.zip" "./$out_name"
;;
linux-*)
mv "./$in_name" "./$out_name"
tar -czvf "${RELEASE_PATH}/${archive_name}.tar.gz" "./$out_name"
;;
macos-*)
mkdir -p "${BIN_PATH}/$arch"
mv "./$in_name" "${BIN_PATH}/$arch/$out_name"
;;
esac
cd -
done
- name: Upload macos binaries for codesigning (arm64)
uses: actions/upload-artifact@v3
with:
name: macos-arm64
path: bin/macos-arm64
- name: Upload macos binaries for codesigning (amd64)
uses: actions/upload-artifact@v3
with:
name: macos-amd64
path: bin/macos-x64
- name: Upload artifacts for cutting release
uses: actions/upload-artifact@v3
with:
name: release-artifacts
path: releases/
macos:
strategy:
fail-fast: true
matrix:
arch:
- amd64
- arm64
name: Codesign and archive macOS binaries
runs-on: macos-11
needs: build
steps:
- name: Setup env
run: |
echo ARCH="${{ matrix.arch }}" >> "$GITHUB_ENV"
- name: Download binaries from build stage
uses: actions/download-artifact@v3
with:
name: macos-${{ matrix.arch }}
path: bin/
- name: Fix file permissions
run: |
cd bin/
chmod a+x livepeer-*
- uses: actions-ecosystem/action-regex-match@v2
id: match-tag
with:
text: ${{ github.ref_name }}
regex: '^(master|main|v[0-9]+\.\d+\.\d+)$'
- name: Codesign and notarize binaries
if: ${{ steps.match-tag.outputs.match != '' }}
uses: livepeer/action-gh-codesign-apple@latest
with:
developer-certificate-id: ${{ secrets.CI_MACOS_CERTIFICATE_ID }}
developer-certificate-base64:
${{ secrets.CI_MACOS_CERTIFICATE_BASE64 }}
developer-certificate-password:
${{ secrets.CI_MACOS_CERTIFICATE_PASSWORD }}
app-notarization-email: ${{ secrets.CI_MACOS_NOTARIZATION_USER }}
app-notarization-password:
${{ secrets.CI_MACOS_NOTARIZATION_PASSWORD }}
app-notarization-team-id: ${{ secrets.CI_MACOS_NOTARIZATION_TEAM_ID }}
binary-path: "bin/"
- name: Archive built binaries
run: |
mkdir -p releases/
cd bin/
for file in $(find . -type f -perm -a+x); do
tar -czf "../releases/${file}-darwin-${ARCH}.tar.gz" "${file}"
done
- name: Upload artifacts for cutting release
uses: actions/upload-artifact@v3
with:
name: release-artifacts
path: releases/
upload:
name: Upload artifacts to google bucket
if:
${{ github.event.pull_request.head.repo.full_name ==
github.event.pull_request.base.repo.full_name }}
permissions:
contents: "read"
id-token: "write"
runs-on: ubuntu-latest
needs:
- build
- macos
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: release-artifacts
path: releases/
- name: Generate sha256 checksum and gpg signatures for release artifacts
uses: livepeer/action-gh-checksum-and-gpg-sign@latest
with:
artifacts-dir: releases
release-name:
${{ github.ref_type == 'tag' && github.ref_name ||
github.event.pull_request.head.sha || github.sha }}
gpg-key: ${{ secrets.CI_GPG_SIGNING_KEY }}
gpg-key-passphrase: ${{ secrets.CI_GPG_SIGNING_PASSPHRASE }}
- name: Generate branch manifest
id: branch-manifest
uses: livepeer/branch-manifest-action@latest
with:
project-name: ${{ github.event.repository.name }}
platform: linux, darwin
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider:
${{ secrets.CI_GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.CI_GOOGLE_SERVICE_ACCOUNT }}
- name: Upload release archives to Google Cloud
id: upload-archives
uses: google-github-actions/upload-cloud-storage@v1
with:
path: "releases"
destination:
"build.livepeer.live/${{ github.event.repository.name }}/${{
(github.ref_type == 'tag' && github.ref_name) ||
github.event.pull_request.head.sha || github.sha }}"
parent: false
- name: Upload branch manifest file
id: upload-manifest
uses: google-github-actions/upload-cloud-storage@v1
with:
path: ${{ steps.branch-manifest.outputs.manifest-file }}
destination:
"build.livepeer.live/${{ github.event.repository.name }}/"
parent: false
- name: Notify new build upload
run: curl -X POST https://holy-bread-207a.livepeer.workers.dev