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