Skip to content

Commit f2cde25

Browse files
committed
Use GHA to build
1 parent 9df1f89 commit f2cde25

File tree

1 file changed

+198
-0
lines changed

1 file changed

+198
-0
lines changed

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)