release.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. - name: Build frontend + copia dist al embed (necesario para go:embed y tests)
  30. run: |
  31. npm ci --no-audit --no-fund --prefix app
  32. npm run build --prefix app
  33. rm -rf server-go/internal/staticspa/dist && cp -r app/dist server-go/internal/staticspa/dist
  34. - name: Tests Go (ambos módulos)
  35. run: |
  36. (cd server-go && go test ./...)
  37. (cd collector && go test ./...)
  38. - name: Build agent binaries para embed (todas las arquitecturas)
  39. env:
  40. CGO_ENABLED: 0
  41. GOOS: linux
  42. run: |
  43. set -e
  44. # amd64
  45. (cd agent && GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o ../server-go/internal/agentbin/agents/netpulse-agent-amd64 ./cmd/netpulse-agent)
  46. # arm64
  47. (cd agent && GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o ../server-go/internal/agentbin/agents/netpulse-agent-arm64 ./cmd/netpulse-agent)
  48. # armv7
  49. (cd agent && GOARCH=arm GOARM=7 go build -trimpath -ldflags "-s -w" -o ../server-go/internal/agentbin/agents/netpulse-agent-armv7 ./cmd/netpulse-agent)
  50. - name: Valida config goreleaser
  51. uses: goreleaser/goreleaser-action@v6
  52. with:
  53. version: '~> v2'
  54. args: check
  55. - name: Release (tag v* — publica)
  56. if: github.ref_type == 'tag'
  57. uses: goreleaser/goreleaser-action@v6
  58. with:
  59. version: '~> v2'
  60. args: release --clean
  61. env:
  62. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  63. - name: Release (workflow_dispatch — snapshot sin publicar)
  64. if: github.ref_type != 'tag'
  65. uses: goreleaser/goreleaser-action@v6
  66. with:
  67. version: '~> v2'
  68. args: release --clean --snapshot
  69. env:
  70. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}