4
0

openwrt-package.yml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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@v4
  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. if gh release view "$TAG" --json assets --jq '.assets[].name' 2>/dev/null | grep -q "netpulse-agent_.*_linux_${{ matrix.goarch }}.tar.gz"; then
  73. echo "Agent tarballs present after $i attempts"
  74. exit 0
  75. fi
  76. echo "Waiting for agent tarballs ($i/80)..."
  77. sleep 15
  78. done
  79. echo "ERROR: agent tarballs not found on $TAG after 20 min" >&2
  80. exit 1
  81. - name: Download netpulse-agent ${{ matrix.goarch }} binary
  82. env:
  83. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  84. TAG: ${{ steps.tag.outputs.tag }}
  85. run: |
  86. gh release download "$TAG" -p "netpulse-agent_*_linux_${{ matrix.goarch }}.tar.gz" --dir /tmp/agent
  87. cd /tmp/agent
  88. tar xzf netpulse-agent_*_linux_${{ matrix.goarch }}.tar.gz
  89. ls -la netpulse-agent
  90. file netpulse-agent
  91. - name: Package ${{ matrix.format }} (SDK ${{ matrix.sdk-version }})
  92. env:
  93. TAG: ${{ steps.tag.outputs.tag }}
  94. run: |
  95. chmod +x deploy/openwrt/package.sh
  96. export PKG_VERSION="${TAG#v}"
  97. export PKG_RELEASE="1"
  98. deploy/openwrt/package.sh \
  99. "${{ matrix.sdk-version }}" \
  100. "${{ matrix.sdk-target }}" \
  101. "" \
  102. "${{ matrix.format }}" \
  103. /tmp/agent/netpulse-agent
  104. - name: Upload to release
  105. env:
  106. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  107. TAG: ${{ steps.tag.outputs.tag }}
  108. run: |
  109. echo "Packages generated:"
  110. ls -la dist/packages/
  111. gh release upload "$TAG" dist/packages/*.${{ matrix.format }} --clobber
  112. package-luci:
  113. runs-on: ubuntu-latest
  114. strategy:
  115. fail-fast: false
  116. matrix:
  117. include:
  118. - sdk-version: 24.10.5
  119. sdk-target: mediatek/filogic
  120. format: ipk
  121. - sdk-version: 25.12.5
  122. sdk-target: qualcommax/ipq807x
  123. format: apk
  124. steps:
  125. - uses: actions/checkout@v4
  126. - name: Resolve release tag
  127. id: tag
  128. run: |
  129. if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
  130. echo "tag=${{ inputs.version }}" >> "$GITHUB_OUTPUT"
  131. elif [ "${{ github.event_name }}" = "push" ]; then
  132. echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
  133. else
  134. echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
  135. fi
  136. - name: Wait for agent tarballs on the release
  137. env:
  138. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  139. TAG: ${{ steps.tag.outputs.tag }}
  140. run: |
  141. for i in $(seq 1 80); do
  142. if gh release view "$TAG" --json assets --jq '.assets[].name' 2>/dev/null | grep -q 'netpulse-agent_.*_linux_arm64.tar.gz'; then
  143. echo "Release ready after $i attempts"
  144. exit 0
  145. fi
  146. echo "Waiting for release assets ($i/80)..."
  147. sleep 15
  148. done
  149. echo "ERROR: agent tarballs not found on $TAG after 20 min" >&2
  150. exit 1
  151. - name: Package luci-app-netpulse ${{ matrix.format }} (SDK ${{ matrix.sdk-version }})
  152. env:
  153. TAG: ${{ steps.tag.outputs.tag }}
  154. run: |
  155. chmod +x deploy/openwrt/package-luci.sh
  156. export PKG_VERSION="${TAG#v}"
  157. export PKG_RELEASE="1"
  158. deploy/openwrt/package-luci.sh \
  159. "${{ matrix.sdk-version }}" \
  160. "${{ matrix.sdk-target }}" \
  161. "" \
  162. "${{ matrix.format }}"
  163. - name: Upload to release
  164. env:
  165. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  166. TAG: ${{ steps.tag.outputs.tag }}
  167. run: |
  168. echo "LuCI packages generated:"
  169. ls -la dist/packages/
  170. gh release upload "$TAG" dist/packages/*.${{ matrix.format }} --clobber
  171. package-server:
  172. runs-on: ubuntu-latest
  173. strategy:
  174. fail-fast: false
  175. matrix:
  176. include:
  177. - sdk-version: 24.10.5
  178. sdk-target: mediatek/filogic
  179. format: ipk
  180. goarch: arm64
  181. - sdk-version: 25.12.5
  182. sdk-target: armsr/armv8
  183. format: apk
  184. goarch: arm64
  185. - sdk-version: 24.10.5
  186. sdk-target: x86/64
  187. format: ipk
  188. goarch: amd64
  189. - sdk-version: 25.12.5
  190. sdk-target: x86/64
  191. format: apk
  192. goarch: amd64
  193. steps:
  194. - uses: actions/checkout@v4
  195. - name: Resolve release tag
  196. id: tag
  197. run: |
  198. if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
  199. echo "tag=${{ inputs.version }}" >> "$GITHUB_OUTPUT"
  200. elif [ "${{ github.event_name }}" = "push" ]; then
  201. echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
  202. else
  203. echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
  204. fi
  205. - name: Wait for server tarball on the release
  206. env:
  207. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  208. TAG: ${{ steps.tag.outputs.tag }}
  209. run: |
  210. for i in $(seq 1 80); do
  211. if gh release view "$TAG" --json assets --jq '.assets[].name' 2>/dev/null | grep -q "netpulse_.*_linux_${{ matrix.goarch }}.tar.gz"; then
  212. echo "Server tarball present after $i attempts"
  213. exit 0
  214. fi
  215. echo "Waiting for server tarball ($i/80)..."
  216. sleep 15
  217. done
  218. echo "ERROR: server tarball not found on $TAG after 20 min" >&2
  219. exit 1
  220. - name: Download netpulse server ${{ matrix.goarch }} binary
  221. env:
  222. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  223. TAG: ${{ steps.tag.outputs.tag }}
  224. run: |
  225. gh release download "$TAG" -p "netpulse_*_linux_${{ matrix.goarch }}.tar.gz" --dir /tmp/server
  226. cd /tmp/server
  227. tar xzf netpulse_*_linux_${{ matrix.goarch }}.tar.gz
  228. ls -la netpulse
  229. file netpulse
  230. - name: Package ${{ matrix.format }} (SDK ${{ matrix.sdk-version }})
  231. env:
  232. TAG: ${{ steps.tag.outputs.tag }}
  233. run: |
  234. chmod +x deploy/openwrt/package-server.sh
  235. export PKG_VERSION="${TAG#v}"
  236. export PKG_RELEASE="1"
  237. deploy/openwrt/package-server.sh \
  238. "${{ matrix.sdk-version }}" \
  239. "${{ matrix.sdk-target }}" \
  240. "" \
  241. "${{ matrix.format }}" \
  242. /tmp/server/netpulse
  243. - name: Upload to release
  244. env:
  245. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  246. TAG: ${{ steps.tag.outputs.tag }}
  247. run: |
  248. echo "Server packages generated:"
  249. ls -la dist/packages/
  250. # netpulse_<v>_*.ipk (no colisiona con el tarball netpulse_<v>_linux_*)
  251. files=$(ls dist/packages/netpulse[-_]*.${{ matrix.format }} 2>/dev/null || true)
  252. if [ -z "$files" ]; then
  253. echo "ERROR: no server package produced" >&2
  254. exit 1
  255. fi
  256. gh release upload "$TAG" $files --clobber