Skip to content

Commit 236b40b

Browse files
committed
add build workflow
1 parent 953933a commit 236b40b

1 file changed

Lines changed: 209 additions & 0 deletions

File tree

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
permissions:
2+
contents: write
3+
name: Build OpenWrt Package
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
name: Build for ${{ matrix.version }} / ${{ matrix.target }}
15+
runs-on: ubuntu-latest
16+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
17+
env:
18+
REPO_APK_KEY: ${{ secrets.REPO_APK_KEY }}
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
include:
24+
# 24.10 (ipk, frozen — do not expand)
25+
- version: openwrt-24.10
26+
target: x86_64
27+
- version: openwrt-24.10
28+
target: aarch64_cortex-a53
29+
- version: openwrt-24.10
30+
target: aarch64_generic
31+
- version: openwrt-24.10
32+
target: arm_cortex-a7
33+
- version: openwrt-24.10
34+
target: arm_cortex-a9
35+
- version: openwrt-24.10
36+
target: mips_24kc
37+
- version: openwrt-24.10
38+
target: mipsel_24kc
39+
# 25.12 (apk, all OpenWrt-supported arches)
40+
- version: openwrt-25.12
41+
target: aarch64_cortex-a53
42+
- version: openwrt-25.12
43+
target: aarch64_cortex-a72
44+
- version: openwrt-25.12
45+
target: aarch64_cortex-a76
46+
- version: openwrt-25.12
47+
target: aarch64_generic
48+
- version: openwrt-25.12
49+
target: arm_arm1176jzf-s_vfp
50+
- version: openwrt-25.12
51+
target: arm_arm926ej-s
52+
- version: openwrt-25.12
53+
target: arm_cortex-a15_neon-vfpv4
54+
- version: openwrt-25.12
55+
target: arm_cortex-a5_vfpv4
56+
- version: openwrt-25.12
57+
target: arm_cortex-a7
58+
- version: openwrt-25.12
59+
target: arm_cortex-a7_neon-vfpv4
60+
- version: openwrt-25.12
61+
target: arm_cortex-a7_vfpv4
62+
- version: openwrt-25.12
63+
target: arm_cortex-a8_vfpv3
64+
- version: openwrt-25.12
65+
target: arm_cortex-a9
66+
- version: openwrt-25.12
67+
target: arm_cortex-a9_neon
68+
- version: openwrt-25.12
69+
target: arm_cortex-a9_vfpv3-d16
70+
- version: openwrt-25.12
71+
target: arm_fa526
72+
- version: openwrt-25.12
73+
target: arm_xscale
74+
- version: openwrt-25.12
75+
target: armeb_xscale
76+
- version: openwrt-25.12
77+
target: i386_pentium-mmx
78+
- version: openwrt-25.12
79+
target: i386_pentium4
80+
- version: openwrt-25.12
81+
target: loongarch64_generic
82+
- version: openwrt-25.12
83+
target: mips64_mips64r2
84+
- version: openwrt-25.12
85+
target: mips64_octeonplus
86+
- version: openwrt-25.12
87+
target: mips64el_mips64r2
88+
- version: openwrt-25.12
89+
target: mips_24kc
90+
- version: openwrt-25.12
91+
target: mips_mips32
92+
- version: openwrt-25.12
93+
target: mipsel_24kc
94+
- version: openwrt-25.12
95+
target: mipsel_24kc_24kf
96+
- version: openwrt-25.12
97+
target: mipsel_74kc
98+
- version: openwrt-25.12
99+
target: mipsel_mips32
100+
- version: openwrt-25.12
101+
target: powerpc64_e5500
102+
- version: openwrt-25.12
103+
target: powerpc_464fp
104+
- version: openwrt-25.12
105+
target: powerpc_8548
106+
- version: openwrt-25.12
107+
target: riscv64_generic
108+
- version: openwrt-25.12
109+
target: x86_64
110+
111+
steps:
112+
- name: 🧾 Checkout repo
113+
uses: actions/checkout@v5
114+
115+
- name: 📛 Set PKG_NAME from repo
116+
run: echo "PKG_NAME=${{ github.event.repository.name }}" >> "$GITHUB_ENV"
117+
118+
- name: 🧰 Set up melmac feed structure
119+
run: |
120+
# Create a proper OpenWrt feed layout where each package lives in its own subdir
121+
mkdir -p feed/${PKG_NAME}
122+
# Copy the package sources into the feed subdir (exclude CI and feed itself)
123+
rsync -av \
124+
--exclude='.git' \
125+
--exclude='feed' \
126+
--exclude='.github' \
127+
./ feed/${PKG_NAME}/
128+
129+
- name: 🧮 Compute ARCH
130+
run: |
131+
if [ "${{ matrix.version }}" = "snapshots" ]; then
132+
echo "ARCH=${{ matrix.target }}-SNAPSHOT" >> "$GITHUB_ENV"
133+
else
134+
echo "ARCH=${{ matrix.target }}-${{ matrix.version }}" >> "$GITHUB_ENV"
135+
fi
136+
137+
- name: 🏗️ Build with OpenWrt SDK
138+
uses: openwrt/gh-action-sdk@v8
139+
env:
140+
ARCH: ${{ env.ARCH }}
141+
FEEDNAME: melmac
142+
PACKAGES: ${{ env.PKG_NAME }}
143+
INDEX: 0
144+
FEED_DIR: ${{ github.workspace }}/feed
145+
NO_SHFMT_CHECK: 1
146+
NO_REFRESH_CHECK: 1
147+
PRIVATE_KEY: ${{ secrets.REPO_APK_KEY }}
148+
149+
- name: 🏷️ Rename APK with version and target
150+
run: |
151+
set -euo pipefail
152+
PKG_VERSION=$(grep -E '^PKG_VERSION *:?=' Makefile | head -n1 | cut -d= -f2 | tr -d '[:space:]')
153+
PKG_RELEASE=$(grep -E '^PKG_RELEASE *:?=' Makefile | head -n1 | cut -d= -f2 | tr -d '[:space:]')
154+
for ext in ipk apk; do
155+
for f in $(find bin/packages -type f -path "*/melmac/*.${ext}"); do
156+
dir=$(dirname "$f")
157+
if [ -n "${{ matrix.suffix }}" ]; then
158+
mv -v "$f" "$dir/${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}_${{ matrix.version }}_${{ matrix.suffix }}.${ext}"
159+
else
160+
mv -v "$f" "$dir/${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}_${{ matrix.version }}_${{ matrix.target }}.${ext}"
161+
fi
162+
done
163+
done
164+
165+
- name: 📦 Upload artifact for ${{ matrix.target }}
166+
uses: actions/upload-artifact@v4
167+
with:
168+
name: ${{ env.PKG_NAME }}-${{ matrix.target }}-${{ matrix.version }}
169+
path: |
170+
bin/packages/*/melmac/${{ env.PKG_NAME }}*.ipk
171+
bin/packages/*/melmac/${{ env.PKG_NAME }}*.apk
172+
if-no-files-found: ignore
173+
174+
release:
175+
name: Release ${{ github.repository }}
176+
needs: build
177+
if: ${{ always() }}
178+
runs-on: ubuntu-latest
179+
180+
steps:
181+
- name: 🧾 Checkout repo
182+
uses: actions/checkout@v5
183+
184+
- name: 🔍 Extract version and release from Makefile
185+
id: version
186+
run: |
187+
PKG_VERSION=$(grep -E '^PKG_VERSION *:?=' Makefile | head -n1 | cut -d= -f2 | tr -d '[:space:]')
188+
PKG_RELEASE=$(grep -E '^PKG_RELEASE *:?=' Makefile | head -n1 | cut -d= -f2 | tr -d '[:space:]')
189+
COMBINED_VERSION="${PKG_VERSION}-${PKG_RELEASE}"
190+
echo "📦 Version: $COMBINED_VERSION"
191+
echo "version=$COMBINED_VERSION" >> "$GITHUB_OUTPUT"
192+
193+
- name: ⬇️ Download all build artifacts
194+
uses: actions/download-artifact@v4
195+
with:
196+
path: ./release-assets
197+
198+
- name: 🗃️ Create GitHub Release
199+
uses: softprops/action-gh-release@v2
200+
with:
201+
tag_name: v${{ steps.version.outputs.version }}
202+
name: Build v${{ steps.version.outputs.version }}
203+
files: |
204+
./release-assets/**/*.ipk
205+
./release-assets/**/*.apk
206+
draft: false
207+
prerelease: false
208+
env:
209+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)