| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- name: release
- # Release estable por tag v*: goreleaser construye netpulse (con el frontend
- # embebido) y netpulse-collector para linux/amd64|arm64|armv7 + checksums.txt.
- # install.sh / install-collector.sh consumen estos assets.
- # Distinto de go.yml: aquello publica binarios rolling del commit en la
- # prerelease go-latest (para el updater del CT 226); esto publica versiones.
- on:
- push:
- tags: ['v*']
- workflow_dispatch: # sin tag = snapshot de prueba (no publica release)
- permissions:
- contents: write
- jobs:
- release:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0 # tags e historia: el gate de agent/VERSION difiere contra el tag anterior
- - uses: actions/setup-node@v4
- with:
- node-version: 24
- cache: npm
- cache-dependency-path: app/package-lock.json
- - uses: actions/setup-go@v5
- with:
- go-version: '1.26'
- cache-dependency-path: |
- server-go/go.sum
- collector/go.sum
- # Versión del agente: fuente única de verdad en agent/VERSION (#790),
- # desacoplada del tag del server. Se inyecta igual en el binario del
- # agente (main.Version) y en el servidor (agentbin.EmbeddedAgentVersion
- # vía .goreleaser.yaml): alimenta el campo updateAvailable de
- # GET /api/agents, así que solo debe subir cuando el código de agent/
- # cambia de verdad. Gate de consistencia: si agent/ cambió desde el tag
- # anterior y agent/VERSION no subió, la release falla (obliga al bump).
- - name: Resuelve AGENT_VERSION desde agent/VERSION
- id: version
- run: |
- set -e
- AGENT_VERSION=$(tr -d '[:space:]' < agent/VERSION)
- if [ -z "$AGENT_VERSION" ]; then
- echo "::error::agent/VERSION está vacío"
- exit 1
- fi
- echo "agent=$AGENT_VERSION" >> "$GITHUB_OUTPUT"
- PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true)
- if [ -n "$PREV_TAG" ]; then
- if ! git diff --quiet "$PREV_TAG"..HEAD -- agent/; then
- PREV_AGENT=$(git show "$PREV_TAG:agent/VERSION" 2>/dev/null | tr -d '[:space:]' || true)
- if [ -n "$PREV_AGENT" ] && [ "$PREV_AGENT" = "$AGENT_VERSION" ]; then
- echo "::error::agent/ cambió desde $PREV_TAG pero agent/VERSION sigue en $AGENT_VERSION. Sube la versión del agente antes de taguear."
- exit 1
- fi
- fi
- fi
- - name: Build frontend + copia dist al embed (necesario para go:embed y tests)
- run: |
- npm ci --no-audit --no-fund --prefix app
- npm run build --prefix app
- rm -rf server-go/internal/staticspa/dist && cp -r app/dist server-go/internal/staticspa/dist
- # Antes de los tests: TestOpenArmVariants abre los binarios embebidos
- # (mismo orden que go.yml desde #459; aquí faltó aplicarlo y las
- # releases v2.25.0+ se quedaron sin assets). OJO los nombres: Open()
- # resuelve "agents/netpulse-agent-" + normalizeArch(arch) y esta mapea
- # armv7/armv7l/armhf -> arm, asi que el fichero se llama
- # netpulse-agent-arm (con GOARM=7), NO netpulse-agent-armv7 (#458).
- - name: Build agent binaries para embed (todas las arquitecturas)
- env:
- CGO_ENABLED: 0
- GOOS: linux
- run: |
- set -e
- # amd64
- (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)
- # arm64
- (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)
- # armv7 (fichero "arm": el nombre que busca normalizeArch)
- (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-arm ./cmd/netpulse-agent)
- # mipsle/mips softfloat (#488): MIPS sin FPU, ambos endianness
- (cd agent && GOARCH=mipsle GOMIPS=softfloat go build -trimpath -ldflags "-s -w -X main.Version=${{ steps.version.outputs.agent }}" -o ../server-go/internal/agentbin/agents/netpulse-agent-mipsle ./cmd/netpulse-agent)
- (cd agent && GOARCH=mips GOMIPS=softfloat go build -trimpath -ldflags "-s -w -X main.Version=${{ steps.version.outputs.agent }}" -o ../server-go/internal/agentbin/agents/netpulse-agent-mips ./cmd/netpulse-agent)
- - name: Tests Go (ambos módulos)
- run: |
- (cd server-go && go test ./...)
- (cd collector && go test ./...)
- - name: Valida config goreleaser
- uses: goreleaser/goreleaser-action@v6
- with:
- version: '~> v2'
- args: check
- - name: Release (tag v* — publica)
- if: github.ref_type == 'tag'
- uses: goreleaser/goreleaser-action@v6
- with:
- version: '~> v2'
- args: release --clean
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- AGENT_VERSION: ${{ steps.version.outputs.agent }}
- - name: Release (workflow_dispatch — snapshot sin publicar)
- if: github.ref_type != 'tag'
- uses: goreleaser/goreleaser-action@v6
- with:
- version: '~> v2'
- args: release --clean --snapshot
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- AGENT_VERSION: ${{ steps.version.outputs.agent }}
|