Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ jobs:
install-only: true

- name: Generate changelog
run: make changelog VERSION=${{ github.event.inputs.version }}
run: |
# Full changelog for CHANGELOG.md (committed to repo)
make changelog VERSION=${{ github.event.inputs.version }}
# Release notes for this version only (passed to goreleaser)
git-cliff --tag ${{ github.event.inputs.version }} --latest --strip header -o RELEASE_NOTES.md

- name: Commit, tag, and push release branch
run: |
Expand All @@ -67,7 +71,7 @@ jobs:
- name: Build and release with goreleaser
uses: goreleaser/goreleaser-action@v6
with:
args: release --clean
args: release --clean --release-notes RELEASE_NOTES.md
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}

Expand Down
3 changes: 3 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ archives:

checksum:
name_template: verda_{{ .Version }}_SHA256SUMS

changelog:
disable: true
8 changes: 5 additions & 3 deletions internal/verda-cli/cmd/version/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ type VerifyResult struct {
// checksumURL returns the GitHub release URL for the checksums file.
func checksumURL(ver string) string {
bare := strings.TrimPrefix(ver, "v")
tag := "v" + bare // GitHub release tags always have v prefix
return fmt.Sprintf(
"https://github.com/verda-cloud/verda-cli/releases/download/%s/verda_%s_binary_SHA256SUMS",
ver, bare,
tag, bare,
)
}

Expand Down Expand Up @@ -133,8 +134,9 @@ func verifyBinary(client *http.Client, binPath, url, goos, goarch string) (*Veri
// runVerify is the top-level verify logic, writing output to out and warnings
// to errOut. It uses the provided HTTP client for fetching checksums.
func runVerify(out, errOut io.Writer, outputFormat string, client *http.Client, ver, goos, goarch string) error {
if ver == "v0.0.0-dev" {
_, _ = fmt.Fprintln(errOut, "Warning: cannot verify a development build (v0.0.0-dev)")
bare := strings.TrimPrefix(ver, "v")
if bare == "0.0.0-dev" || bare == "" {
_, _ = fmt.Fprintf(errOut, "Warning: cannot verify a development build (%s)\n", ver)
return errors.New("cannot verify development build")
}

Expand Down
31 changes: 24 additions & 7 deletions internal/verda-cli/cmd/version/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ func TestChecksumURL(t *testing.T) {
version: "v0.5.0",
want: "https://github.com/verda-cloud/verda-cli/releases/download/v0.5.0/verda_0.5.0_binary_SHA256SUMS",
},
{
version: "1.3.0",
want: "https://github.com/verda-cloud/verda-cli/releases/download/v1.3.0/verda_1.3.0_binary_SHA256SUMS",
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -304,13 +308,26 @@ func TestVerifyBinaryMismatch(t *testing.T) {
func TestRunVerifyDevBuild(t *testing.T) {
t.Parallel()

var outBuf, errBuf bytes.Buffer

err := runVerify(&outBuf, &errBuf, "", nil, "v0.0.0-dev", "", "")
if err == nil {
t.Fatal("expected error for dev build")
tests := []struct {
name string
version string
}{
{"with v prefix", "v0.0.0-dev"},
{"without v prefix", "0.0.0-dev"},
{"empty", ""},
}
if !strings.Contains(errBuf.String(), "development build") {
t.Errorf("expected warning about development build, got: %q", errBuf.String())

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
var outBuf, errBuf bytes.Buffer
err := runVerify(&outBuf, &errBuf, "", nil, tt.version, "", "")
if err == nil {
t.Fatal("expected error for dev build")
}
if !strings.Contains(errBuf.String(), "development build") {
t.Errorf("expected warning about development build, got: %q", errBuf.String())
}
})
}
}
Loading