Skip to content

Commit

Permalink
Merge pull request #13 from cego/staal0-add-version-param
Browse files Browse the repository at this point in the history
Add version parameter to build
  • Loading branch information
staal0 authored Feb 6, 2024
2 parents c4bb4d3 + 0cd1a6b commit 68f629e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ jobs:
with:
go-version: 1.18

- name: Checkout code
uses: actions/checkout@v4

- name: Build
run: go build -v ./...
run: |
echo Build James ${GITHUB_REF#refs/tags/v}
go build -ldflags "-X main.Build=${GITHUB_REF#refs/tags/v}" -v ./...
- name: Test
run: go test -v ./...
16 changes: 12 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ import (
"github.com/spf13/cobra"
)

// Build A version string that can be set with
//
// -ldflags "-X main.Build=SOMEVERSION"
//
// at compile-time.
var Build string

const (
appName = "james"
)
Expand All @@ -41,10 +48,11 @@ var (
dumpPath string

rootCmd = &cobra.Command{
Use: appName,
PreRun: prerun,
Short: "A helper for OpenSSH's AuthorizedKeysCommand",
Run: root,
Use: appName,
PreRun: prerun,
Short: "A helper for OpenSSH's AuthorizedKeysCommand",
Run: root,
Version: Build,
}

dumpWriter io.Writer
Expand Down

0 comments on commit 68f629e

Please sign in to comment.