From 392e904abfee92b7fc6b16751b70c765c16f6cde Mon Sep 17 00:00:00 2001 From: Shekhar Patil Date: Tue, 2 Jun 2026 23:42:29 +0530 Subject: [PATCH] Fix collector release: tag derivation + decouple GitHub release The collector-release workflow failed on workflow_dispatch because the "Derive semver" step assumed a tag push: github.ref_name was "main", so GORELEASER_CURRENT_TAG became "main" and goreleaser produced a ":main-amd64" image. Three fixes: 1. Derive the semver from the actual tag on a tag push, and fall back to the latest collector-v* tag on workflow_dispatch / branch runs (fail loudly if none exists). 2. Stop letting goreleaser publish the GitHub release. goreleaser (OSS) derives the release tag from the parsed semver (v0.2.0), which is also owned by the Python release, so the two collide. Set release.disable and publish the archives + checksums ourselves via `gh release create` at the namespaced collector-vX.Y.Z tag (idempotent on re-runs). goreleaser still builds the binaries and pushes the docker image. 3. Docs: correct the pinned image tag format (no "collector-" prefix on the docker tag) and the multi-arch claim (the image is amd64-only; arm64 ships as a binary tarball). Note: the remaining blocker is GHCR write permission for the ghcr.io/last9/l9gpu-collector package, which needs an org-level settings change (Actions write packages / package creation), not a code fix. --- .github/workflows/collector-release.yml | 39 ++++++++++++++++++++++++- .goreleaser.yml | 12 ++++---- docs/COLLECTOR.md | 7 +++-- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/.github/workflows/collector-release.yml b/.github/workflows/collector-release.yml index 765af2b..fcfc361 100644 --- a/.github/workflows/collector-release.yml +++ b/.github/workflows/collector-release.yml @@ -67,9 +67,25 @@ jobs: id: semver env: REF_NAME: ${{ github.ref_name }} + REF_TYPE: ${{ github.ref_type }} run: | - semver="${REF_NAME#collector-}" + if [ "$REF_TYPE" = "tag" ]; then + tag="$REF_NAME" + else + # workflow_dispatch / branch run: fall back to the latest collector-v* tag + tag="$(git describe --tags --abbrev=0 --match 'collector-v*')" + fi + if [ -z "$tag" ]; then + echo "::error::no collector-v* tag found to release from" >&2 + exit 1 + fi + # goreleaser (OSS) parses .Version from GORELEASER_CURRENT_TAG, so it + # must be a bare semver (v0.2.0) with the "collector-" prefix stripped. + # The GitHub release is published separately at the full tag below. + semver="${tag#collector-}" + echo "Releasing ${semver} (from ${tag})" echo "tag=${semver}" >> "$GITHUB_OUTPUT" + echo "full_tag=${tag}" >> "$GITHUB_OUTPUT" - name: Run goreleaser uses: goreleaser/goreleaser-action@v6 @@ -80,3 +96,24 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GORELEASER_CURRENT_TAG: ${{ steps.semver.outputs.tag }} + + - name: Publish GitHub release + env: + GH_TOKEN: ${{ github.token }} + FULL_TAG: ${{ steps.semver.outputs.full_tag }} + SEMVER: ${{ steps.semver.outputs.tag }} + run: | + # goreleaser left the archives + checksums in dist/ (release.disable). + # Publish them at the namespaced collector-vX.Y.Z tag, idempotently so + # re-runs of the same tag re-upload instead of failing. + prerelease_flag="" + case "$SEMVER" in *-*) prerelease_flag="--prerelease" ;; esac + if gh release view "$FULL_TAG" >/dev/null 2>&1; then + gh release upload "$FULL_TAG" dist/*.tar.gz dist/checksums.txt --clobber + else + gh release create "$FULL_TAG" \ + --title "l9gpu-collector ${SEMVER#v}" \ + --generate-notes \ + $prerelease_flag \ + dist/*.tar.gz dist/checksums.txt + fi diff --git a/.goreleaser.yml b/.goreleaser.yml index b5750ff..0cedb11 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -75,13 +75,13 @@ docker_manifests: checksum: name_template: "checksums.txt" +# goreleaser only builds the binaries/archives and pushes the docker image. +# The GitHub release is published by the workflow via `gh release create` at +# the full "collector-vX.Y.Z" tag. We can't let goreleaser publish it because +# goreleaser (OSS) derives the release tag from the parsed semver (v0.2.0), +# which is also owned by the Python release — they would collide. release: - github: - owner: last9 - name: gpu-telemetry - prerelease: auto - draft: false - name_template: "l9gpu-collector {{ .Version }}" + disable: "true" changelog: sort: asc diff --git a/docs/COLLECTOR.md b/docs/COLLECTOR.md index b119614..e6bec89 100644 --- a/docs/COLLECTOR.md +++ b/docs/COLLECTOR.md @@ -27,11 +27,12 @@ docker run --rm \ Use `:latest` for tracking the newest release, or pin to a version: ```bash -docker pull ghcr.io/last9/l9gpu-collector:collector-v0.1.0 +docker pull ghcr.io/last9/l9gpu-collector:v0.1.0 ``` -Multi-arch (linux/amd64, linux/arm64). Docker picks the right image -automatically. +The docker image is published for `linux/amd64` only. For `linux/arm64`, +use the binary tarball below (a native arm64 image will be added once an +arm64 build runner is available). ### Kubernetes