dispatchrun / dispatch

Entrypoint of the Dispatch ecosystem.
11 stars 1 forks source link

fix(version): fixes dispatch version output #73

Closed keshavlingala closed 2 months ago

keshavlingala commented 3 months ago

This PR fixes the issue #64 on dispatch version command, it will now print git tag version an 1st 8 characters of git revision

keshavlingala commented 3 months ago

Reviews, changes, and/or suggestions would be appreciated @chicoxyzzy @chriso @achille-roussel

keshavlingala commented 3 months ago

That's right! Good Catch!. I am working on passing the version and revision from go build arguments, that way it will get injected into the executable, I am able to get it working along with Makefile changes.

trying to figure out the goreleaser and if it needs any more changes, I am bit new to this

keshavlingala commented 3 months ago

Injected the version and revision from the go build arguments and updated the Makefile. The build workflow is using the make command itself before running the release workflow, so that should include the the required git command.

@chriso Please take a look to see if this can work. Let me know if I missed anything

chriso commented 3 months ago

Thanks for the contribution @keshavlingala!

As mentioned in the linked issue, we have to cater to the subset of users that will install the Dispatch CLI through go directly, via:

go install github.com/dispatchrun/dispatch@latest

When you install through this path, the Makefile isn't consulted and the ldflags won't be set such that the tag and SHA are injected. The user would not see the tag and SHA when running dispatch version. Today, they'll see the tag because go install injects it into the binary, and makes it accessible via runtime/debug.ReadBuildInfo:

~ $ go install github.com/dispatchrun/dispatch@latest
go: downloading github.com/dispatchrun/dispatch v0.2.0
~ $ dispatch version
dispatch version v0.2.0

I don't think it's a big deal that the SHA is missing here, since it isn't important to the end user and can be derived from the tag if necessary.

As mentioned in https://github.com/dispatchrun/dispatch/issues/64#issuecomment-2150973453, the tag isn't injected properly when you install the Dispatch CLI via Homebrew, or if you manually download a binary from the GitHub Releases page. This is due to a minor issue in the goreleaser build process; we're not using proxy, as described in https://goreleaser.com/cookbooks/build-go-modules/.

We'd be happy to accept a PR to update goreleaser to use the proxy method, so that we have parity across all of our installation paths (dispatch version shows the tag).