Repository navigation
feat(devices): discover wired static-IP hosts via router ARP table (#… #273
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: go-server | |
| # Compila el backend Go (con app/dist embebido en el binario) y lo publica como | |
| # asset de la prerelease "go-latest" (el CT 226 tiene 512MB y no tiene Go; el | |
| # updater descarga el binario exacto de su commit: | |
| # netpulse-server-<sha>-linux-<arch>.tar.gz). | |
| # Sin filtro de rutas (#471): si un push a main no toca server-go/ ni app/ | |
| # no se publica asset de ese SHA, y el updater del CT se queda ofreciendo una | |
| # actualización imposible (cae al asset más viejo y current != latest para | |
| # siempre). Con este trigger, CADA SHA de main tiene su binario en go-latest. | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| cache-dependency-path: app/package-lock.json | |
| - name: ESLint (app) | |
| working-directory: app | |
| run: npm ci --no-audit --no-fund && npm run lint | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # publicar assets en la prerelease go-latest | |
| env: | |
| # Versión del agente embebido en el servidor. Se inyecta igual en el | |
| # binario del agente (main.Version) y en el servidor | |
| # (agentbin.EmbeddedAgentVersion): el campo updateAvailable de | |
| # GET /api/agents compara la versión reportada del agente contra esa | |
| # versión. Bumpear aquí y en agentbin.md el valor único de verdad. | |
| AGENT_VERSION: "2.26.11" | |
| strategy: | |
| matrix: | |
| arch: [amd64, arm64] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # tags necesarias para git describe (httpapi.Version) | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| 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 | |
| - name: Build frontend | |
| working-directory: app | |
| run: npm ci --no-audit --no-fund && npm run build | |
| - name: Copia dist al embed del binario | |
| run: 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 | |
| # y además go:embed los necesita presentes para compilar el servidor. | |
| # OJO los nombres: Open() resuelve "agents/netpulse-agent-" + normalizeArch(arch) | |
| # y normalizeArch mapea armv7/armv7l/armhf -> arm, así 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=$AGENT_VERSION" -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=$AGENT_VERSION" -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=$AGENT_VERSION" -o ../server-go/internal/agentbin/agents/netpulse-agent-arm ./cmd/netpulse-agent) | |
| # mipsle softfloat (MT7621 y resto de MIPS little-endian) y mips | |
| # softfloat (big-endian, ath79): sin FPU en ambos (#488) | |
| (cd agent && GOARCH=mipsle GOMIPS=softfloat go build -trimpath -ldflags "-s -w -X main.Version=$AGENT_VERSION" -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=$AGENT_VERSION" -o ../server-go/internal/agentbin/agents/netpulse-agent-mips ./cmd/netpulse-agent) | |
| - name: Tests Go | |
| working-directory: server-go | |
| run: go test ./... | |
| - name: Build binario (linux/${{ matrix.arch }}) | |
| working-directory: server-go | |
| env: | |
| CGO_ENABLED: 0 | |
| GOOS: linux | |
| GOARCH: ${{ matrix.arch }} | |
| # -X updater.BuildCommit: sin esto el updater del CT cae a git rev-parse | |
| # (repo stale dubious-ownership) y reporta un SHA viejo → falso "update | |
| # available" permanente aunque el binario sea el de main HEAD. | |
| # -X agentbin.EmbeddedAgentVersion: la versión del agente embebido; | |
| # alimenta el campo updateAvailable de GET /api/agents. | |
| # -X httpapi.Version: la versión semver del último tag (rolling por | |
| # commit no tiene versión propia; reporta la del release más reciente). | |
| run: | | |
| VER=$(git describe --tags --abbrev=0 || echo "0.0.0") | |
| go build -trimpath -ldflags "-s -w -X github.com/gnacho/netpulse/server-go/internal/updater.BuildCommit=${GITHUB_SHA::7} -X github.com/gnacho/netpulse/server-go/internal/agentbin.EmbeddedAgentVersion=${AGENT_VERSION} -X github.com/gnacho/netpulse/server-go/internal/httpapi.Version=${VER}" -o netpulse ./cmd/netpulse | |
| - name: Empaqueta binario + despliegue | |
| run: tar czf netpulse-server-${{ github.sha }}-linux-${{ matrix.arch }}.tar.gz -C server-go netpulse .env.example -C .. deploy | |
| - name: Publica en prerelease go-latest | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: go-latest | |
| name: go-latest | |
| prerelease: true | |
| files: netpulse-server-${{ github.sha }}-linux-${{ matrix.arch }}.tar.gz | |
| # El cleanup va en un job aparte TRAS la matrix (#290): dentro del job build | |
| # cada arco listaba y borraba los mismos assets en paralelo y todos menos el | |
| # primero recibían 404. Aquí corre una sola vez, cuando ya no hay escritores | |
| # concurrentes. | |
| cleanup-go-latest: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # borrar assets antiguos de la prerelease go-latest | |
| steps: | |
| - name: Limpia assets antiguos (conserva los 10 más recientes por fecha) | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh api repos/${{ github.repository }}/releases/tags/go-latest \ | |
| --jq '.assets | sort_by(.created_at) | reverse | .[10:] | .[].name' \ | |
| | while read -r a; do | |
| gh release delete-asset -R "${{ github.repository }}" go-latest "$a" -y \ | |
| || echo "warn: no se pudo borrar '$a' (¿ya borrado?); se continúa" | |
| done |