grim/hgkeeper

2d8b599beeb4
Parents ef4ae04808d3
Children a2f020bc5a00
Add a version command and include the short commit hash in it
  • +6 -5
    convey.yml
  • +2 -0
    main.go
  • +19 -0
    version/cmd.go
  • --- a/convey.yml Tue Jun 21 16:49:17 2022 -0500
    +++ b/convey.yml Tue Jun 21 16:51:05 2022 -0500
    @@ -1,5 +1,5 @@
    environment:
    - - VERSION=0.0.0
    + - VERSION=1.0.0
    - REPO=rwgrim/hgkeeper
    - TAG=latest
    - REGISTRY=docker.io
    @@ -41,7 +41,7 @@
    - GOARCH=amd64
    - OUTPUT=hgkeeper-${VERSION}-${GOOS}-${GOARCH}
    script:
    - - go build -o ${OUTPUT}
    + - go build -o ${OUTPUT} -ldflags "-X keep.imfreedom.org/grim/hgkeeper/version.Commit=${COMMIT_SHORT}"
    - sha256sum ${OUTPUT} | tee ${OUTPUT}.sha256sum
    build-freebsd-amd64:
    @@ -53,7 +53,7 @@
    - GOARCH=amd64
    - OUTPUT=hgkeeper-${VERSION}-${GOOS}-${GOARCH}
    script:
    - - go build -o ${OUTPUT}
    + - go build -o ${OUTPUT} -ldflags "-X keep.imfreedom.org/grim/hgkeeper/version.Commit=${COMMIT_SHORT}"
    - sha256sum ${OUTPUT} | tee ${OUTPUT}.sha256sum
    build-linux-amd64:
    @@ -65,7 +65,7 @@
    - GOARCH=amd64
    - OUTPUT=hgkeeper-${VERSION}-${GOOS}-${GOARCH}
    script:
    - - go build -o ${OUTPUT}
    + - go build -o ${OUTPUT} -ldflags "-X keep.imfreedom.org/grim/hgkeeper/version.Commit=${COMMIT_SHORT}"
    - sha256sum ${OUTPUT} | tee ${OUTPUT}.sha256sum
    build-windows-amd64:
    @@ -77,7 +77,8 @@
    - GOARCH=amd64
    - OUTPUT=hgkeeper-${VERSION}-${GOOS}-${GOARCH}.exe
    script:
    - - go build -o ${OUTPUT}
    + - go build -o ${OUTPUT} -ldflags "-X keep.imfreedom.org/grim/hgkeeper/version.Commit=${COMMIT_SHORT}"
    + - sha256sum ${OUTPUT} | tee ${OUTPUT}.sha256sum
    - sha256sum ${OUTPUT} | tee ${OUTPUT}.sha256sum
    build-image:
    --- a/main.go Tue Jun 21 16:49:17 2022 -0500
    +++ b/main.go Tue Jun 21 16:51:05 2022 -0500
    @@ -11,6 +11,7 @@
    "keep.imfreedom.org/grim/hgkeeper/once"
    "keep.imfreedom.org/grim/hgkeeper/serve"
    "keep.imfreedom.org/grim/hgkeeper/setup"
    + "keep.imfreedom.org/grim/hgkeeper/version"
    )
    type commands struct {
    @@ -20,6 +21,7 @@
    Once once.Command `kong:"cmd,help='run hgkeeper for one transaction. This is used when integrating with a system ssh server'"`
    Serve serve.Command `kong:"cmd,help='run the ssh server'"`
    Setup setup.Command `kong:"cmd,help='inital setup for the server'"`
    + Version version.Command `kong:"cmd,help='display the version and exit'"`
    }
    func init() {
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/version/cmd.go Tue Jun 21 16:51:05 2022 -0500
    @@ -0,0 +1,19 @@
    +package version
    +
    +import (
    + "fmt"
    +
    + "keep.imfreedom.org/grim/hgkeeper/globals"
    +)
    +
    +const Version = "1.0.0"
    +
    +var Commit = "unknown"
    +
    +type Command struct{}
    +
    +func (c *Command) Run(g *globals.Globals) error {
    + fmt.Printf("hgkeeper %s~%s\n", Version, Commit)
    +
    + return nil
    +}