@@ -18,6 +18,12 @@ defaults:
1818jobs :
1919 release :
2020 runs-on : ubuntu-latest
21+ env :
22+ DO_SPACES_ENDPOINT : https://sfo3.digitaloceanspaces.com
23+ DO_SPACES_BUCKET : hyperstack-support-tools
24+ DO_SPACES_CDN : https://hyperstack-support-tools.sfo3.digitaloceanspaces.com
25+ AWS_DEFAULT_REGION : us-east-1
26+
2127 steps :
2228 - name : Checkout
2329 uses : actions/checkout@v4
@@ -27,10 +33,22 @@ jobs:
2733 - name : Set up Go
2834 uses : actions/setup-go@v5
2935 with :
30- # Path relative to repo root (working-directory does not apply to uses steps)
3136 go-version-file : customers/vm-troubleshooting/go.mod
3237 cache-dependency-path : customers/vm-troubleshooting/go.sum
3338
39+ - name : Derive release metadata
40+ id : meta
41+ run : |
42+ VERSION="${GITHUB_REF_NAME#gather-info/}"
43+ BASENAME="gather-info-${VERSION}-linux-amd64"
44+ CHECKSUM_NAME="${BASENAME}.sha256"
45+ LATEST_NAME="gather-info-latest-linux-amd64"
46+
47+ echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
48+ echo "basename=${BASENAME}" >> "$GITHUB_OUTPUT"
49+ echo "checksum=${CHECKSUM_NAME}" >> "$GITHUB_OUTPUT"
50+ echo "latest=${LATEST_NAME}" >> "$GITHUB_OUTPUT"
51+
3452 - name : Download modules
3553 run : go mod download
3654
@@ -46,61 +64,125 @@ jobs:
4664 GOOS : linux
4765 GOARCH : amd64
4866 run : |
49- # Strip the "gather-info/" prefix to get the clean version string
50- VERSION="${GITHUB_REF_NAME#gather-info/}"
67+ VERSION="${{ steps.meta.outputs.version }}"
5168 COMMIT="${{ github.sha }}"
5269 DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
70+ OUTPUT="${{ steps.meta.outputs.basename }}"
71+
5372 go build -trimpath \
5473 -ldflags="-s -w \
5574 -X github.com/NexGenCloud/vm-diagnostics/internal/config.Version=${VERSION} \
5675 -X github.com/NexGenCloud/vm-diagnostics/internal/config.Commit=${COMMIT:0:7} \
5776 -X github.com/NexGenCloud/vm-diagnostics/internal/config.BuildDate=${DATE}" \
58- -o gather-info \
77+ -o "${OUTPUT}" \
5978 ./cmd/gather-info
6079
6180 - name : Generate checksum
62- run : sha256sum gather-info > gather-info.sha256
81+ run : sha256sum "${{ steps.meta.outputs.basename }}" > "${{ steps.meta.outputs.checksum }}"
6382
6483 - name : Verify binary
6584 run : |
66- ./gather-info --version
67- file gather-info | grep -q "statically linked"
85+ ./"${{ steps.meta.outputs.basename }}" --version
86+ file "${{ steps.meta.outputs.basename }}" | grep -q "statically linked"
87+
88+ - name : Generate changelog
89+ id : changelog
90+ working-directory : .
91+ run : |
92+ # Find the previous gather-info tag (excluding the current one)
93+ CURRENT_TAG="${GITHUB_REF_NAME}"
94+ PREV_TAG=$(git tag --list 'gather-info/v*' --sort=-version:refname \
95+ | grep -v "^${CURRENT_TAG}$" | head -1)
96+
97+ if [ -n "${PREV_TAG}" ]; then
98+ echo "Generating changelog: ${PREV_TAG}..${CURRENT_TAG}"
99+ CHANGES=$(git log --oneline --no-merges "${PREV_TAG}..${CURRENT_TAG}" \
100+ -- customers/vm-troubleshooting/)
101+ else
102+ echo "No previous tag found — using all commits"
103+ CHANGES=$(git log --oneline --no-merges "${CURRENT_TAG}" \
104+ -- customers/vm-troubleshooting/)
105+ fi
106+
107+ # Write to file (multi-line output is tricky in GITHUB_OUTPUT)
108+ echo "${CHANGES}" > customers/vm-troubleshooting/changelog.txt
109+ echo "prev_tag=${PREV_TAG:-none}" >> "$GITHUB_OUTPUT"
68110
69111 - name : Generate release body
70- id : body
71112 run : |
72- VERSION="${GITHUB_REF_NAME#gather-info/}"
73- cat <<BODY > release-body.md
113+ VERSION="${{ steps.meta.outputs.version }}"
114+ BINARY="${{ steps.meta.outputs.basename }}"
115+ CHECKSUM="${{ steps.meta.outputs.checksum }}"
116+ CDN="${DO_SPACES_CDN}"
117+ PREV_TAG="${{ steps.changelog.outputs.prev_tag }}"
118+
119+ # Build changelog section
120+ CHANGELOG=""
121+ if [ -s changelog.txt ]; then
122+ CHANGELOG="### Changes"$'\n\n'
123+ if [ "${PREV_TAG}" != "none" ]; then
124+ CHANGELOG="${CHANGELOG}Since \`${PREV_TAG}\`:"$'\n\n'
125+ fi
126+ while IFS= read -r line; do
127+ CHANGELOG="${CHANGELOG}- ${line}"$'\n'
128+ done < changelog.txt
129+ CHANGELOG="${CHANGELOG}"$'\n'
130+ fi
131+
132+ cat > release-body.md <<BODY
74133 ## gather-info ${VERSION}
75134
76- ### Usage
135+ ### Quick install
77136
78137 \`\`\`bash
138+ curl -fSL "${CDN}/public/${BINARY}" -o gather-info
139+ curl -fSL "${CDN}/public/${CHECKSUM}" -o gather-info.sha256
140+ sha256sum -c gather-info.sha256
79141 chmod +x gather-info
80142 sudo ./gather-info
81143 \`\`\`
82144
83- ### Verify download
145+ ### Latest (always points to newest release)
84146
85147 \`\`\`bash
86- sha256sum -c gather-info.sha256
148+ curl -fSL "${CDN}/public/ gather-info-latest-linux-amd64" -o gather-info
87149 \`\`\`
88150
89- ### What's included
151+ ${CHANGELOG} ### What's included
90152
91153 Static Linux x86_64 binary. Collects system, network, NVIDIA GPU, DCGM, Docker, services, journal, packages, storage, and InfiniBand diagnostics into a single \`.tar.gz\` archive.
92154
93155 See [CODEMAP.md](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/customers/vm-troubleshooting/CODEMAP.md) for architecture details.
94156 BODY
95- # Strip leading whitespace from heredoc indentation
96157 sed -i 's/^ //' release-body.md
97158
98- - name : Release
159+ - name : Create GitHub release
99160 uses : softprops/action-gh-release@v2
100161 with :
101- name : " gather-info ${{ github.ref_name }}"
162+ name : " gather-info ${{ steps.meta.outputs.version }}"
102163 body_path : customers/vm-troubleshooting/release-body.md
103- # Paths relative to repo root (working-directory does not apply to uses steps)
104164 files : |
105- customers/vm-troubleshooting/gather-info
106- customers/vm-troubleshooting/gather-info.sha256
165+ customers/vm-troubleshooting/${{ steps.meta.outputs.basename }}
166+ customers/vm-troubleshooting/${{ steps.meta.outputs.checksum }}
167+
168+ - name : Upload to DigitalOcean Spaces
169+ env :
170+ AWS_ACCESS_KEY_ID : ${{ secrets.DO_SPACES_ACCESS_KEY_ID }}
171+ AWS_SECRET_ACCESS_KEY : ${{ secrets.DO_SPACES_SECRET_ACCESS_KEY }}
172+ run : |
173+ BINARY="${{ steps.meta.outputs.basename }}"
174+ CHECKSUM="${{ steps.meta.outputs.checksum }}"
175+ LATEST="${{ steps.meta.outputs.latest }}"
176+ S3_BASE="s3://${DO_SPACES_BUCKET}/public"
177+ S3_OPTS="--endpoint-url ${DO_SPACES_ENDPOINT} --region ${AWS_DEFAULT_REGION}"
178+
179+ # Upload versioned binary + checksum
180+ aws s3 cp "${BINARY}" "${S3_BASE}/${BINARY}" --acl public-read ${S3_OPTS}
181+ aws s3 cp "${CHECKSUM}" "${S3_BASE}/${CHECKSUM}" --acl public-read ${S3_OPTS}
182+
183+ # Update "latest" pointer (copy, not symlink — S3 doesn't support symlinks)
184+ aws s3 cp "${BINARY}" "${S3_BASE}/${LATEST}" --acl public-read ${S3_OPTS}
185+
186+ echo "::notice::Binary: ${DO_SPACES_CDN}/public/${BINARY}"
187+ echo "::notice::Checksum: ${DO_SPACES_CDN}/public/${CHECKSUM}"
188+ echo "::notice::Latest: ${DO_SPACES_CDN}/public/${LATEST}"
0 commit comments