-
Notifications
You must be signed in to change notification settings - Fork 1
152 lines (128 loc) · 4.08 KB
/
release-agl.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
name: Build AGL
on:
release:
types:
- created
workflow_dispatch:
inputs:
hash:
description: 'SDK Commit'
required: true
default: ''
comment:
description: 'Comment'
required: false
default: ''
env:
REPO: nugu-linux
REPOSLUG: nugu-developers/nugu-linux
#
# Jobs
# -> build (matrix)
# - Generate .tgz
# - Upload to Github release
#
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
target: [ koi_rpi4, koi_x64 ]
steps:
- name: Get SHA and ID from Release ${{ github.ref }}
run: |
if [ -z "${{ github.event.inputs.hash }}" ]; then
# Remove "refs/tags/" from "refs/tags/xxxxxxx"
SHORTSHA=$(echo ${GITHUB_REF} | cut -c11-)
else
SHORTSHA=${{ github.event.inputs.hash }}
fi
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_ENV
echo "sha=$SHORTSHA" >> $GITHUB_ENV
- name: Check for duplicated files
run: |
COUNT=0
MATCH_COUNT=1
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"
if [[ $item == *"agl"* ]]; 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: Prepare SDK source
if: ${{ env.exist == '0'}}
run: |
git clone https://github.com/${REPOSLUG} --recursive
cd ${REPO}
git checkout ${{ env.sha }}
git reset --hard
rm -rf .git
# Fix permissions for docker
chmod 777 $PWD
ls -l
- name: Prepare AGL Docker image
if: ${{ env.exist == '0'}}
run: docker pull ghcr.io/webispy/agl:${{ matrix.target }}
- name: Build
if: ${{ env.exist == '0'}}
run: |
cd ${REPO}
cat <<EOF > sdkbuild.sh
#!/bin/bash
set -e
source /opt/agl-sdk/11.0.*/environment-setup-*
rm -rf build
mkdir build
cd build
cmake .. -DENABLE_BUILTIN_OPUS=ON \
-DENABLE_PORTAUDIO_PLUGIN=OFF \
-DENABLE_ASAN=OFF \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_TOOLCHAIN_FILE=/opt/toolchain/Toolchain.cmake
make -j6
mkdir SDK
DESTDIR=SDK make install
tar cvfz files_agl_${{ matrix.target }}_${{ env.sha }}.tgz SDK
EOF
chmod 755 sdkbuild.sh
echo "> Build cross-compile"
docker run -t --rm -v $PWD:$PWD -w $PWD \
ghcr.io/webispy/agl:${{ matrix.target }} ./sdkbuild.sh
cp build/files_*.tgz /tmp/
- name: Upload
if: ${{ env.exist == '0'}}
uses: svenstaro/upload-release-action@v2
with:
file: /tmp/*.tgz
file_glob: true
repo_token: ${{ secrets.GH_TOKEN }}
overwrite: true
tag: ${{ github.ref }}