mirror of
https://github.com/lukaszraczylo/semver-generator.git
synced 2026-07-07 04:04:39 +00:00
Add -v / --version command and appropriate build flags.
This commit is contained in:
@@ -162,6 +162,8 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Compile binary
|
- name: Compile binary
|
||||||
uses: thatisuday/go-cross-build@v1
|
uses: thatisuday/go-cross-build@v1
|
||||||
|
env:
|
||||||
|
INPUT_LDFLAGS: "-s -w -X main.PKG_VERSION=${{ needs.prepare.outputs.RELEASE_VERSION }}"
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,darwin/amd64,windows/amd64,linux/arm64,darwin/amd64
|
platforms: linux/amd64,darwin/amd64,windows/amd64,linux/arm64,darwin/amd64
|
||||||
name: semver-gen
|
name: semver-gen
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
LOCAL_VERSION?=$(shell semver-gen generate -l -c config-release.yaml | sed -e 's|SEMVER ||g')
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@go build -o semver-gen *.go
|
go build -o semver-gen -ldflags="-s -w -X main.PKG_VERSION=${LOCAL_VERSION}" *.go
|
||||||
|
|
||||||
run: build
|
run: build
|
||||||
@./semver-gen
|
@./semver-gen
|
||||||
|
|||||||
+7
-2
@@ -32,8 +32,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
repo *Setup
|
repo *Setup
|
||||||
|
PKG_VERSION string
|
||||||
)
|
)
|
||||||
|
|
||||||
type Wording struct {
|
type Wording struct {
|
||||||
@@ -177,6 +178,10 @@ func (s *Setup) getSemver() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if varShowVersion {
|
||||||
|
fmt.Println("semver-gen", PKG_VERSION, "\tMore information: https://github.com/lukaszraczylo/semver-generator")
|
||||||
|
return
|
||||||
|
}
|
||||||
if repo.Generate {
|
if repo.Generate {
|
||||||
err := repo.ReadConfig(repo.LocalConfigFile)
|
err := repo.ReadConfig(repo.LocalConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+5
-1
@@ -30,7 +30,9 @@ var rootCmd = &cobra.Command{
|
|||||||
|
|
||||||
Effortless semantic version generator with git commit keywords matching, allowing you to focus on the development.
|
Effortless semantic version generator with git commit keywords matching, allowing you to focus on the development.
|
||||||
Visit https://github.com/lukaszraczylo/semver-generator for more information, documentation and examples.`,
|
Visit https://github.com/lukaszraczylo/semver-generator for more information, documentation and examples.`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {},
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
main()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func Execute() {
|
func Execute() {
|
||||||
@@ -55,6 +57,7 @@ func (r *Setup) setupCobra() {
|
|||||||
var (
|
var (
|
||||||
varRepoName, varLocalCfg string
|
varRepoName, varLocalCfg string
|
||||||
varUseLocal bool
|
varUseLocal bool
|
||||||
|
varShowVersion bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -64,5 +67,6 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().StringVarP(&varRepoName, "repository", "r", "https://github.com/lukaszraczylo/simple-gql-client", "Remote repository URL.")
|
rootCmd.PersistentFlags().StringVarP(&varRepoName, "repository", "r", "https://github.com/lukaszraczylo/simple-gql-client", "Remote repository URL.")
|
||||||
rootCmd.PersistentFlags().StringVarP(&varLocalCfg, "config", "c", "config.yaml", "Path to config file")
|
rootCmd.PersistentFlags().StringVarP(&varLocalCfg, "config", "c", "config.yaml", "Path to config file")
|
||||||
rootCmd.PersistentFlags().BoolVarP(&varUseLocal, "local", "l", false, "Use local repository")
|
rootCmd.PersistentFlags().BoolVarP(&varUseLocal, "local", "l", false, "Use local repository")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&varShowVersion, "version", "v", false, "Display version")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user