-
Notifications
You must be signed in to change notification settings - Fork 90
246 lines (234 loc) · 10 KB
/
github-actions.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
name: Containers
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
build-job:
name: 🏗️ Build
runs-on: ubuntu-latest
if: "!contains(github.event.commits[0].message, '[skip ci]')"
strategy:
matrix:
include:
- model: "dsl-ax82u"
sdk: "src-rt-5.02axhnd.675x"
ui: "default"
skip: "Y"
- model: "rt-ax82u"
sdk: "src-rt-5.02axhnd.675x"
ui: "default"
skip: "Y"
- model: "rt-ax82u_v2"
sdk: "src-rt-5.04axhnd.675x"
ui: "default"
skip: "Y"
- model: "rt-ax92u"
sdk: "src-rt-5.02axhnd"
ui: "default"
skip: "Y"
- model: "rt-ax5400"
sdk: "src-rt-5.04axhnd.675x"
ui: "default"
skip: "Y"
- model: "tuf-ax3000"
sdk: "src-rt-5.02axhnd.675x"
ui: "default"
skip: "Y"
- model: "tuf-ax5400"
sdk: "src-rt-5.02axhnd.675x"
ui: "default"
skip: "Y"
- model: "tuf-ax3000"
sdk: "src-rt-5.02axhnd.675x"
ui: "tuf"
skip: "Y"
- model: "tuf-ax5400"
sdk: "src-rt-5.02axhnd.675x"
ui: "tuf"
skip: "Y"
- model: "rt-ax95q"
sdk: "src-rt-5.02axhnd.675x"
ui: "default"
skip: "n"
- model: "rt-axe95q"
sdk: "src-rt-5.02axhnd.675x"
ui: "default"
skip: "n"
container:
image: gnuton/asuswrt-merlin-toolchains-docker:latest
env:
MERLINUPDATE: "y"
MODEL: ${{ matrix.model }}
SDK: ${{ matrix.sdk }}
UI: ${{ matrix.ui }}
GIT_REPO: "https://github.com/gnuton/asuswrt-merlin.ng.git"
PROJECT_DIR: "/project/asuswrt-merlin.ng"
HOME: "/home/docker"
CHANGELOG_FILE: "/tmp/CHANGELOG"
options: --user docker
volumes:
- ${{ github.workspace }}:/project
steps:
- name: Fix permissions in docker image
run: |
sudo chown docker:docker /home/docker /project -R
- name: Setup git config
run: |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default
git config --global user.email "[email protected]"
git config --global user.name "Circle CI BOT"
git config --global push.default simple
- name: "Fetch code"
run: |
pwd
echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
cd /project
git clone --single-branch --depth 1 --branch master $GIT_REPO
ls /home/docker
- name: "Set version"
run: |
cd ${PROJECT_DIR}
export CIRCLE_TAG="${GITHUB_REF#refs/*/}"
if [[ $GITHUB_REF_TYPE == "branch" ]]; then
echo "Nothing to do. Not a release. Branch detected: ${CIRCLE_TAG}"
else
TAG=$(echo ${CIRCLE_TAG} | sed 's/^[^.]*\.//')
MAJOR_VER=$(echo "${TAG}" | sed -E 's/([0-9.]*)[_-]?(.*)/\1/')
MINOR_VER=$(echo "${TAG}" | sed -E 's/([0-9.]*)[_-]?(.*)/\2/')
sed -i "s/SERIALNO=.*/SERIALNO=${MAJOR_VER}/g" release/src-rt/version.conf
sed -i "s/EXTENDNO=.*/EXTENDNO=${MINOR_VER}/g" release/src-rt/version.conf
echo "Release detected. Updating version.conf with MAJOR_VER=${MAJOR_VER} and MINOR_VER=${MINOR_VER}"
fi
- name: Generate changelog
run: |
cd ${PROJECT_DIR}
python tools/get-last-notes.py > "${CHANGELOG_FILE}"
cat "${CHANGELOG_FILE}"
- name: "Build"
run: |
echo "----- I am: $(id) -----"
cd ${PROJECT_DIR}/release/${SDK}
echo "----- Files in dir: $(pwd) -----"
ls -alh
echo "----- Setting toolchains for ${SDK} -----"
if [[ ${SDK} == "src-rt-5.04axhnd.675x" ]]; then
source /home/docker/envs/bcm-hnd-ax-4.19.sh
elif [[ ${SDK} == "src-rt-5.02axhnd.675x" ]]; then
source /home/docker/envs/bcm-hnd.sh
elif [[ ${SDK} == "src-rt-5.02axhnd" ]]; then
source /home/docker/envs/bcm-hnd.sh
else
echo "SDK not supported"
exit -1
fi
echo "----- hack-ish fix ---------"
sudo ln -sf /home/docker/am-toolchains/brcm-arm-hnd /opt/toolchains
echo "----- Check envs dir ---------"
ls -alh /home/docker/envs/
echo "----- Debugging env vars -----"
env
echo "------ Setting UI as $UI ---------"
if [[ ${UI} == "tuf" ]]; then
echo "Enabling TUF UI"
sed -i 's/TUF_UI=n/TUF_UI=y/' ${PROJECT_DIR}/release/src-rt/target.mak
fi
echo "----- BUILD -----"
if [[ ${SKIP_BUILD} == "Y" ]]; then
echo "Skipping build"
exit 0
fi
# make ${MODEL}
# #### Just for testing ####
mkdir -p "${PROJECT_DIR}/release/${SDK}/image/"
echo "TEST" > "${PROJECT_DIR}/release/${SDK}/image/${MODEL}_${UI}_puresqubi.w"
- name: "Prepare artifacts"
env:
ARTIFACTS_DIR: ${{ github.workspace }}/artifacts
run: |
export IMAGE_PATH=${PROJECT_DIR}/release/${SDK}/image/
mkdir -p "${ARTIFACTS_DIR}"
if [[ ${SKIP_BUILD} == "Y" ]]; then
echo "Nothing to persist. Skipping."
exit 0
fi
echo "Removing images with boot loader."
rm -rf ${IMAGE_PATH}/*cferom*
files=("${IMAGE_PATH}"/*squashfs.pkgtb "${IMAGE_PATH}"/*.w)
if [ ${#files[@]} -gt 0 ]; then
for f in "${files[@]}"; do
if [ -f "$f" ] && [ "${f##*.}" != "md5" ]; then
echo "Creating MD5 signature for $f"
md5sum "$f" > "$f.md5"
echo "Copying image $f to workspace"
cp "$f" "${ARTIFACTS_DIR}"
cp "$f.md5" "${ARTIFACTS_DIR}"
fi
done
else
echo "No *.squashfs.pkgtb or *.w files found in ${IMAGE_PATH}"
fi
# Changelogs are the same for each models since we are building from the same branch. We do use only the one generated by DSL-AX82U for now.
if [[ ${MODEL} == "dsl-ax82u" ]]; then
cp "${CHANGELOG_FILE}" "${ARTIFACTS_DIR}"
fi
- name: "Archive artifacts"
uses: actions/upload-artifact@v2
with:
name: release-${{ matrix.model }}-${{ matrix.ui }}
path: ${{ github.workspace }}/artifacts
- name: "Publish Manifest"
env:
UPDATE_DIR: "updates"
run: |
export CIRCLE_TAG="${GITHUB_REF#refs/*/}"
if [[ $GITHUB_REF_TYPE == "branch" ]]; then
echo "Nothing to do. Not a release. Branch detected: ${CIRCLE_TAG}"
exit 0
fi
MAJOR_VER=$(echo "${CIRCLE_TAG}" | sed -E 's/([0-9.]*)[_-]?(.*)/\1/')
MINOR_VER=$(echo "${CIRCLE_TAG}" | sed -E 's/([0-9.]*)[_-]?(.*)/\2/')
RELEASE_NOTE_FILE=$(echo "${MAJOR_VER}_${MINOR_VER}_note.txt" | sed "s/\./_/")
echo "Generating manifest file..."
echo "DSL-AX82U#FW${MAJOR_VER}#EXT${MINOR_VER}" >> ${UPDATE_DIR}/manifest2.txt
echo "RT-AX82U#FW${MAJOR_VER}#EXT${MINOR_VER}" >> ${UPDATE_DIR}/manifest2.txt
echo "RT-AX82U_V2#FW${MAJOR_VER}#EXT${MINOR_VER}" >> ${UPDATE_DIR}/manifest2.txt
echo "RT-AX5400#FW${MAJOR_VER}#EXT${MINOR_VER}" >> ${UPDATE_DIR}/manifest2.txt
echo "TUF-AX5400#FW${MAJOR_VER}#EXT${MINOR_VER}" >> ${UPDATE_DIR}/manifest2.txt
echo "TUF-AX3000#FW${MAJOR_VER}#EXT${MINOR_VER}" >> ${UPDATE_DIR}/manifest2.txt
echo "RT-AX95Q#FW${MAJOR_VER}#EXT${MINOR_VER}" >> ${UPDATE_DIR}/manifest2.txt
echo "RT-AXE95Q#FW${MAJOR_VER}#EXT${MINOR_VER}" >> ${UPDATE_DIR}/manifest2.txt
echo "RT-AX5400#FW${MAJOR_VER}#EXT${MINOR_VER}" >> ${UPDATE_DIR}/manifest2.txt
cp ${CHANGELOG_FILE} ${UPDATE_DIR}/"${RELEASE_NOTE_FILE}"
echo "Uploading to github manifest and ${RELEASE_NOTE_FILE}"
git add ${UPDATE_DIR}
git commit -m "Updating Notes and manifest to version:${MAJOR_VER} ${MINOR_VER} [skip ci]" -a
git push origin
release-job:
name: ⬆️ Publish
needs: build-job
runs-on: ubuntu-latest
steps:
- name: Download packages
uses: actions/download-artifact@v2
- name: Get release version
run: |
echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "prerelease=$([[ ${GITHUB_REF#refs/*/} == *alpha* || ${GITHUB_REF#refs/*/} == *beta* ]] && echo True || echo False" >> $GITHUB_ENV
- name: Publish archives and packages
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.version }}
body_path: /home/runner/work/asuswrt-merlin.ng/asuswrt-merlin.ng/release-dsl-ax82u-default/CHANGELOG
draft: true
prerelease: ${{ env.prerelease }}
files: /home/runner/work/asuswrt-merlin.ng/asuswrt-merlin.ng/release*/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish_manifest-job:
name: Publish Manifest
needs: build-job
runs-on: build-job
steps:
- name: Update versions in Manifest file
run: |
ls