4
0

openwrt-package.yml 8.6 KB

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