Skip to content

Commit 57bccef

Browse files
committed
Use GHA to build
1 parent 10dff8d commit 57bccef

File tree

1 file changed

+203
-0
lines changed

1 file changed

+203
-0
lines changed

.github/workflows/ci.yml

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- name: Free disk space
12+
run: |
13+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android
14+
15+
- name: Install dependencies
16+
run: |
17+
sudo add-apt-repository ppa:npalix/coccinelle
18+
sudo apt update
19+
sudo apt install build-essential clang flex g++ gawk gcc-multilib gettext \
20+
git libncurses5-dev libssl-dev python3-distutils rsync unzip zlib1g-dev \
21+
coccinelle
22+
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
26+
- name: Hook the openwrt_core URL for opkg
27+
run: |
28+
OWNER="${GITHUB_REPOSITORY%%/*}"
29+
REPO="${GITHUB_REPOSITORY#*/}"
30+
TIME="$(curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | jq -r .created_at)"
31+
32+
echo "ci-$(date -d "${TIME}" -u +'%Y%m%d-%H%M%S')-${GITHUB_SHA:0:8}" >version
33+
sed -i "s|%U/targets/%S/packages|https://${OWNER}.github.io/${REPO}/${GITHUB_REF_NAME}/%R|" include/feeds.mk
34+
35+
- name: Update and install feeds
36+
run: |
37+
./scripts/feeds update -a
38+
./scripts/feeds install -a
39+
40+
- name: Configure
41+
run: |
42+
cat <<EOF | sed -E 's/^ //' >.config
43+
CONFIG_TARGET_ipq50xx=y
44+
CONFIG_TARGET_ipq50xx_arm=y
45+
CONFIG_TARGET_ipq50xx_arm_DEVICE_redmi_ax3000=y
46+
47+
CONFIG_IB=y
48+
# CONFIG_IB_STANDALONE is not set
49+
CONFIG_SDK=y
50+
CONFIG_MAKE_TOOLCHAIN=y
51+
52+
CONFIG_ALL_NONSHARED=y
53+
CONFIG_REPRODUCIBLE_DEBUG_INFO=y
54+
55+
CONFIG_PACKAGE_kmod-bonding=y
56+
CONFIG_PACKAGE_kmod-qca-nss-ecm-standard=y
57+
CONFIG_PACKAGE_kmod-qca-nss-drv-pppoe=y
58+
59+
CONFIG_PACKAGE_luci=y
60+
EOF
61+
make defconfig
62+
63+
- name: Download
64+
run: |
65+
make -j16 download
66+
67+
- name: Build tools
68+
run: |
69+
make -j$(nproc) tools/install
70+
71+
- name: Build toolchain
72+
run: |
73+
make -j$(nproc) toolchain/install
74+
75+
- name: Build all
76+
run: |
77+
make -j$(nproc) IGNORE_ERRORS=1
78+
79+
- name: Upload bin to artifacts
80+
uses: actions/upload-artifact@v3
81+
with:
82+
name: bin-ipq50xx-arm
83+
path: bin/targets/ipq50xx/arm/*
84+
85+
- name: Upload dl to artifacts
86+
uses: actions/upload-artifact@v3
87+
with:
88+
name: dl
89+
path: dl/*
90+
91+
gh-pages:
92+
needs: [ build ]
93+
runs-on: ubuntu-20.04
94+
permissions:
95+
contents: write
96+
steps:
97+
- name: Checkout gh-pages
98+
uses: actions/checkout@v3
99+
with:
100+
path: 'gh-pages'
101+
ref: 'gh-pages'
102+
fetch-depth: 0
103+
104+
- name: Configure the git user
105+
run: |
106+
git config --global user.name 'github-actions[bot]'
107+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
108+
109+
- name: Drop old versions
110+
run: |
111+
cd gh-pages
112+
readarray -t old_version < <(git log --format='%h' -- "${GITHUB_REF_NAME}" | tail -n +10)
113+
GIT_SEQUENCE_EDITOR="sed -i '1 i break'" git rebase --interactive --committer-date-is-author-date --root
114+
for commit in "${old_version[@]}"; do
115+
sed -i "/${commit}/d" .git/rebase-merge/git-rebase-todo
116+
done
117+
git rebase --continue
118+
119+
- name: Download bin from artifacts
120+
uses: actions/download-artifact@v3
121+
with:
122+
name: bin-ipq50xx-arm
123+
path: bin/
124+
125+
- name: Copy contents
126+
run: |
127+
version="$(cat "bin/version.buildinfo")"
128+
mkdir -p "gh-pages/${GITHUB_REF_NAME}/${version}/"
129+
cp -avr bin/packages/* "gh-pages/${GITHUB_REF_NAME}/${version}/"
130+
131+
- name: Commit
132+
run: |
133+
cd gh-pages
134+
git add .
135+
git commit -m "Add: ${GITHUB_REF_NAME}: $(cat ../bin/version.buildinfo)"
136+
137+
- name: Publish
138+
run: |
139+
cd gh-pages
140+
git push -f origin gh-pages
141+
142+
release:
143+
needs: [ build ]
144+
runs-on: ubuntu-20.04
145+
permissions:
146+
contents: write
147+
steps:
148+
- name: Checkout
149+
uses: actions/checkout@v3
150+
151+
- name: Download dl from artifacts
152+
uses: actions/download-artifact@v3
153+
with:
154+
name: dl
155+
path: dl/
156+
157+
- name: Download bin from artifacts
158+
uses: actions/download-artifact@v3
159+
with:
160+
name: bin-ipq50xx-arm
161+
path: bin/targets/ipq50xx/arm/
162+
163+
- name: Tar
164+
run: |
165+
tar cvf dl.tar -C dl/ .
166+
tar cvf bin-ipq50xx.tar -C bin/targets/ipq50xx/arm/ .
167+
168+
- name: Generate release informations
169+
run: |
170+
TIME="$(curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | jq -r .created_at)"
171+
172+
TAG="ci-${GITHUB_REF_NAME}-$(date -d "${TIME}" -u +'%Y%m%d-%H%M%S-%Z')"
173+
echo "TAG=$TAG" >>$GITHUB_ENV
174+
175+
cat <<EOF | sed -E 's/^ //' >Release.md
176+
CI ${GITHUB_REF_NAME} $(date -d "${TIME}" -u +'%Y-%m-%d %H:%M:%S %Z(%:z)')
177+
178+
# ${GITHUB_REF_NAME}
179+
180+
Build time: \`$(date -d "${TIME}" -u +'%Y-%m-%d %H:%M:%S %Z(%:z)')\`
181+
Release version: ${TAG}
182+
183+
## Sources
184+
$(cat bin/targets/ipq50xx/arm/feeds.buildinfo | awk -F'[ ^]' '{printf "%s: `%s`\n", $2, $4}')
185+
186+
## SHA256
187+
$(cat bin/targets/ipq50xx/arm/sha256sums | awk '{printf "%s: `%s`\n", $2, $1}' | sed -E 's/^\*//')
188+
EOF
189+
190+
echo "NAME=$(head --line=1 Release.md)" >>$GITHUB_ENV
191+
tail --line=+2 Release.md >Body.md
192+
193+
- name: Release
194+
uses: softprops/action-gh-release@v1
195+
with:
196+
tag_name: ${{ env.TAG }}
197+
target_commitish: ${{ github.sha }}
198+
name: ${{ env.NAME }}
199+
body_path: Body.md
200+
files: |
201+
bin/targets/ipq50xx/arm/sha256sums
202+
bin/targets/ipq50xx/arm/*.*
203+
*.tar

0 commit comments

Comments
 (0)