Skip to content

Commit 863ecd5

Browse files
committed
Use GHA to build
1 parent 4a64b22 commit 863ecd5

File tree

1 file changed

+188
-0
lines changed

1 file changed

+188
-0
lines changed

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)