-
Notifications
You must be signed in to change notification settings - Fork 0
281 lines (260 loc) · 9.72 KB
/
build.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
name: build
on:
workflow_dispatch:
# schedule:
# - cron: '0 6 * * *'
jobs:
check:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.gh.outputs.tag }}
date: ${{ steps.gh.outputs.date }}
sha: ${{ steps.gh.outputs.sha }}
url: ${{ steps.gh.outputs.url }}
message: ${{ steps.gh.outputs.message }}
is_active: ${{ steps.activity.outputs.is_active }}
steps:
- name: Get repo data via GH API
id: gh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: 'bol-van/zapret'
run: |
BRANCH=$(gh api repos/$REPO --jq '.default_branch')
DATE=$(gh api repos/$REPO/commits/$BRANCH --jq '.commit.committer.date')
{
echo "date=$(date --utc -d $DATE +%Y%m%d)"
echo "tag=$(gh api repos/$REPO/releases/latest --jq '.tag_name')"
echo "sha=$(gh api repos/$REPO/commits/$BRANCH --jq '.sha[0:7]')"
echo "url=$(gh api repos/$REPO/commits/$BRANCH --jq '.html_url')"
echo "message<<EOF"
gh api repos/$REPO/commits/$BRANCH --jq '.commit.message'
echo EOF
} >> $GITHUB_OUTPUT
echo "DATE=$DATE" >> $GITHUB_ENV
- name: Check for repo activity
id: activity
env:
DATE: ${{ env.DATE }}
URL: ${{ steps.gh.outputs.url }}
run: |
TIMESTAMP=$(date --utc -d $DATE +%s)
DAYS=$(( ( $(date --utc +%s) - $TIMESTAMP ) / 86400 ))
echo "Repository activity: $(date --utc -d $DATE)"
echo "Commit: $URL"
if [ "${{ github.event_name }}" != "schedule" ]; then
is_active=true
elif [[ $DAYS -lt 1 ]] ; then
is_active=true
else
echo "Repository not updated within last 24 hours."
is_active=false
fi
echo "is_active=$is_active" >> $GITHUB_OUTPUT
build:
needs: check
if: needs.check.outputs.is_active == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# branch:
# # - openwrt-19.07
# - openwrt-21.02
# - openwrt-22.03
# - openwrt-23.05
# arch:
# - aarch64_cortex-a53
# - aarch64_cortex-a72
# - aarch64_generic
# - arm_arm1176jzf-s_vfp
# - arm_arm926ej-s
# - arm_cortex-a15_neon-vfpv4
# - arm_cortex-a5_vfpv4
# - arm_cortex-a7
# - arm_cortex-a7_neon-vfpv4
# - arm_cortex-a7_vfpv4
# - arm_cortex-a8_vfpv3
# - arm_cortex-a9
# - arm_cortex-a9_neon
# - arm_cortex-a9_vfpv3-d16
# - arm_fa526
# - arm_mpcore
# - arm_xscale
# - mips64_octeonplus
# - mips_24kc
# - mips_4kec
# - mips_mips32
# - mipsel_24kc
# - mipsel_24kc_24kf
# - mipsel_74kc
# - mipsel_mips32
# - x86_64
include:
- branch: SNAPSHOT
arch: x86_64
# exclude:
# # - branch: openwrt-19.07
# # arch: arm_cortex-a7
# # - branch: openwrt-19.07
# # arch: arm_cortex-a7_vfpv4
# # - branch: openwrt-19.07
# # arch: mips_4kec
# - branch: openwrt-21.02
# arch: arm_cortex-a7_vfpv4
container:
image: openwrt/sdk:${{ matrix.arch }}-${{ matrix.branch }}
options: --user root
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: 'bol-van/zapret'
path: zapret
- name: Apply diff from PR
if: false
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget -qO- --header="Authorization: token $GH_TOKEN" https://api.github.com/repos/cli/cli/releases/latest | grep -Po '"tag_name": "v\K.+(?=")' |\
xargs -I{} wget -qO- https://github.com/cli/cli/releases/download/v{}/gh_{}_linux_amd64.tar.gz | tar -xz --wildcards '*/bin/gh' --strip-components=2
cd zapret && ../gh pr diff 413 | git apply -
- name: Set up SDK
if: ${{ matrix.branch == 'openwrt-23.05' || matrix.branch == 'SNAPSHOT' }}
working-directory: /builder
shell: bash
run: |
gpg --verbose --keyserver keyserver.ubuntu.com --recv-keys 0x1D53D1877742E911 ||\
gpg --verbose --import <(wget -qO- 'https://git.openwrt.org/?p=keyring.git;a=blob_plain;f=gpg/0x1D53D1877742E911.asc')
sed -r -i 's/^rm.+//' setup.sh
./setup.sh
ls -lh
- name: Set up ccache
uses: actions/cache@v4
with:
path: ${{ matrix.branch == 'openwrt-19.07' && '/home/build/openwrt/.ccache' || '/builder/.ccache' }}
key: ccache-${{ matrix.arch }}-${{ matrix.branch }}-${{ github.run_id }}
restore-keys: |
ccache-${{ matrix.arch }}-${{ matrix.branch }}-
- name: Build packages
id: build
continue-on-error: true
working-directory: ${{ matrix.branch == 'openwrt-19.07' && '/home/build/openwrt' || '/builder' }}
env:
# DATE: ${{ needs.check.outputs.date }}
TAG: ${{ needs.check.outputs.tag }}
# SHA: ${{ needs.check.outputs.sha }}
ARCH: ${{ matrix.arch }}
BRANCH: ${{ matrix.branch }}
SIGN_KEY: ${{ secrets.SIGN_PRIVATE_KEY }}
CCACHE_DIR: ${{ matrix.branch == 'openwrt-19.07' && '/home/build/openwrt/.ccache' || '/builder/.ccache' }}
shell: bash
run: |
# export PKG_VERSION=$(date --utc -d $DATE +%Y%m%d)
export PKG_VERSION=${TAG#v}
find $GITHUB_WORKSPACE/zapret -type d -path '*/package/zapret' -exec cp -vr {} ./package \;
cp -vr $GITHUB_WORKSPACE/zapret/tpws ./package/zapret/tpws/
cp -vr $GITHUB_WORKSPACE/zapret/nfq ./package/zapret/nfqws/
cp -vr $GITHUB_WORKSPACE/zapret/mdig ./package/zapret/mdig/
cp -vr $GITHUB_WORKSPACE/zapret/ip2net ./package/zapret/ip2net/
# find ./package/zapret -type f -name Makefile -exec sed 's/PKG_RELEASE.*//g' -i {} \;
mv feeds.conf.default feeds.conf
sed -e 's|base.*\.git|base https://github.com/openwrt/openwrt.git|' \
-e 's|packages.*\.git|packages https://github.com/openwrt/packages.git|' -i feeds.conf
./scripts/feeds update base packages
./scripts/feeds install -a
make defconfig
make package/{ip2net,nfqws,mdig,tpws}/compile V=s -j$(nproc) CONFIG_CCACHE=1 BUILD_LOG=1
find ./bin/packages/*/base -type f ! -regex ".*\(ip2net\|nfqws\|mdig\|tpws\).*\.[ai]pk$" -delete
echo "$SIGN_KEY" | base64 -d > key-build
make package/index
tar -C ./bin/packages/*/base -cvf $GITHUB_WORKSPACE/pkg-$BRANCH-$ARCH.tar --transform "s|^\./|${BRANCH/openwrt-}/$ARCH/|" --show-transformed-names .
./staging_dir/host/bin/ccache --max-size=10M --show-stats
- name: Compress build logs
if: always()
env:
ARCH: ${{ matrix.arch }}
BRANCH: ${{ matrix.branch }}
LOGS_DIR: ${{ matrix.branch == 'openwrt-19.07' && '/home/build/openwrt/logs' || '/builder/logs' }}
run: |
tar -cJvf logs-$BRANCH-$ARCH.tar.xz $LOGS_DIR
- name: Upload packages
if: steps.build.outcome == 'success'
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: pkg-${{ matrix.branch }}-${{ matrix.arch }}
path: pkg-*.tar
# if-no-files-found: error
- name: Upload build logs
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: logs-${{ matrix.branch }}-${{ matrix.arch }}
path: logs-*.tar.xz
gh-pages:
if: false
needs: [ check, build ]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: ipk-*
- name: Prepare files
run: |
mkdir public
find . -name 'ipk-*.tar' -exec tar -C ./public -xvf {} \;
- name: Deploy to GH pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
full_commit_message: ${{ needs.check.outputs.url }}
force_orphan: true
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
continue-on-error: true
release:
if: false
needs: [ check, gh-pages ]
permissions:
contents: write
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
branch:
# - '19.07'
- '21.02'
- '22.03'
- '23.05'
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: ipk-*
- name: Put ipk into zip
env:
BRANCH: ${{ matrix.branch }}
DATE: ${{ needs.check.outputs.date }}
run: |
mkdir -p public
find . -name "ipk-openwrt-$BRANCH-*.tar" -exec tar -xvf {} --wildcards '*.ipk' \;
find $BRANCH -mindepth 1 -type d -exec sh -c 'zip -0 ./public/zapret_${DATE}_$(basename {}).zip -j {} {}/*' \;
ls -lh ./public/*.zip
- name: Upload assets
uses: andelf/nightly-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: false
tag_name: ${{ matrix.branch }}
name: '${{ needs.check.outputs.date }} for OpenWrt ${{ matrix.branch }}'
body: |
${{ needs.check.outputs.url }}: ${{ needs.check.outputs.message }}
files: ./public/*.zip