-
Notifications
You must be signed in to change notification settings - Fork 6
267 lines (229 loc) Β· 8.43 KB
/
Copy pathbuild-ipk.yml
File metadata and controls
267 lines (229 loc) Β· 8.43 KB
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
name: Build Beszel Agent IPK
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * 0'
env:
UPSTREAM_REPO: 'henrygd/beszel'
PACKAGE_NAME: 'beszel-agent'
jobs:
validate-versions:
runs-on: ubuntu-latest
outputs:
latest_upstream_version: ${{ steps.validate.outputs.latest_upstream_version }}
latest_repo_tag: ${{ steps.validate.outputs.latest_repo_tag }}
should_build: ${{ steps.validate.outputs.should_build }}
steps:
- name: Validate versions
id: validate
run: |
set -euo pipefail
LATEST_UPSTREAM=$(curl -s "https://api.github.com/repos/$UPSTREAM_REPO/releases/latest" | jq -r .tag_name)
echo "Latest upstream Beszel: $LATEST_UPSTREAM"
LATEST_REPO=$(curl -s "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r .tag_name)
echo "Latest repo release: $LATEST_REPO"
REPO_VERSION=${LATEST_REPO%%-*}
echo "Repo base version: $REPO_VERSION"
if [ "$LATEST_UPSTREAM" != "$REPO_VERSION" ]; then
echo "New version detected! Building $LATEST_UPSTREAM β $LATEST_UPSTREAM"
echo "latest_upstream_version=$LATEST_UPSTREAM" >> $GITHUB_OUTPUT
echo "latest_repo_tag=$LATEST_UPSTREAM-${{ matrix.branch }}" >> $GITHUB_OUTPUT
echo "should_build=true" >> $GITHUB_OUTPUT
else
echo "Versions match: $LATEST_UPSTREAM == $REPO_VERSION. No build needed."
echo "should_build=false" >> $GITHUB_OUTPUT
fi
build:
needs: validate-versions
if: needs.validate-versions.outputs.should_build == 'true'
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.prepare.outputs.tag }}
strategy:
fail-fast: false
matrix:
branch:
- openwrt-24.10
arch:
- aarch64_cortex-a53
- aarch64_cortex-a72
- aarch64_generic
- arm_cortex-a7_neon-vfpv4
- arm_cortex-a9
- mipsel_24kc
- x86_64
container:
image: openwrt/sdk:${{ matrix.arch }}-${{ matrix.branch }}
options: --user root
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache SDK downloads
uses: actions/cache@v4
with:
path: /builder/dl
key: openwrt-dl-${{ matrix.branch }}-${{ matrix.arch }}-${{ hashFiles('beszel-agent/Makefile') }}
restore-keys: |
openwrt-dl-${{ matrix.branch }}-${{ matrix.arch }}-
openwrt-dl-${{ matrix.branch }}-
- name: Setup SDK
working-directory: /builder
run: HOME=/builder ./setup.sh
- name: Prepare build
id: prepare
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="${{ needs.validate-versions.outputs.latest_upstream_version }}"
echo "Latest version: $TAG"
GOARCH=$(./scripts/arch-mapper.sh "${{ matrix.arch }}")
echo "Go architecture: $GOARCH"
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "goarch=$GOARCH" >> $GITHUB_OUTPUT
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
echo "Building version: $TAG for arch: $GOARCH"
- name: Install dependencies
working-directory: /builder
run: |
apt update && apt install -y upx-ucl
- name: Download and prepare binary
env:
VERSION: ${{ steps.prepare.outputs.version }}
GOARCH: ${{ steps.prepare.outputs.goarch }}
run: |
set -euo pipefail
./scripts/download-binary.sh "$VERSION" "$GOARCH" "./beszel-agent/files/usr/bin"
- name: Prepare package structure
working-directory: /builder
env:
VERSION: ${{ steps.prepare.outputs.version }}
run: |
set -euo pipefail
cp -r $GITHUB_WORKSPACE/beszel-agent package/beszel-agent
cp -r $GITHUB_WORKSPACE/packaging/files/* package/beszel-agent/files/
cp $GITHUB_WORKSPACE/packaging/Makefile.prebuilt package/beszel-agent/Makefile
echo "=== Package structure ==="
ls -laR package/beszel-agent/files/
- name: Build IPK
working-directory: /builder
env:
VERSION: ${{ steps.prepare.outputs.version }}
run: |
set -euo pipefail
echo "CONFIG_PACKAGE_beszel-agent=m" >> .config
make defconfig
make package/beszel-agent/compile V=s -j$(nproc) BUILD_LOG=1 \
BESZEL_VERSION="$VERSION"
- name: Collect artifacts
env:
ARCH: ${{ matrix.arch }}
BRANCH: ${{ matrix.branch }}
run: |
set -euo pipefail
echo "=== Searching for IPK files ==="
find /builder/bin/packages -name "beszel-agent*.ipk" -ls || true
mkdir -p $GITHUB_WORKSPACE/ipk-output
find /builder/bin/packages -name "beszel-agent*.ipk" -exec cp {} $GITHUB_WORKSPACE/ipk-output/ \;
cd $GITHUB_WORKSPACE/ipk-output
echo "=== Files in ipk-output ==="
ls -la
IPK_COUNT=$(ls beszel-agent*.ipk 2>/dev/null | wc -l)
if [[ $IPK_COUNT -eq 0 ]]; then
echo "ERROR: No IPK file found!" >&2
exit 1
fi
echo "Found $IPK_COUNT IPK file(s)"
VERSION_DIR="${BRANCH/openwrt-}/$ARCH"
mkdir -p "$VERSION_DIR"
mv *.ipk "$VERSION_DIR/"
cd "$VERSION_DIR"
sha256sum *.ipk > SHA256SUMS
cd $GITHUB_WORKSPACE/ipk-output
tar -cvf $GITHUB_WORKSPACE/ipk-$BRANCH-$ARCH.tar "$VERSION_DIR"
- name: Validate IPK package
env:
ARCH: ${{ matrix.arch }}
BRANCH: ${{ matrix.branch }}
run: |
set -euo pipefail
VERSION_DIR="${BRANCH/openwrt-}/$ARCH"
cd ipk-output/$VERSION_DIR
echo "=== Validating packages in $VERSION_DIR ==="
for ipk in *.ipk; do
size=$(stat -f%z "$ipk" 2>/dev/null || stat -c%s "$ipk")
if [[ $size -lt 10000 ]]; then
echo "ERROR: IPK file $ipk is too small ($size bytes)" >&2
exit 1
fi
echo "β $ipk size: $size bytes"
done
sha256sum -c SHA256SUMS
echo "β Package validation passed"
- name: Upload packages
if: success()
uses: actions/upload-artifact@v4
with:
name: ipk-${{ matrix.branch }}-${{ matrix.arch }}
path: |
ipk-output/**/*.ipk
ipk-output/**/SHA256SUMS
if-no-files-found: error
retention-days: 30
gh-pages:
needs: [validate-versions, build]
if: needs.validate-versions.outputs.should_build == 'true'
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: 'Beszel Agent ${{ needs.build.outputs.tag }}'
force_orphan: true
release:
needs: [validate-versions, build, gh-pages]
if: needs.validate-versions.outputs.should_build == 'true'
permissions:
contents: write
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
branch:
- '24.10'
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: ipk-*
- name: Prepare files
env:
BRANCH: ${{ matrix.branch }}
run: |
find . -name "ipk-openwrt-$BRANCH-*.tar" -exec tar -xvf {} --wildcards '*.ipk' \;
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
fail_on_unmatched_files: true
tag_name: ${{ needs.validate-versions.outputs.latest_repo_tag }}
name: ${{ needs.validate-versions.outputs.latest_repo_tag }} for OpenWrt ${{ matrix.branch }}
target_commitish: gh-pages
body: |
### Beszel Agent ${{ needs.validate-versions.outputs.latest_repo_tag }} for OpenWrt ${{ matrix.branch }}
files: ./**/*.ipk