-
Notifications
You must be signed in to change notification settings - Fork 110
276 lines (246 loc) · 9.9 KB
/
appimage.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
name: Build AppImage
on:
workflow_dispatch:
inputs:
release_type:
required: true
type: string
workflow_call:
inputs:
release_type:
required: true
type: string
secrets:
GCP_CREDENTIALS:
required: true
jobs:
appimage:
name: AppImage Build
strategy:
fail-fast: false
matrix:
include:
- arch: [ubuntu-latest]
image: ghcr.io/viamrobotics/rdk-devenv:amd64-cache
platform: linux/amd64
label: amd64
- arch: [buildjet-2vcpu-ubuntu-2204-arm]
image: ghcr.io/viamrobotics/rdk-devenv:arm64-cache
platform: linux/arm64
label: arm64
runs-on: ${{ matrix.arch }}
container:
image: ${{ matrix.image }}
options: --platform ${{ matrix.platform }}
timeout-minutes: 15
outputs:
date: ${{ steps.build_date.outputs.date }}
steps:
- name: Check out code
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: actions/checkout@v3
- name: Check out PR branch code
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Clean and Fix Permissions
run: |
chown testbot:testbot -R .
sudo -Hu testbot bash -lc 'make clean-all'
- name: Authorize GCP Upload
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Build and Package (PR)
if: contains(github.event.pull_request.labels.*.name, 'appimage') || contains(github.event.pull_request.labels.*.name, 'appimage-ignore-tests')
run: |
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="pr-${{ github.event.pull_request.number }}" appimage'
- name: Upload Files (PR)
if: contains(github.event.pull_request.labels.*.name, 'appimage') || contains(github.event.pull_request.labels.*.name, 'appimage-ignore-tests')
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: 'etc/packaging/appimages/deploy/'
destination: 'packages.viam.com/apps/viam-server/'
glob: '*'
parent: false
gzip: false
- name: Build and Package (Latest)
if: inputs.release_type == 'latest'
run: |
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="latest" appimage'
- name: Build and Package (Tagged)
if: inputs.release_type == 'stable' || inputs.release_type == 'rc'
run: |
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="${{ inputs.release_type }}" BUILD_CHANNEL="${{ github.ref_name }}" appimage'
- name: Set Date
id: build_date
run: echo "date=`date +%F`" >> $GITHUB_OUTPUT
- name: Upload Files (Testing)
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: 'etc/packaging/appimages/deploy/'
destination: 'packages.viam.com/apps/viam-server/testing/appimage/${{ steps.build_date.outputs.date }}/${{ github.sha }}/'
glob: '*'
parent: false
gzip: false
appimage-static-32bit:
name: static 32-bit for appimage
runs-on: buildjet-2vcpu-ubuntu-2204-arm
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# note: we run this way instead of using rdk-devenv as the job's container because of https://github.com/actions/runner/issues/2115 (js-based actions install incomaptible node on 32-bit)
- name: build server
run: docker run --rm -v $PWD:/rdk ghcr.io/viamrobotics/rdk-devenv:armhf-cache sh -c "cd /rdk && make server-static"
- name: build aix
run: docker run --rm -v $PWD:/rdk ghcr.io/viamrobotics/rdk-devenv:armhf-cache sh -c 'cd /rdk && GOBIN=`pwd`/bin/`uname -s`-`uname -m` go install -ldflags "-s -w" -tags osusergo,netgo github.com/Otterverse/aix@latest'
- name: permissions
run: sudo chown -R $USER bin
# note: we do this because uname sees the arm64 kernel underneath the armhf container
- name: fix platform detection
run: mv bin/`uname -s`-`uname -m` bin/`uname -s`-armv7l
- uses: actions/upload-artifact@v3
with:
name: appimage-static-32bit
path: |
bin/*/viam-server
bin/*/aix
# note: this is a separate job because 1) appimage-builder doesn't work on 32-bit, 2) setup-python doesn't work on arm64
appimage-32bit:
runs-on: ubuntu-latest
needs: appimage-static-32bit
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
- uses: actions/download-artifact@v3
with:
name: appimage-static-32bit
path: bin/
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: deps
run: pip install appimage-builder git+https://github.com/AppImageCrafters/appimage-builder.git@42d32f11496de43a9f6a9ada7882a11296e357ca
- name: build
env:
BUILD_CHANNEL: ${{ inputs.release_type }}
UNAME_M: armv7l
DPKG_ARCH: armhf
APPIMAGE_ARCH: armhf
run: make appimage-arch
- uses: actions/upload-artifact@v3
with:
name: appimage-armhf
path: etc/packaging/appimages/deploy
output_summary:
name: Output Summary
runs-on: ubuntu-latest
needs: appimage
if: contains(github.event.pull_request.labels.*.name, 'appimage') || contains(github.event.pull_request.labels.*.name, 'appimage-ignore-tests')
steps:
- name: Display Download Links
run: |
channel="pr-${{ github.event.pull_request.number }}"
echo "### Built AppImages for ${channel}" >> $GITHUB_STEP_SUMMARY
echo "- arm64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-aarch64.AppImage" >> $GITHUB_STEP_SUMMARY
echo "- x86_64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-x86_64.AppImage" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
appimage_test:
name: AppImage Test
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
strategy:
fail-fast: false
matrix:
include:
- arch: ubuntu-latest
label: x86_64
- arch: buildjet-2vcpu-ubuntu-2204-arm
label: aarch64
- arch: [arm64, pi4]
label: aarch64
needs: appimage
runs-on: ${{ matrix.arch }}
timeout-minutes: 15
outputs:
date: ${{ needs.appimage.outputs.date }}
steps:
- name: Clean Workspace
run: |
shopt -s dotglob
sudo chown -R `whoami` ./
rm -rf ./*
- name: Test AppImage
run: |
if echo "${{ matrix.arch[0] }}" | grep -q ubuntu; then
sudo apt-get install -y libfuse2
fi
channel="${{ github.ref_name }}"
# we call our main branch releases "latest"
if [ "$channel" = "main" ]; then
channel="latest"
fi
export TEST_DIR=`mktemp -d -t test-viam-server-XXXXXX`
cd $TEST_DIR
curl -o viam-server https://storage.googleapis.com/packages.viam.com/apps/viam-server/testing/appimage/${{ needs.appimage.outputs.date }}/${{ github.sha }}/viam-server-${channel}-`uname -m`.AppImage
chmod 755 viam-server
export RAND_PORT=$((30000 + $RANDOM))
echo "{\"network\": {\"bind_address\":\"localhost:${RAND_PORT}\"}}" > test.json
./viam-server -config test.json &
curl --retry 5 --retry-delay 5 --retry-connrefused localhost:$RAND_PORT
export RET1=$?
kill %%
wait $!
export RET2=$?
cd - && rm -rf $TEST_DIR
[ $RET1 == 0 ] && [ $RET1 == 0 ]
appimage_deploy:
name: AppImage Deploy
needs: appimage-32bit
# needs: [appimage_test, appimage-32bit]
runs-on: ubuntu-latest
env:
channel: ${{ github.ref_name == 'main' && 'latest' || github.ref_name }}
steps:
- name: Authorize GCP
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- uses: actions/download-artifact@v3
with:
name: appimage-armhf
path: etc/packaging/appimages/deploy
- name: trace
run: find etc/packaging/appimages/deploy
- name: deploy 32-bit
uses: google-github-actions/[email protected]
with:
headers: "cache-control: no-cache"
path: etc/packaging/appimages/deploy/viam-server-${{ env.channel }}-armhf.AppImage
destination: 'packages.viam.com/apps/viam-server/'
parent: false
- name: short-circuit
run: exit 1
- name: Publish AppImage
run: |
gsutil mv "gs://packages.viam.com/apps/viam-server/testing/appimage/${{ needs.appimage_test.outputs.date }}/${{ github.sha }}/*" "gs://packages.viam.com/apps/viam-server/"
- name: Output Summary
run: |
echo "### Built AppImages for ${channel}" >> $GITHUB_STEP_SUMMARY
echo "- arm64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-aarch64.AppImage" >> $GITHUB_STEP_SUMMARY
echo "- x86_64: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-x86_64.AppImage" >> $GITHUB_STEP_SUMMARY
echo "- armhf: https://storage.googleapis.com/packages.viam.com/apps/viam-server/viam-server-${channel}-armhf.AppImage" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY