Skip to content

Commit f9e0fa2

Browse files
committed
Use GHA to build
1 parent f782c21 commit f9e0fa2

File tree

1 file changed

+200
-0
lines changed

1 file changed

+200
-0
lines changed

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)