From bf7b5665e504a9599aeeb38dfe95233c725f7825 Mon Sep 17 00:00:00 2001 From: Tim Adler Date: Thu, 27 Oct 2022 19:22:01 +0200 Subject: [PATCH 1/2] first step to autoversion --- .github/workflows/build_release.yml | 2 +- .goreleaser.yaml | 218 ++++++++++++++++++++++++++++ cmd/root.go | 7 +- cmd/version.go | 20 --- 4 files changed, 224 insertions(+), 23 deletions(-) create mode 100644 .goreleaser.yaml delete mode 100644 cmd/version.go diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 4d185dc..516006a 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -16,7 +16,7 @@ jobs: with: fetch-depth: 0 # See: https://goreleaser.com/ci/actions/ - - name: Set up Go 1.14 + - name: Set up Go 1.18 uses: actions/setup-go@v2 with: go-version: "1.18" diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..2243a98 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,218 @@ +# .goreleaser.yaml +builds: + # You can have multiple builds defined as a yaml list + - + # ID of the build. + # Defaults to the binary name. + # id: "my-build" + + # Path to main.go file or main package. + # Notice: when used with `gomod.proxy`, this must be a package. + # + # Default is `.`. + # main: ./cmd/my-app + + # Binary name. + # Can be a path (e.g. `bin/app`) to wrap the binary in a directory. + # Default is the name of the project directory. + # binary: program + + # Custom flags templates. + # Default is empty. + # flags: + # - -tags=dev + # - -v + + # Custom asmflags templates. + # Default is empty. + # asmflags: + # - -D mysymbol + # - all=-trimpath={{.Env.GOPATH}} + + # Custom gcflags templates. + # Default is empty. + # gcflags: + # - all=-trimpath={{.Env.GOPATH}} + # - ./dontoptimizeme=-N + + # Custom ldflags templates. + # Default is `-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser`. + ldflags: + - "-X lit/cmd.Version={{.Version}}" + + # Custom build tags templates. + # Default is empty. + # tags: + # - osusergo + # - netgo + # - static_build + # - feature + + # Custom environment variables to be set during the builds. + # + # Default: `os.Environ()` merged with what you set the root `env` section. + # env: + # - CGO_ENABLED=0 + + # GOOS list to build for. + # For more info refer to: https://golang.org/doc/install/source#environment + # Defaults are darwin and linux. + # goos: + # - freebsd + # - windows + + # GOARCH to build for. + # For more info refer to: https://golang.org/doc/install/source#environment + # Defaults are 386, amd64 and arm64. + # goarch: + # - amd64 + # - arm + # - arm64 + + # GOARM to build for when GOARCH is arm. + # For more info refer to: https://golang.org/doc/install/source#environment + # Default is only 6. + # goarm: + # - 6 + # - 7 + + # GOAMD64 to build when GOARCH is amd64. + # For more info refer to: https://golang.org/doc/install/source#environment + # Default is only v1. + # goamd64: + # - v2 + # - v3 + + # GOMIPS and GOMIPS64 to build when GOARCH is mips, mips64, mipsle or mips64le. + # For more info refer to: https://golang.org/doc/install/source#environment + # Default is only hardfloat. + # gomips: + # - hardfloat + # - softfloat + + # List of combinations of GOOS + GOARCH + GOARM to ignore. + # Default is empty. + # ignore: + # - goos: darwin + # goarch: 386 + # - goos: linux + # goarch: arm + # goarm: 7 + # - goarm: mips64 + # - gomips: hardfloat + # - goamd64: v4 + + # Optionally override the matrix generation and specify only the final list + # of targets. + # + # Format is `{goos}_{goarch}` with their respective suffixes when + # applicable: `_{goarm}`, `_{goamd64}`, `_{gomips}`. + # + # Special values: + # - go_118_first_class: evaluates to the first-class ports of go1.18. + # Since GoReleaser v1.9. + # - go_first_class: evaluates to latest stable go first-class ports, + # currently same as 1.18. + # Since GoReleaser v1.9. + # + # This overrides `goos`, `goarch`, `goarm`, `gomips`, `goamd64` and + # `ignores`. + # targets: + # - go_first_class + # - go_118_first_class + # - linux_amd64_v1 + # - darwin_arm64 + # - linux_arm_6 + + # Set a specific go binary to use when building. + # It is safe to ignore this option in most cases. + # + # Default is "go" + # gobinary: "go1.13.4" + + # Sets the command to run to build. + # Can be useful if you want to build tests, for example, + # in which case you can set this to "test". + # It is safe to ignore this option in most cases. + # + # Default: build. + # Since: v1.9. + # command: test + + # Set the modified timestamp on the output binary, typically + # you would do this to ensure a build was reproducible. Pass + # empty string to skip modifying the output. + # Default is empty string. + # mod_timestamp: '{{ .CommitTimestamp }}' + + # Hooks can be used to customize the final binary, + # for example, to run generators. + # Those fields allow templates. + # Default is both hooks empty. + # hooks: + # pre: rice embed-go + # post: ./script.sh {{ .Path }} + + # If true, skip the build. + # Useful for library projects. + # Default is false + # skip: false + + # By default, GoReleaser will create your binaries inside + # `dist/${BuildID}_${BuildTarget}`, which is an unique directory per build + # target in the matrix. + # You can set subdirs within that folder using the `binary` property. + # + # However, if for some reason you don't want that unique directory to be + # created, you can set this property. + # If you do, you are responsible for keeping different builds from + # overriding each other. + # + # Defaults to `false`. + # no_unique_dist_dir: true + + # By default, GoReleaser will check if the main filepath has a main + # function. + # This can be used to skip that check, in case you're building tests, for + # example. + # + # Default: false. + # Since: v1.9. + # no_main_check: true + + # Path to project's (sub)directory containing Go code. + # This is the working directory for the Go build command(s). + # If dir does not contain a `go.mod` file, and you are using `gomod.proxy`, + # produced binaries will be invalid. + # You would likely want to use `main` instead of this. + # Default is `.`. + # dir: go + + # Builder allows you to use a different build implementation. + # This is a GoReleaser Pro feature. + # Valid options are: `go` and `prebuilt`. + # Defaults to `go`. + # builder: prebuilt + + # Overrides allows to override some fields for specific targets. + # This can be specially useful when using CGO. + # Note: it'll only match if the full target matches. + # + # Default: empty. + # Since: v1.5. + # overrides: + # - goos: darwin + # goarch: arm64 + # goamd64: v1 + # goarm: '' + # gomips: '' + # ldflags: + # - foo + # tags: + # - bar + # asmflags: + # - foobar + # gcflags: + # - foobaz + # env: + # - CGO_ENABLED=1 \ No newline at end of file diff --git a/cmd/root.go b/cmd/root.go index bba5eed..313d4c4 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -15,10 +15,13 @@ import ( var cliCfg = config.LauncherConfig{} +var Version string + // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Use: "lit", - Short: "A command-line quicklauncher.", + Use: "lit", + Version: Version, + Short: "A command-line quicklauncher.", Long: `lit An easily configurable quicklauncher for your terminal. You need to create a ~/.lit.yml config file in order to use it. diff --git a/cmd/version.go b/cmd/version.go deleted file mode 100644 index c1a6d6e..0000000 --- a/cmd/version.go +++ /dev/null @@ -1,20 +0,0 @@ -package cmd - -import ( - "fmt" - - "github.com/spf13/cobra" -) - -func init() { - rootCmd.AddCommand(versionCmd) -} - -var versionCmd = &cobra.Command{ - Use: "version", - Short: "Print the version number of lit", - Long: `All software has versions. This is lit's`, - Run: func(cmd *cobra.Command, args []string) { - fmt.Println("lit - a commandline quicklauncher v0.1 -- HEAD") - }, -} From 973b855472c279c0ce6f5db23e6a726305fed14f Mon Sep 17 00:00:00 2001 From: Tim Adler Date: Thu, 27 Oct 2022 23:02:25 +0200 Subject: [PATCH 2/2] renamed for consistency --- .goreleaser.yaml => .goreleaser.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .goreleaser.yaml => .goreleaser.yml (100%) diff --git a/.goreleaser.yaml b/.goreleaser.yml similarity index 100% rename from .goreleaser.yaml rename to .goreleaser.yml