Skip to content

Commit

Permalink
Merge pull request #12 from safesoftware/set-version-auto
Browse files Browse the repository at this point in the history
Automatically set the version when a release is created.
  • Loading branch information
garnold54 authored Dec 8, 2022
2 parents 7724195 + 160e2f3 commit 1b30b2c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ jobs:
goos: windows
steps:
- uses: actions/checkout@v3
- name: Set APP_VERSION env
run: echo APP_VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev ) >> ${GITHUB_ENV}
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
binary_name: "fmeserver"
binary_name: "fmeserver"
ldflags: -X "github.com/safesoftare/fmeserver-cli/cmd.appVersion=${{ env.APP_VERSION }}"
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"windows": {
"command": "go",
"args": [
"build",
"-ldflags=\\\"-X github.com/safesoftare/fmeserver-cli/cmd.appVersion=$(git rev-parse --short HEAD)\\\"",
"-o",
"fmeserver.exe"
]
},
"linux": {
"command": "go",
"args": [
"build",
"-ldflags=\"-X github.com/safesoftare/fmeserver-cli/cmd.appVersion=$(git rev-parse --short HEAD)\"",
"-o",
"fmeserver"
]
},
"problemMatcher": []
}
]
}
7 changes: 6 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ var jsonOutput bool
var outputType string
var noHeaders bool

const notSet string = "not set"

// this information will be collected at build time, by `-ldflags "-X github.com/safesoftare/fmeserver-cli/cmd.appVersion=0.1"`
var appVersion = notSet

var ErrSilent = errors.New("ErrSilent")

// rootCmd represents the base command when called without any subcommands
Expand All @@ -28,7 +33,7 @@ func NewRootCommand() *cobra.Command {
Use: "fmeserver",
Short: "A command line interface for interacting with FME Server.",
Long: `A command line interface for interacting with FME Server.`,
Version: "0.4",
Version: appVersion,
SilenceErrors: true,
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
Expand Down

0 comments on commit 1b30b2c

Please sign in to comment.