-
Notifications
You must be signed in to change notification settings - Fork 9
244 lines (204 loc) · 8.04 KB
/
build_and_test_push.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
name: "Test, build, sync to AWS, and create release (on tagged push)"
on: push
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Go 1.17
uses: actions/setup-go@v4
with:
go-version: '1.17'
- name: Run Setup Script
run: |
bash ./.github/scripts/before_install.sh
env:
GITHUB_BRANCH: ${{ github.ref_name }}
ACCESS_KEY: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
- name: Run Tests
run: go test -v github.com/uc-cdis/gen3-client/tests
build:
env:
goarch: amd64
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
zipfile: dataclient_linux.zip
- goos: darwin
goarch: amd64
zipfile: dataclient_osx.zip
- goos: windows
goarch: amd64
zipfile: dataclient_win64.zip
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Go 1.17
uses: actions/setup-go@v4
with:
go-version: '1.17'
- name: Run Setup Script
run: |
bash .github/scripts/before_install.sh
env:
GITHUB_BRANCH: ${{ github.ref_name }}
ACCESS_KEY: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
- name: Run Build Script
run: |
bash .github/scripts/build.sh
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ env.goarch }}
GITHUB_BRANCH: ${{ github.ref_name }}
GITHUB_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifact-${{ matrix.goos }}
path: ~/shared/${{ matrix.zipfile }}
retention-days: 3
sign:
needs: build
runs-on: macos-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Download OSX Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-darwin
path: ./dist
- name: Unzip OSX Artifact and remove zip file
run: |
cd ./dist
ls
unzip dataclient_osx.zip
rm dataclient_osx.zip
- name: Build executable
shell: bash
env:
APPLE_CERT_PASSWORD: ${{ secrets.APPLE_CERT_PASSWORD }}
APPLE_NOTARY_UUID: ${{ secrets.APPLE_NOTARY_UUID }}
APPLE_NOTARY_KEY: ${{ secrets.APPLE_NOTARY_KEY}}
APPLE_NOTARY_DATA: ${{ secrets.APPLE_NOTARY_DATA }}
APPLE_CERT_DATA: ${{ secrets.APPLE_CERT_DATA }}
APPLICATION_CERT_PASSWORD: ${{ secrets.APPLICATION_CERT_PASSWORD }}
APPLICATION_CERT_DATA: ${{ secrets.APPLICATION_CERT_DATA }}
APPLE_TEAM_ID: WYQ7U7YUC9
run: |
# Setup
SIGNFILE="$(pwd)/dist/gen3-client"
# Export certs
echo "$APPLE_CERT_DATA" | base64 --decode > /tmp/certs.p12
echo "$APPLE_NOTARY_DATA" | base64 --decode > /tmp/notary.p8
echo "$APPLICATION_CERT_DATA" | base64 --decode > /tmp/app_certs.p12
# Create keychain
security create-keychain -p actions macos-build.keychain
security default-keychain -s macos-build.keychain
security unlock-keychain -p actions macos-build.keychain
security set-keychain-settings -t 3600 -u macos-build.keychain
# Import certs to keychain
security import /tmp/certs.p12 -k ~/Library/Keychains/macos-build.keychain -P "$APPLE_CERT_PASSWORD" -T /usr/bin/codesign -T /usr/bin/productsign
security import /tmp/app_certs.p12 -k ~/Library/Keychains/macos-build.keychain -P "$APPLICATION_CERT_PASSWORD" -T /usr/bin/codesign -T /usr/bin/productsign
# Key signing
security set-key-partition-list -S apple-tool:,apple: -s -k actions macos-build.keychain
# Verify keychain things
security find-identity -v macos-build.keychain | grep "$APPLE_TEAM_ID" | grep "Developer ID Application"
security find-identity -v macos-build.keychain | grep "$APPLE_TEAM_ID" | grep "Developer ID Installer"
# Force the codesignature
codesign --force --options=runtime --keychain "/Users/runner/Library/Keychains/macos-build.keychain-db" -s "$APPLE_TEAM_ID" "$SIGNFILE"
# Verify the code signature
codesign -v "$SIGNFILE" --verbose
mkdir -p ./dist/pkg
cp ./dist/gen3-client ./dist/pkg/gen3-client
pkgbuild --identifier "org.uc-cdis.gen3-client.pkg" --timestamp --install-location /Applications --root ./dist/pkg installer.pkg
pwd
ls
productbuild --resources ./resources --distribution ./distribution.xml gen3-client.pkg
productsign --sign "$APPLE_TEAM_ID" --timestamp gen3-client.pkg gen3-client_signed.pkg
xcrun notarytool store-credentials "notarytool-profile" --issuer $APPLE_NOTARY_UUID --key-id $APPLE_NOTARY_KEY --key /tmp/notary.p8
xcrun notarytool submit gen3-client_signed.pkg --keychain-profile "notarytool-profile" --wait
xcrun stapler staple gen3-client_signed.pkg
mv gen3-client_signed.pkg dataclient_osx.pkg
- name: Upload signed artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact-darwin-signed
path: dataclient_osx.pkg
sync_signed_to_aws:
runs-on: ubuntu-latest
needs: sign
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Run Setup Script
run: |
bash ./.github/scripts/before_install.sh
env:
GITHUB_BRANCH: ${{ github.ref_name }}
ACCESS_KEY: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
- name: Download OSX Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-darwin-signed
- name: Sync to AWS
env:
GITHUB_BRANCH: ${{ github.ref_name }}
run: |
rm ~/shared/dataclient_osx.zip
zip dataclient_osx_signed.zip dataclient_osx.pkg
mv dataclient_osx_signed.zip ~/shared/
aws s3 sync ~/shared s3://cdis-dc-builds/$GITHUB_BRANCH
get_tagged_branch:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [build,sign]
outputs:
branch: ${{ steps.check_step.outputs.branch }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get current branch
id: check_step
# 1. Get the list of branches ref where this tag exists
# 2. Remove 'origin/' from that result
# 3. Put that string in output
# => We can now use function 'contains(list, item)''
run: |
raw=$(git branch -r --contains ${{ github.ref }})
branch="$(echo ${raw//origin\//} | tr -d '\n')"
echo "{name}=branch" >> $GITHUB_OUTPUT
echo "Branches where this tag exists : $branch."
deploy:
needs: get_tagged_branch
if: startsWith(github.ref, 'refs/tags/') && contains(${{ needs.get_tagged_branch.outputs.branch }}, 'master')
runs-on: ubuntu-latest
steps:
- name: Download Linux Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-linux
- name: Download OSX Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-darwin-signed
- name: Download Windows Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-windows
- name: Create Release gh cli
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TAG: ${{ github.ref_name }}
run: gh release create "$GH_TAG" dataclient_linux.zip dataclient_osx.pkg dataclient_win64.zip --repo="$GITHUB_REPOSITORY"