-
Notifications
You must be signed in to change notification settings - Fork 1
397 lines (340 loc) · 12.2 KB
/
release-ubuntu.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
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
name: Build Ubuntu
on:
release:
types:
- created
env:
REPO: nugu-linux
REPOSLUG: nugu-developers/nugu-linux
#
# Jobs
# check
# -> build (matrix)
# - Generate DEB package and .tgz
# - Upload to Github release
# -> pages
# - Doxygen
# - DEB Repository
# - Upload to Github pages
# -> docker
# - Generate nugulinux/sdk:unstable docker image
#
jobs:
check:
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.check.outputs.id }}
sha: ${{ steps.check.outputs.sha }}
steps:
- name: Get SHA and ID from Release ${{ github.ref }}
id: check
run: |
# Remove "refs/tags/" from "refs/tags/xxxxxxx"
SHORTSHA=$(echo ${GITHUB_REF} | cut -c11-)
echo "SHA: $SHORTSHA"
# Get ID for Release-tag
ID=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -X GET https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${SHORTSHA} | jq '.id' -r)
echo "> Release ID = ${ID}"
if [[ ${ID} == "null" ]]; then
echo "Release ${ID} not exist."
exit
fi
echo "Release-ID: $ID"
echo "id=$ID" >> $GITHUB_OUTPUT
echo "sha=$SHORTSHA" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: check
strategy:
fail-fast: true
matrix:
target:
[
bionic_x64,
bionic_arm64,
bionic_armhf,
focal_x64,
focal_arm64,
focal_armhf,
jammy_x64,
jammy_arm64,
jammy_armhf,
]
steps:
- name: Setup
run: |
UBUNTU_VER=$(echo ${{ matrix.target }} | cut -d "_" -f 1)
ARCH=$(echo ${{ matrix.target }} | cut -d "_" -f 2)
if [ "$ARCH" == "x64" ]; then
ARCH2="amd64"
else
ARCH2="${ARCH}"
fi
echo "ubuntuver=$UBUNTU_VER" >> $GITHUB_ENV
echo "arch=$ARCH" >> $GITHUB_ENV
echo "arch2=$ARCH2" >> $GITHUB_ENV
echo "id=${{ needs.check.outputs.release_id }}" >> $GITHUB_ENV
echo "sha=${{ needs.check.outputs.sha }}" >> $GITHUB_ENV
- name: Check for duplicated files
run: |
COUNT=0
MATCH_COUNT=6
RESULT=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -X GET https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${{ env.id }}/assets?per_page=80)
FILES=$(echo $RESULT | jq '.[].name' -r)
for item in $FILES
do
echo "Check artifacts - $item"
# Check ARCH or ARCH2
if [[ $item == *"${{ env.arch }}"* ]]; then
:
elif [[ $item == *"${{ env.arch2 }}"* ]]; then
:
else
continue;
fi
# Check Ubuntu version (jammy / focal / bionic)
if [[ $item == *"${{ env.ubuntuver }}"* ]]; then
:
else
continue;
fi
declare -i COUNT; COUNT+=1
echo "> Found build artifacts: [${COUNT}/${MATCH_COUNT}] ${item}"
done
# Mark to flag file to trigger the build
if [[ $COUNT == $MATCH_COUNT ]]; then
echo "> There is no need to rebuild."
echo "exist=1" >> $GITHUB_ENV
else
echo "> Rebuild required"
echo "exist=0" >> $GITHUB_ENV
fi
- name: The build artifact already exists, so the build is skipped.
if: ${{ env.exist == '1'}}
run: echo "Done"
- name: Start Ubuntu build
if: ${{ env.exist == '0'}}
run: |
# Get date for commit to generate version
DATETIME=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -X GET https://api.github.com/repos/${REPOSLUG}/commits/${{ env.sha }} | jq '.commit.committer.date' -r)
echo "commit.committer.date = ${DATETIME}"
STAMP=$(date -d ${DATETIME} +%Y%m%d)
VERSION="${STAMP}${{ env.sha }}"
echo "package version = ${VERSION}"
echo "Clone the sdk repository"
git clone https://github.com/${REPOSLUG} --recursive
cd ${REPO}
git checkout ${{ env.sha }}
git reset --hard
rm -rf .git
echo "Add commit-id(${{ env.sha }}) to package version"
sed -i "1 s/ubuntu[0-9]*~bionic/ubuntu${VERSION}~bionic/" packaging/bionic/changelog
sed -i "1 s/ubuntu[0-9]*~focal/ubuntu${VERSION}~focal/" packaging/focal/changelog
sed -i "1 s/ubuntu[0-9]*~jammy/ubuntu${VERSION}~jammy/" packaging/jammy/changelog
head -1 packaging/bionic/changelog
head -1 packaging/focal/changelog
head -1 packaging/jammy/changelog
cd -
# Fix permissions for docker
chmod 777 $PWD
chmod 777 $PWD/${REPO}
echo "Build debian package"
docker run -t --rm --privileged -v $PWD:$PWD -w $PWD/${REPO} \
-v /var/lib/schroot/chroots \
nugulinux/buildenv:${{ matrix.target }} sdkbuild.sh
ls -l
echo "Create /tmp/result"
mkdir /tmp/result
cp *.deb /tmp/result/
echo "Completed"
echo "files=1" >> $GITHUB_ENV
- name: Generate tgz
if: ${{ env.files == '1'}}
run: |
FILENAME=files_${{ matrix.target }}_${{ env.sha }}
# Create temporary directory
mkdir dest
# Extract all deb packages
FILES=$(ls *.deb)
for item in $FILES
do
echo "Extract ${item}"
ar x ${item}
if [ -f data.tar.xz ]; then
tar -C dest -xvf data.tar.xz
rm data.tar.xz
elif [ -f data.tar.zst ]; then
tar -C dest -xvf data.tar.zst
rm data.tar.zst
fi
done
# Generate tgz
cd dest
tar cvfz ../${FILENAME}.tgz .
cd -
cp ${FILENAME}.tgz /tmp/result/
- name: Upload artifact to release
if: ${{ env.files == '1'}}
uses: svenstaro/upload-release-action@v2
with:
file: /tmp/result/*
file_glob: true
repo_token: ${{ secrets.GH_TOKEN }}
overwrite: true
tag: ${{ github.ref }}
pages:
runs-on: ubuntu-latest
needs: [check, build]
env:
BASEROOT: /tmp/www
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Setup
id: setup
run: |
sudo apt-get install doxygen graphviz
POOL_BIONIC=${BASEROOT}/ubuntu/dists/bionic/pool
POOL_FOCAL=${BASEROOT}/ubuntu/dists/focal/pool
POOL_JAMMY=${BASEROOT}/ubuntu/dists/jammy/pool
DIRS=(
${POOL_BIONIC}
${POOL_JAMMY}
${BASEROOT}/ubuntu/dists/bionic/main/binary-amd64
${BASEROOT}/ubuntu/dists/bionic/main/binary-arm64
${BASEROOT}/ubuntu/dists/bionic/main/binary-armhf
${BASEROOT}/ubuntu/dists/focal/main/binary-amd64
${BASEROOT}/ubuntu/dists/focal/main/binary-arm64
${BASEROOT}/ubuntu/dists/focal/main/binary-armhf
${BASEROOT}/ubuntu/dists/jammy/main/binary-amd64
${BASEROOT}/ubuntu/dists/jammy/main/binary-arm64
${BASEROOT}/ubuntu/dists/jammy/main/binary-armhf
)
for item in "${DIRS[@]}"
do
echo "- Create ${item}"
if [[ ! -d ${item} ]]; then
mkdir -p ${item}
fi
done
# Generate index.html
DATE=$(date)
cat <<EOF > ${BASEROOT}/index.html
<html>
<body>
<h1>DEB Package repository for unstable release</h1>
<p>
last unstable commit: <a href="https://github.com/nugu-developers/nugu-linux/commit/${{ env.sha }}">${{ env.sha }}</a>
</p>
<p>
API Document(doxygen): <a href="https://nugulinux.github.io/sdk-unstable/doxygen/">https://nugulinux.github.io/sdk-unstable/doxygen/</a>
</p>
<hr/>
<h2>NUGU SDK for Linux PPA Setup (stable release)</h2>
<pre>
add-apt-repository ppa:nugulinux/sdk
apt-get update
</pre>
<hr/>
<h2>Unstable package repository setup</h2>
<h3>Jammy (22.04)</h3>
<pre>
echo "deb [trusted=yes] https://nugulinux.github.io/sdk-unstable/ubuntu/ jammy main" > /etc/apt/sources.list.d/nugudev.list
apt-get update
</pre>
<h3>Focal (20.04)</h3>
<pre>
echo "deb [trusted=yes] https://nugulinux.github.io/sdk-unstable/ubuntu/ focal main" > /etc/apt/sources.list.d/nugudev.list
apt-get update
</pre>
<h3>Bionic (18.04)</h3>
<pre>
echo "deb [trusted=yes] https://nugulinux.github.io/sdk-unstable/ubuntu/ bionic main" > /etc/apt/sources.list.d/nugudev.list
apt-get update
</pre>
<hr/>
<p>Generated at ${DATE}</p>
</body>
</html>
EOF
echo "id=${{ needs.check.outputs.release_id }}" >> $GITHUB_ENV
echo "sha=${{ needs.check.outputs.sha }}" >> $GITHUB_ENV
echo "pool_bionic=${POOL_BIONIC}" >> $GITHUB_ENV
echo "pool_focal=${POOL_FOCAL}" >> $GITHUB_ENV
echo "pool_jammy=${POOL_JAMMY}" >> $GITHUB_ENV
- name: Generate doxygen
run: |
git clone https://github.com/${REPOSLUG}
cd ${REPO}
git checkout ${{ env.sha }}
git reset --hard
rm -rf .git
doxygen
mv doc/html ${BASEROOT}/doxygen
cd ..
rm -rf ${REPO}
- name: Generate unstable DEB repository
run: |
function generate {
DIST=$1
HOST=$2
PKGSREPO="dists/${DIST}/pool"
PKGS="dists/${DIST}/main/binary-${HOST}/"
echo "> DEB Repo: ${PKGSREPO}"
echo "> Packages path: ${PKGS}"
cd ${BASEROOT}/ubuntu
dpkg-scanpackages -m -a $HOST ${PKGSREPO} > ${PKGS}/Packages
cd -
}
echo "> Get file list"
RESULT=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -X GET https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${{ env.id }}/assets?per_page=80)
FILES=$(echo $RESULT | jq '.[].browser_download_url' -r)
for item in $FILES
do
if [[ $item != *.deb ]]; then
echo "- ignore: ${item}"
continue
fi
echo "Download ${item}"
if [[ $item == *"bionic"* ]]; then
echo "- 18.04: ${item}"
wget -nv ${item} -P ${{ env.pool_bionic }}
if [[ $item == *"amd64"* ]]; then
generate "bionic" "amd64"
elif [[ $item == *"armhf"* ]]; then
generate "bionic" "armhf"
elif [[ $item == *"arm64"* ]]; then
generate "bionic" "arm64"
fi
elif [[ $item == *"focal"* ]]; then
echo "- 20.04: ${item}"
wget -nv ${item} -P ${{ env.pool_focal }}
if [[ $item == *"amd64"* ]]; then
generate "focal" "amd64"
elif [[ $item == *"armhf"* ]]; then
generate "focal" "armhf"
elif [[ $item == *"arm64"* ]]; then
generate "focal" "arm64"
fi
elif [[ $item == *"jammy"* ]]; then
echo "- 20.04: ${item}"
wget -nv ${item} -P ${{ env.pool_jammy }}
if [[ $item == *"amd64"* ]]; then
generate "jammy" "amd64"
elif [[ $item == *"armhf"* ]]; then
generate "jammy" "armhf"
elif [[ $item == *"arm64"* ]]; then
generate "jammy" "arm64"
fi
else
echo "- unknown version: ${item}"
fi
done
- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GH_TOKEN }}
branch: gh-pages
folder: /tmp/www
clean: true
single-commit: true