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
5 changes: 4 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# .github/workflows/release.yml
---
name: goreleaser
name: release

on:
push:
Expand All @@ -18,10 +18,12 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
Expand All @@ -31,3 +33,4 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD: $(git rev-parse --short "$GITHUB_SHA")
11 changes: 10 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
---
version: 2

before:
hooks:
- make clean
- go mod tidy

snapshot:
version_template: "{{ .Env.BUILD }}"
version_template: "{{ .Version }}"

builds:
- id: default
ldflags:
- -s -w
- -X github.com/itential/ipctl/internal/metadata.Build={{ .Env.BUILD }}
- -X github.com/itential/ipctl/internal/metadata.Version={{ .Tag }}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ snapshot:
# and add and remove any missing or unused modules.
install:
go mod download
@go mod tidy
go mod tidy

# The build target will build the application binary and place it into the bin/
# folder. If the folder does not exist, it will be created.
build: install
go build \
-v \
-o bin/ipctl \
-ldflags="-X 'github.com/itential/ipctl/internal/metadata.Sha=$$(git rev-parse --short HEAD)' -X 'github.com/itential/ipctl/nternal/metadata.User=$$(id -u -n)' -X 'github.com/itential/ipctl/internal/metadata.Time=$$(date)' -X 'github.com/itential/ipctl/internal/metadata.Version=$$(git tag | sort -V | tail -1)'"
-ldflags="-X 'github.com/itential/ipctl/internal/metadata.Build=$$(git rev-parse --short HEAD)' -X 'github.com/itential/ipctl/internal/metadata.Version=$$(git tag | sort -V | tail -1)'"

# The test target runs the unit tests for this project. All unit tests are
# based on mock data for the various services it connects to. The target
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func versionCommand() *cobra.Command {
Short: "Print the version information",
Run: func(cmd *cobra.Command, args []string) {
terminal.Display("version: %s", metadata.Version)
terminal.Display("commit: %s", metadata.Sha)
terminal.Display("commit: %s", metadata.Build)
e, _ := os.Executable()
terminal.Display("executable: %s", path.Dir(e))
terminal.Display("")
Expand Down
8 changes: 1 addition & 7 deletions internal/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
package metadata

// Represents the Git SHA (short) the build was compiled against
var Sha string

// Represent the date when the binary was built
var Time string

// Represent the username that build the binary
var User string
var Build string

// Represent the version of the build in the binary
var Version string
Loading