forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 95
179 lines (146 loc) · 5.16 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: CI
on:
workflow_dispatch:
push:
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Install dependencies
run: |
sudo apt update
sudo apt install build-essential clang flex g++ gawk gcc-multilib gettext \
git libncurses5-dev libssl-dev python3-distutils rsync unzip zlib1g-dev
- name: Checkout
uses: actions/checkout@v3
- name: Hook the openwrt_core URL for opkg
run: |
TIME="$(curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | jq -r .created_at)"
echo "ci-$(date -d "${TIME}" -u +'%Y%m%d-%H%M%S')-${GITHUB_SHA:0:8}" >version
sed -i "s|%U/targets/%S/packages|https://hzyitc.github.io/openwrt-redmi-ax3000/${GITHUB_REF_NAME}/%R|" include/feeds.mk
- name: Update and install feeds
run: |
./scripts/feeds update -a
./scripts/feeds install -a
- name: Configure
run: |
cat <<EOF | sed -E 's/^ //' >.config
CONFIG_TARGET_ipq50xx=y
CONFIG_TARGET_ipq50xx_arm=y
CONFIG_TARGET_ipq50xx_arm_DEVICE_redmi_ax3000=y
CONFIG_IB=y
# CONFIG_IB_STANDALONE is not set
CONFIG_SDK=y
CONFIG_MAKE_TOOLCHAIN=y
CONFIG_ALL_NONSHARED=y
CONFIG_REPRODUCIBLE_DEBUG_INFO=y
CONFIG_PACKAGE_luci=y
EOF
make defconfig
- name: Download
run: |
make -j16 download
- name: Build tools
run: |
make -j$(nproc) tools/install
- name: Build toolchain
run: |
make -j$(nproc) toolchain/install
- name: Build all
run: |
make -j$(nproc) IGNORE_ERRORS=1
- name: Upload bin to artifacts
uses: actions/upload-artifact@v3
with:
name: bin-ipq50xx-arm
path: bin/targets/ipq50xx/arm/*
- name: Upload dl to artifacts
uses: actions/upload-artifact@v3
with:
name: dl
path: dl/*
gh-pages:
needs: [ build ]
runs-on: ubuntu-20.04
permissions:
contents: write
steps:
- name: Checkout gh-pages
uses: actions/checkout@v3
with:
path: 'gh-pages'
ref: 'gh-pages'
fetch-depth: 0
- name: Configure the git user
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Drop old versions
run: |
cd gh-pages
readarray -t old_version < <(git log --format='%h' -- "${GITHUB_REF_NAME}" | tail -n +10)
GIT_SEQUENCE_EDITOR="sed -i '1 i break'" git rebase -i --root
for commit in "${old_version[@]}"; do
sed -i "/${commit}/d" .git/rebase-merge/git-rebase-todo
done
git rebase --continue
- name: Download bin from artifacts
uses: actions/download-artifact@v3
with:
name: bin-ipq50xx-arm
path: bin/
- name: Copy contents
run: |
version="$(cat "bin/version.buildinfo")"
mkdir -p "gh-pages/${GITHUB_REF_NAME}/${version}/"
cp -avr bin/packages/* "gh-pages/${GITHUB_REF_NAME}/${version}/"
- name: Commit
run: |
cd gh-pages
git add .
git commit -m "Add: ${GITHUB_REF_NAME}: $(cat ../bin/version.buildinfo)"
- name: Publish
run: |
cd gh-pages
git push -f origin gh-pages
release:
needs: [ build ]
runs-on: ubuntu-20.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download dl from artifacts
uses: actions/download-artifact@v3
with:
name: dl
path: dl/
- name: Download bin from artifacts
uses: actions/download-artifact@v3
with:
name: bin-ipq50xx-arm
path: bin/targets/ipq50xx/arm/
- name: Tar
run: |
tar cvf dl.tar -C dl/ .
tar cvf bin-ipq50xx.tar -C bin/targets/ipq50xx/arm/ .
- name: Release
run: |
TIME="$(curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | jq -r .created_at)"
cat <<EOF | sed -E 's/^ //' >Release.md
CI ${GITHUB_REF_NAME} $(date -d "${TIME}" -u +'%Y-%m-%d %H:%M:%S %Z(%:z)')
# ${GITHUB_REF_NAME}
$(date -d "${TIME}" -u +'%Y-%m-%d %H:%M:%S %Z(%:z)')
## Sources
$(cat bin/targets/ipq50xx/arm/feeds.buildinfo | awk -F'[ ^]' '{print $2 ": `" $4 "`"}')
## SHA256
$(cat bin/targets/ipq50xx/arm/sha256sums | awk '{printf "%s: `%s`\n", $2, $1}' | sed -E 's/^\*//')
EOF
tag="ci-${GITHUB_REF_NAME}-$(date -d "${TIME}" -u +'%Y%m%d-%H%M%S-%Z')"
hub release create -t "$GITHUB_SHA" "$tag" -F Release.md --prerelease \
-a bin/targets/ipq50xx/arm/sha256sums \
$(for a in bin/targets/ipq50xx/arm/*.*; do echo -a "$a"; done) \
$(for a in *.tar; do echo -a "$a"; done)
env:
GITHUB_TOKEN: ${{ github.token }}