Skip to content

Commit 8b83a06

Browse files
committed
Use GHA to build
1 parent 0f37580 commit 8b83a06

File tree

1 file changed

+178
-0
lines changed

1 file changed

+178
-0
lines changed

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)