Skip to content

Commit

Permalink
fix: embed version in kubectl-retina with goreleaser (#170)
Browse files Browse the repository at this point in the history
# Description

The ldflag needs to be the full module-aware path to the variable
Version. This causes issues with kubectl-retina because that Version is
used to set image versions for the k8s objects created to take captures.

## Related Issue

If this pull request is related to any issue, please mention it here.
Additionally, make sure that the issue is assigned to you before
submitting this pull request.

## Checklist

- [ ] I have read the [contributing
documantation](https://retina.sh/docs/contributing).
- [ ] I signed and signed-off the commits (`git commit -S -s ...`)
- [ ] I have correctly attributed the author(s) of the code.
- [ ] I have tested the changes locally.
- [ ] I have followed the project's style guidelines.
- [ ] I have updated the documentation, if necessary.
- [ ] I have added tests, if applicable.

## Testing 

```bash
$ goreleaser build --clean --snapshot --single-target
...
  • building binaries
    • partial build                                  match=target=linux_amd64
    • building                                       binary=dist/retina_linux_amd64_v1/kubectl-retina-linux-amd64
...
```

```bash
$ ./dist/retina_linux_amd64_v1/kubectl-retina-linux-amd64 version
0.0.2-SNAPSHOT-027d383
```

## Additional Notes

Add any additional notes or context about the pull request here.

---

Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more
information on how to contribute to this project.

Signed-off-by: Evan Baker <[email protected]>
  • Loading branch information
rbtr authored Mar 28, 2024
1 parent 9468715 commit 635f4ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ builds:
- windows
- darwin
ldflags:
- -X cli/cmd.Version={{.Version}}
- -X github.com/microsoft/retina/cli/cmd.Version={{.Version}}
main: cli/main.go

archives:
- name_template: "{{ .Binary }}-v{{ .Version }}"
wrap_in_directory: false
format_overrides:
- goos: windows
format: zip
- goos: windows
format: zip

changelog:
sort: asc
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
)

// This variable is used by the "version" command and is set during build.
var Version = "undefined"
// Defaults to a safe value if not set.
var Version = "v0.0.2"

func VersionCmd() *cobra.Command {
cmd := &cobra.Command{
Expand Down

0 comments on commit 635f4ef

Please sign in to comment.