Skip to content

Automatically populate version info for releases#237

Merged
tminusplus merged 13 commits intomainfrom
tszucs/embed-version
Aug 30, 2023
Merged

Automatically populate version info for releases#237
tminusplus merged 13 commits intomainfrom
tszucs/embed-version

Conversation

@tminusplus
Copy link
Copy Markdown
Contributor

@tminusplus tminusplus commented Aug 25, 2023

What was changed

This uses a combination of the DebugBuildInfo and pseudo version to ensure that we have build information both when:

  • The application is built from the Makefile locally.
  • The application is built with standard Go tooling, like go install github.com/temporalio/tcld/cmd/tcld.
  • The application is installed via brew.

Part of this is updating past Go 1.18 for all the new niceness around DebugBuildInfo. Go mod tidy was also ran.

Note, that the Go behaviour is to increment the patch version when you are using an unreleased build from go install. You can see this in the checklist where go install refers to v0.13.1 (because it is not the v0.13.0 version) but the makefile refers to v0.13.0 (even though it is not really the v0.13.0 version).

Why?

Now we do not have to manually update the version with releases.

Checklist

  • Tested the binary from a go install github.com/temporalio/tcld/cmd/tcld@tszucs/embed-version:
❯ go install github.com/temporalio/tcld/cmd/tcld@tszucs/embed-version
go: downloading github.com/temporalio/tcld v0.13.1-0.20230830001508-132e34e4954e

❯ tcld version
{
    "Date": "2023-08-30T00:15:08.000Z",
    "Commit": "132e34e4954e",
    "Version": "v0.13.1-0.20230830001508-132e34e4954e"
}
  • Tested the binary from a clean tcld:
❯ make clean tcld

❯ ./tcld version
{
    "Date": "2023-08-29T17:15:08-07:00",
    "Commit": "132e34e4954e",
    "Version": "v0.13.1-embed-version-test"
}
❯ brew reinstall  --build-from-source ./tcld.rb
==> Fetching tcld
==> Cloning https://github.com/temporalio/tcld.git
Updating /Users/tszucs/Library/Caches/Homebrew/tcld--git
From github.com:temporalio/tcld
 * [new tag]         v0.13.1-embed-version-test -> v0.13.1-embed-version-test
==> Checking out tag v0.13.1-embed-version-test
HEAD is now at 132e34e Print as ISO timestamp
HEAD is now at 132e34e Print as ISO timestamp
==> Reinstalling tcld
==> go build -ldflags=-s -w -X github.com/temporalio/tcld/app.version=v0.13.1 -X github.com/temporalio/tcld/app.commit=132e34e4954e -X github.com/temporalio/tcld/app.date=2023-08-30T00:15:08Z -o /opt/homebrew/Cellar/tcld/0.13.1/bin/tcld ./cmd/tcld
🍺  /opt/homebrew/Cellar/tcld/0.13.1: 5 files, 15.6MB, built in 2 seconds
==> Running `brew cleanup tcld`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /Users/tszucs/Library/Caches/Homebrew/tcld--0.13.1... (271.3KB)

❯ /opt/hombrew/Cellar/tcld/0.13.1/bin/tcld version
{
    "Date": "2023-08-30T00:15:08Z",
    "Commit": "132e34e4954e",
    "Version": "v0.13.1"
}

Comment thread app/version.go Outdated
Comment thread app/version.go Outdated
Comment thread app/version.go Outdated
Comment thread app/version.go Outdated
@tminusplus tminusplus changed the title Enable pulling build info from go install built binaries Automatically populate version info for releases Aug 30, 2023
@tminusplus tminusplus merged commit 6ef2af8 into main Aug 30, 2023
@tminusplus tminusplus deleted the tszucs/embed-version branch August 30, 2023 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants