Skip to content

Commit 350fbd8

Browse files
committed
Use GHA to build
1 parent 8715a17 commit 350fbd8

File tree

1 file changed

+189
-0
lines changed

1 file changed

+189
-0
lines changed

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)