Skip to content

Commit

Permalink
chore(cli): add version info & commit id for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
neargle committed Mar 6, 2022
1 parent 98ec2d1 commit dbd9257
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ jobs:
sudo apt-get install -y upx
export CGO_ENABLED=0
gox -parallel 5 -osarch="darwin/amd64 linux/386 linux/amd64 linux/arm linux/arm64" -ldflags="-s -w " -output="bin/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/cdk/
gox -parallel 5 -osarch="linux/386 linux/amd64 linux/arm64" -ldflags="-s -w " -tags="thin" -output="bin/{{.Dir}}_{{.OS}}_{{.Arch}}_thin" ./cmd/cdk/
export GIT_COMMIT=$(git rev-list -1 HEAD)
export ldflags="-X github.com/cdk-team/CDK/pkg/cli.GitCommit=$GIT_COMMIT"
gox -parallel 5 -osarch="darwin/amd64 linux/386 linux/amd64 linux/arm linux/arm64" -ldflags="-s -w $ldflags " -output="bin/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/cdk/
gox -parallel 5 -osarch="linux/386 linux/amd64 linux/arm64" -ldflags="-s -w $ldflags " -tags="thin" -output="bin/{{.Dir}}_{{.OS}}_{{.Arch}}_thin" ./cmd/cdk/
# cdk_linux_386 cdk_linux_amd64 cdk_linux_arm cdk_linux_arm64
cp bin/cdk_linux_amd64 bin/cdk_linux_amd64_upx
Expand Down
15 changes: 9 additions & 6 deletions pkg/cli/banner.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package cli

import (
"fmt"
"log"
"os"

"github.com/docopt/docopt-go"
)

var BannerVersion = "cdk v0.1.10"
var Args docopt.Opts
var GitCommit string

var BannerVersion = fmt.Sprintf("%s %s", "CDK Version(GitCommit):", GitCommit)

var BannerHeader = `Container DucK
Zero-dependency k8s/docker/serverless penetration toolkit by <i@cdxy.me>
var BannerHeader = fmt.Sprintf(`Container DucK
%s
Zero-dependency k8s/docker/serverless penetration toolkit by cdxy & neargle
Find tutorial, configuration and use-case in https://github.com/cdk-team/CDK/wiki
`
`, BannerVersion)

var BannerContainer = BannerHeader + `
Usage:
Expand Down Expand Up @@ -64,8 +69,6 @@ Example:
2. inside serverless function service execute "./cdk-serverless /code 1.2.3.4 999"
`

var Args docopt.Opts

func parseDocopt() {
args, err := docopt.ParseArgs(BannerContainer, os.Args[1:], BannerVersion)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/util/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package util

0 comments on commit dbd9257

Please sign in to comment.