Skip to content

Commit 580ccf7

Browse files
committed
Use GHA to build
1 parent e219313 commit 580ccf7

File tree

1 file changed

+183
-0
lines changed

1 file changed

+183
-0
lines changed

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)