diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d95bef1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,30 @@ +# Copyright (c) 2021 Gemba Advantage +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# in the Software without restriction, including without limitation the rights +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: gomod + directory: / + schedule: + interval: daily diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..e954f35 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,44 @@ +# Copyright (c) 2021 Gemba Advantage +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# in the Software without restriction, including without limitation the rights +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 14 + +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 + +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security + +# Label to use when marking an issue as stale +staleLabel: wontfix + +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. + +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c25534f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +# Copyright (c) 2021 Gemba Advantage +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# in the Software without restriction, including without limitation the rights +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +name: ci +on: + push: + branches: + - main + pull_request: +jobs: + ci: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + token: ${{ secrets.GH_UPLIFT }} + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + - name: Lint + uses: golangci/golangci-lint-action@v2 + with: + skip-go-installation: true + - name: Test + run: make test + - name: Code Coverage + uses: codecov/codecov-action@v2.0.3 + - name: Build + run: make build + - name: Tag + if: github.ref == 'refs/heads/main' + uses: gembaadvantage/uplift-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GH_UPLIFT }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..022a699 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +# Copyright (c) 2021 Gemba Advantage +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# in the Software without restriction, including without limitation the rights +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +name: release +on: + push: + tags: + - "v*.*.*" +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + - name: Import GPG key + id: import_gpg + uses: hashicorp/ghaction-import-gpg@v2.1.0 + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + - name: GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GH_GORELEASER }} diff --git a/.gitignore b/.gitignore index 66fd13c..0a9e372 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +# Built binary +bin/ diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..180c56b --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,46 @@ +# Copyright (c) 2021 Gemba Advantage +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# in the Software without restriction, including without limitation the rights +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +run: + timeout: 2m + +linters: + disable-all: true + enable: + - deadcode + - dupl + - gofmt + - goimports + - gosimple + - govet + - ineffassign + - misspell + - nakedret + - revive + - staticcheck + - structcheck + - unused + - varcheck + +linters-settings: + gofmt: + simplify: true + dupl: + threshold: 400 diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..28ec877 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,86 @@ +# Copyright (c) 2021 Gemba Advantage +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# in the Software without restriction, including without limitation the rights +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +builds: + - id: git-remote-codecommit + main: ./cmd/grc + binary: git-remote-codecommit + ldflags: + - -s -w + - -X github.com/gembaadvantage/git-remote-codecommit/internal/version.version={{.Tag}} + - -X github.com/gembaadvantage/git-remote-codecommit/internal/version.gitCommit={{.Commit}} + - -X github.com/gembaadvantage/git-remote-codecommit/internal/version.gitBranch=main + - -X github.com/gembaadvantage/git-remote-codecommit/internal/version.buildDate={{.Date}} + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - 386 + - arm + - arm64 + - ppc64le + goarm: + - 7 + ignore: + - goos: darwin + goarch: 386 +archives: + - id: git-remote-codecommit-archive + format: tar.gz + name_template: |- + {{ .ProjectName }}_{{ .Tag }}_{{ .Os }}-{{ .Arch }} + builds: + - git-remote-codecommit + replacements: + 386: i386 + amd64: x86_64 + format_overrides: + - goos: windows + format: zip + files: + - README.md + - LICENSE +signs: + - artifacts: checksum +brews: + - name: git-remote-codecommit + tap: + owner: gembaadvantage + name: homebrew-tap + folder: Formula + homepage: "https://github.com/gembaadvantage/git-remote-codecommit" + description: "Semantic versioning the easy way" + license: MIT + install: | + bin.install "git-remote-codecommit" + test: | + installed_version = shell_output("#{bin}/git-remote-codecommit version --short 2>&1") + assert_match "v#{version}", installed_version +scoop: + bucket: + owner: gembaadvantage + name: scoops + homepage: "https://github.com/gembaadvantage/git-remote-codecommit" + description: "Semantic versioning the easy way" + license: MIT diff --git a/.uplift.yml b/.uplift.yml new file mode 100644 index 0000000..92e1655 --- /dev/null +++ b/.uplift.yml @@ -0,0 +1,21 @@ +# Copyright (c) 2021 Gemba Advantage +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# in the Software without restriction, including without limitation the rights +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +firstVersion: v1.0.0 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..29b5c61 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or + advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email + address, without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +github@gembaadvantage.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..759ab82 --- /dev/null +++ b/Makefile @@ -0,0 +1,67 @@ +# Copyright (c) 2021 Gemba Advantage +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# in the Software without restriction, including without limitation the rights +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +BINDIR := $(CURDIR)/bin +BINNAME ?= git-remote-codecommit +BINVERSION := '' +LDFLAGS := -w -s + +GOBIN = $(shell go env GOBIN) +ifeq ($(GOBIN),) +GOBIN = $(shell go env GOPATH)/bin +endif + +# Interrogate git for build time information +GIT_COMMIT = $(shell git rev-parse HEAD) +GIT_SHA = $(shell git rev-parse --short HEAD) +GIT_BRANCH = $(shell git branch --show-current) +GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null) + +BINVERSION = ${GIT_TAG} + +ifneq ($(GIT_BRANCH),'main') + BINVERSION := $(BINVERSION)-${GIT_SHA} +endif + +# Set build time information +LDFLAGS += -X github.com/gembaadvantage/git-remote-codecommit/internal/version.version=${BINVERSION} +LDFLAGS += -X github.com/gembaadvantage/git-remote-codecommit/internal/version.gitCommit=${GIT_COMMIT} +LDFLAGS += -X github.com/gembaadvantage/git-remote-codecommit/internal/version.gitBranch=${GIT_BRANCH} + +.PHONY: all +all: build + +.PHONY: build +build: $(BINDIR)/$(BINNAME) + +$(BINDIR)/$(BINNAME): $(SRC) + go build -ldflags '$(LDFLAGS)' -o '$(BINDIR)/$(BINNAME)' ./cmd/grc + +.PHONY: test +test: + go test -race -vet=off -p 1 -covermode=atomic -coverprofile=coverage.out ./... + +.PHONY: lint +lint: + golangci-lint run --timeout 5m0s + +.PHONY: clean +clean: + @rm -rf '$(BINDIR)' \ No newline at end of file diff --git a/README.md b/README.md index 5790396..c6eebd0 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# git-remote-codecommit \ No newline at end of file +# git-remote-codecommit diff --git a/cmd/grc/main.go b/cmd/grc/main.go new file mode 100644 index 0000000..5810738 --- /dev/null +++ b/cmd/grc/main.go @@ -0,0 +1,26 @@ +/* +Copyright (c) 2021 Gemba Advantage + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +package main + +func main() { +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1dbeb35 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/gembaadvantage/git-remote-codecommit + +go 1.17 diff --git a/internal/version/build.go b/internal/version/build.go new file mode 100644 index 0000000..19c7f3d --- /dev/null +++ b/internal/version/build.go @@ -0,0 +1,61 @@ +/* +Copyright (c) 2021 Gemba Advantage + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +package version + +import "runtime" + +var ( + // The current built version + version = "" + // The git branch associated with the current built version + gitBranch = "" + // The git SHA1 of the commit + gitCommit = "" + // The date associated with the current built version + buildDate = "" +) + +// BuildInfo contains build time information about the application +type BuildInfo struct { + Version string `json:"version,omitempty"` + GitBranch string `json:"gitBranch,omitempty"` + GitCommit string `json:"gitCommit,omitempty"` + BuildDate string `json:"buildDate,omitempty"` + GoVersion string `json:"goVersion,omitempty"` +} + +// Short returns the semantic version of the application +func Short() string { + return version +} + +// Long returns the build time version information of the application +func Long() BuildInfo { + return BuildInfo{ + Version: version, + GitBranch: gitBranch, + GitCommit: gitCommit, + BuildDate: buildDate, + GoVersion: runtime.Version(), + } +}