release.yml 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. name: release
  2. # Release estable por tag v*: goreleaser construye netpulse (con el frontend
  3. # embebido) y netpulse-collector para linux/amd64|arm64|armv7 + checksums.txt.
  4. # install.sh / install-collector.sh consumen estos assets.
  5. # Distinto de go.yml: aquello publica binarios rolling del commit en la
  6. # prerelease go-latest (para el updater del CT 226); esto publica versiones.
  7. on:
  8. push:
  9. tags: ['v*']
  10. workflow_dispatch: # sin tag = snapshot de prueba (no publica release)
  11. permissions:
  12. contents: write
  13. jobs:
  14. release:
  15. runs-on: ubuntu-latest
  16. steps:
  17. - uses: actions/checkout@v4
  18. - uses: actions/setup-node@v4
  19. with:
  20. node-version: 22
  21. cache: npm
  22. cache-dependency-path: app/package-lock.json
  23. - uses: actions/setup-go@v5
  24. with:
  25. go-version: '1.26'
  26. cache-dependency-path: |
  27. server-go/go.sum
  28. collector/go.sum
  29. # Versión del agente embebido en el servidor. Deriva del tag (v2.11.1 →
  30. # 2.11.1) y se inyecta igual en el binario del agente (main.Version) y en
  31. # el servidor (agentbin.EmbeddedAgentVersion vía .goreleaser.yaml):
  32. # alimenta el campo updateAvailable de GET /api/agents. Con
  33. # workflow_dispatch (sin tag) cae a 0.0.0 para snapshots de prueba.
  34. - name: Resuelve AGENT_VERSION desde el tag
  35. id: version
  36. run: |
  37. if [ "${{ github.ref_type }}" = "tag" ]; then
  38. echo "agent=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
  39. else
  40. echo "agent=0.0.0" >> "$GITHUB_OUTPUT"
  41. fi
  42. - name: Build frontend + copia dist al embed (necesario para go:embed y tests)
  43. run: |
  44. npm ci --no-audit --no-fund --prefix app
  45. npm run build --prefix app
  46. rm -rf server-go/internal/staticspa/dist && cp -r app/dist server-go/internal/staticspa/dist
  47. - name: Tests Go (ambos módulos)
  48. run: |
  49. (cd server-go && go test ./...)
  50. (cd collector && go test ./...)
  51. - name: Build agent binaries para embed (todas las arquitecturas)
  52. env:
  53. CGO_ENABLED: 0
  54. GOOS: linux
  55. run: |
  56. set -e
  57. # amd64
  58. (cd agent && GOARCH=amd64 go build -trimpath -ldflags "-s -w -X main.Version=${{ steps.version.outputs.agent }}" -o ../server-go/internal/agentbin/agents/netpulse-agent-amd64 ./cmd/netpulse-agent)
  59. # arm64
  60. (cd agent && GOARCH=arm64 go build -trimpath -ldflags "-s -w -X main.Version=${{ steps.version.outputs.agent }}" -o ../server-go/internal/agentbin/agents/netpulse-agent-arm64 ./cmd/netpulse-agent)
  61. # armv7
  62. (cd agent && GOARCH=arm GOARM=7 go build -trimpath -ldflags "-s -w -X main.Version=${{ steps.version.outputs.agent }}" -o ../server-go/internal/agentbin/agents/netpulse-agent-armv7 ./cmd/netpulse-agent)
  63. - name: Valida config goreleaser
  64. uses: goreleaser/goreleaser-action@v6
  65. with:
  66. version: '~> v2'
  67. args: check
  68. - name: Release (tag v* — publica)
  69. if: github.ref_type == 'tag'
  70. uses: goreleaser/goreleaser-action@v6
  71. with:
  72. version: '~> v2'
  73. args: release --clean
  74. env:
  75. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  76. AGENT_VERSION: ${{ steps.version.outputs.agent }}
  77. - name: Release (workflow_dispatch — snapshot sin publicar)
  78. if: github.ref_type != 'tag'
  79. uses: goreleaser/goreleaser-action@v6
  80. with:
  81. version: '~> v2'
  82. args: release --clean --snapshot
  83. env:
  84. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  85. AGENT_VERSION: ${{ steps.version.outputs.agent }}