openwrt-package.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. name: openwrt-package
  2. # Builds the OpenWrt packages for the released agent and attaches them to the
  3. # published release:
  4. # - netpulse-agent as .ipk (24.10 SDK, mediatek/filogic) and .apk (25.12
  5. # SDK, armsr/armv8 -> aarch64_generic, instalable en aarch64 genérico y
  6. # en cortex-a53, cubriendo routers fuera de cortex-a53). Also built for
  7. # x86/64 (amd64 binary) since #672.
  8. # - luci-app-netpulse (arch all) as .ipk and .apk (#236).
  9. # - netpulse on-box server as .ipk and .apk (#364), also for x86/64 (#672).
  10. #
  11. # Triggered on v* tag pushes, the SAME event that runs release.yml. It does
  12. # not rely on the `release` event for goreleaser-published releases: goreleaser
  13. # creates releases with the workflow GITHUB_TOKEN, and events triggered by the
  14. # GITHUB_TOKEN do not start new workflow runs
  15. # (https://docs.github.com/en/actions/concepts/security/github_token). So this
  16. # workflow runs in parallel with release.yml and waits for the agent tarballs
  17. # before attaching packages. The `release: published` trigger stays for
  18. # manually published releases.
  19. on:
  20. push:
  21. tags: ['v*']
  22. release:
  23. types: [published]
  24. workflow_dispatch:
  25. inputs:
  26. version:
  27. description: 'Release tag (ej: v2.6.0)'
  28. required: true
  29. permissions:
  30. contents: write
  31. jobs:
  32. package-agent:
  33. runs-on: ubuntu-latest
  34. strategy:
  35. fail-fast: false
  36. matrix:
  37. include:
  38. - sdk-version: 24.10.5
  39. sdk-target: mediatek/filogic
  40. format: ipk
  41. goarch: arm64
  42. - sdk-version: 25.12.5
  43. sdk-target: armsr/armv8
  44. format: apk
  45. goarch: arm64
  46. - sdk-version: 24.10.5
  47. sdk-target: x86/64
  48. format: ipk
  49. goarch: amd64
  50. - sdk-version: 25.12.5
  51. sdk-target: x86/64
  52. format: apk
  53. goarch: amd64
  54. steps:
  55. - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
  56. - name: Resolve release tag
  57. id: tag
  58. run: |
  59. if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
  60. echo "tag=${{ inputs.version }}" >> "$GITHUB_OUTPUT"
  61. elif [ "${{ github.event_name }}" = "push" ]; then
  62. echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
  63. else
  64. echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
  65. fi
  66. - name: Wait for agent tarballs on the release
  67. env:
  68. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  69. TAG: ${{ steps.tag.outputs.tag }}
  70. run: |
  71. for i in $(seq 1 80); do
  72. assets="$(gh release view "$TAG" --json assets --jq '.assets[].name' 2>/dev/null || true)"
  73. if printf '%s\n' "$assets" | grep -q "netpulse-agent_.*_linux_${{ matrix.goarch }}.tar.gz" \
  74. && printf '%s\n' "$assets" | grep -qx 'checksums.txt'; then
  75. echo "Agent tarballs and checksums present after $i attempts"
  76. exit 0
  77. fi
  78. echo "Waiting for agent tarballs and checksums ($i/80)..."
  79. sleep 15
  80. done
  81. echo "ERROR: agent tarballs or checksums not found on $TAG after 20 min" >&2
  82. exit 1
  83. - name: Download netpulse-agent ${{ matrix.goarch }} binary
  84. env:
  85. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  86. TAG: ${{ steps.tag.outputs.tag }}
  87. run: |
  88. gh release download "$TAG" -p "netpulse-agent_*_linux_${{ matrix.goarch }}.tar.gz" -p checksums.txt --dir /tmp/agent
  89. cd /tmp/agent
  90. asset="$(ls netpulse-agent_*_linux_${{ matrix.goarch }}.tar.gz)"
  91. awk -v n="$asset" '{candidate=$NF; sub(/^\*/, "", candidate); if (candidate == n) print}' checksums.txt > agent-checksums.txt
  92. test -s agent-checksums.txt
  93. sha256sum -c agent-checksums.txt
  94. tar xzf "$asset"
  95. ls -la netpulse-agent
  96. file netpulse-agent
  97. - name: Package ${{ matrix.format }} (SDK ${{ matrix.sdk-version }})
  98. env:
  99. TAG: ${{ steps.tag.outputs.tag }}
  100. run: |
  101. chmod +x deploy/openwrt/package.sh
  102. export PKG_VERSION="${TAG#v}"
  103. export PKG_RELEASE="1"
  104. deploy/openwrt/package.sh \
  105. "${{ matrix.sdk-version }}" \
  106. "${{ matrix.sdk-target }}" \
  107. "" \
  108. "${{ matrix.format }}" \
  109. /tmp/agent/netpulse-agent
  110. - name: Upload to release
  111. env:
  112. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  113. TAG: ${{ steps.tag.outputs.tag }}
  114. run: |
  115. echo "Packages generated:"
  116. ls -la dist/packages/
  117. gh release upload "$TAG" dist/packages/*.${{ matrix.format }} --clobber
  118. package-luci:
  119. runs-on: ubuntu-latest
  120. strategy:
  121. fail-fast: false
  122. matrix:
  123. include:
  124. - sdk-version: 24.10.5
  125. sdk-target: mediatek/filogic
  126. format: ipk
  127. - sdk-version: 25.12.5
  128. sdk-target: qualcommax/ipq807x
  129. format: apk
  130. steps:
  131. - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
  132. - name: Resolve release tag
  133. id: tag
  134. run: |
  135. if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
  136. echo "tag=${{ inputs.version }}" >> "$GITHUB_OUTPUT"
  137. elif [ "${{ github.event_name }}" = "push" ]; then
  138. echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
  139. else
  140. echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
  141. fi
  142. - name: Wait for agent tarballs on the release
  143. env:
  144. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  145. TAG: ${{ steps.tag.outputs.tag }}
  146. run: |
  147. for i in $(seq 1 80); do
  148. if gh release view "$TAG" --json assets --jq '.assets[].name' 2>/dev/null | grep -q 'netpulse-agent_.*_linux_arm64.tar.gz'; then
  149. echo "Release ready after $i attempts"
  150. exit 0
  151. fi
  152. echo "Waiting for release assets ($i/80)..."
  153. sleep 15
  154. done
  155. echo "ERROR: agent tarballs not found on $TAG after 20 min" >&2
  156. exit 1
  157. - name: Package luci-app-netpulse ${{ matrix.format }} (SDK ${{ matrix.sdk-version }})
  158. env:
  159. TAG: ${{ steps.tag.outputs.tag }}
  160. run: |
  161. chmod +x deploy/openwrt/package-luci.sh
  162. export PKG_VERSION="${TAG#v}"
  163. export PKG_RELEASE="1"
  164. deploy/openwrt/package-luci.sh \
  165. "${{ matrix.sdk-version }}" \
  166. "${{ matrix.sdk-target }}" \
  167. "" \
  168. "${{ matrix.format }}"
  169. - name: Upload to release
  170. env:
  171. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  172. TAG: ${{ steps.tag.outputs.tag }}
  173. run: |
  174. echo "LuCI packages generated:"
  175. ls -la dist/packages/
  176. gh release upload "$TAG" dist/packages/*.${{ matrix.format }} --clobber
  177. package-server:
  178. runs-on: ubuntu-latest
  179. strategy:
  180. fail-fast: false
  181. matrix:
  182. include:
  183. - sdk-version: 24.10.5
  184. sdk-target: mediatek/filogic
  185. format: ipk
  186. goarch: arm64
  187. - sdk-version: 25.12.5
  188. sdk-target: armsr/armv8
  189. format: apk
  190. goarch: arm64
  191. - sdk-version: 24.10.5
  192. sdk-target: x86/64
  193. format: ipk
  194. goarch: amd64
  195. - sdk-version: 25.12.5
  196. sdk-target: x86/64
  197. format: apk
  198. goarch: amd64
  199. steps:
  200. - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
  201. - name: Resolve release tag
  202. id: tag
  203. run: |
  204. if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
  205. echo "tag=${{ inputs.version }}" >> "$GITHUB_OUTPUT"
  206. elif [ "${{ github.event_name }}" = "push" ]; then
  207. echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
  208. else
  209. echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
  210. fi
  211. - name: Wait for server tarball on the release
  212. env:
  213. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  214. TAG: ${{ steps.tag.outputs.tag }}
  215. run: |
  216. for i in $(seq 1 80); do
  217. assets="$(gh release view "$TAG" --json assets --jq '.assets[].name' 2>/dev/null || true)"
  218. if printf '%s\n' "$assets" | grep -q "netpulse_.*_linux_${{ matrix.goarch }}.tar.gz" \
  219. && printf '%s\n' "$assets" | grep -qx 'checksums.txt'; then
  220. echo "Server tarball and checksums present after $i attempts"
  221. exit 0
  222. fi
  223. echo "Waiting for server tarball and checksums ($i/80)..."
  224. sleep 15
  225. done
  226. echo "ERROR: server tarball or checksums not found on $TAG after 20 min" >&2
  227. exit 1
  228. - name: Download netpulse server ${{ matrix.goarch }} binary
  229. env:
  230. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  231. TAG: ${{ steps.tag.outputs.tag }}
  232. run: |
  233. gh release download "$TAG" -p "netpulse_*_linux_${{ matrix.goarch }}.tar.gz" -p checksums.txt --dir /tmp/server
  234. cd /tmp/server
  235. asset="$(ls netpulse_*_linux_${{ matrix.goarch }}.tar.gz)"
  236. awk -v n="$asset" '{candidate=$NF; sub(/^\*/, "", candidate); if (candidate == n) print}' checksums.txt > server-checksums.txt
  237. test -s server-checksums.txt
  238. sha256sum -c server-checksums.txt
  239. tar xzf "$asset"
  240. ls -la netpulse
  241. file netpulse
  242. - name: Package ${{ matrix.format }} (SDK ${{ matrix.sdk-version }})
  243. env:
  244. TAG: ${{ steps.tag.outputs.tag }}
  245. run: |
  246. chmod +x deploy/openwrt/package-server.sh
  247. export PKG_VERSION="${TAG#v}"
  248. export PKG_RELEASE="1"
  249. deploy/openwrt/package-server.sh \
  250. "${{ matrix.sdk-version }}" \
  251. "${{ matrix.sdk-target }}" \
  252. "" \
  253. "${{ matrix.format }}" \
  254. /tmp/server/netpulse
  255. - name: Upload to release
  256. env:
  257. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  258. TAG: ${{ steps.tag.outputs.tag }}
  259. run: |
  260. echo "Server packages generated:"
  261. ls -la dist/packages/
  262. # netpulse_<v>_*.ipk (no colisiona con el tarball netpulse_<v>_linux_*)
  263. files=$(ls dist/packages/netpulse[-_]*.${{ matrix.format }} 2>/dev/null || true)
  264. if [ -z "$files" ]; then
  265. echo "ERROR: no server package produced" >&2
  266. exit 1
  267. fi
  268. gh release upload "$TAG" $files --clobber