Skip to content

Commit 6472314

Browse files
committed
Use GHA to build
1 parent b0f6054 commit 6472314

File tree

1 file changed

+205
-0
lines changed

1 file changed

+205
-0
lines changed

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)