Skip to content

Commit 82612b8

Browse files
authored
Merge pull request #4 from someengineering/lloesche/version
Add tag as version number
2 parents 53ee9b9 + d4116ba commit 82612b8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ jobs:
3535
echo "OS_NAME=$OS_NAME" >> $GITHUB_ENV
3636
- name: Build Binary (amd64)
3737
run: |
38-
GOARCH=amd64 go build -ldflags "-s -w" -o "${{ github.workspace }}/release/fixctl-$OS_NAME-amd64-${{ github.ref_name }}$SUFFIX"
38+
GOARCH=amd64 go build -ldflags "-s -w -X main.version=v${{ github.ref_name }}" -o "${{ github.workspace }}/release/fixctl-$OS_NAME-amd64-${{ github.ref_name }}$SUFFIX"
3939
shell: bash
4040
- name: Build Binary (arm64)
4141
run: |
42-
GOARCH=arm64 go build -ldflags "-s -w" -o "${{ github.workspace }}/release/fixctl-$OS_NAME-arm64-${{ github.ref_name }}$SUFFIX"
42+
GOARCH=arm64 go build -ldflags "-s -w -X main.version=v${{ github.ref_name }}" -o "${{ github.workspace }}/release/fixctl-$OS_NAME-arm64-${{ github.ref_name }}$SUFFIX"
4343
shell: bash
4444
- name: Generate Universal Binary (macOS)
4545
if: matrix.os == 'macos-latest'

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import (
1111
"github.com/someengineering/fixctl/utils"
1212
)
1313

14+
var version = "development"
15+
1416
func customUsage() {
15-
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
17+
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s (%s):\n", os.Args[0], version)
1618
flag.VisitAll(func(f *flag.Flag) {
1719
fmt.Fprintf(flag.CommandLine.Output(), " --%s: %s (default %q)\n", f.Name, f.Usage, f.DefValue)
1820
})

0 commit comments

Comments
 (0)