Skip to content

Commit 74dabe9

Browse files
committed
Use GHA to build
1 parent bd46dcd commit 74dabe9

File tree

1 file changed

+201
-0
lines changed

1 file changed

+201
-0
lines changed

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)