From 8166d48d84b163f19b9da921d5e56ee5ca3293ca Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Sat, 22 May 2021 15:58:57 -0500 Subject: [PATCH] :construction_worker: Add initial CI --- .dockerignore | 11 ++++++++ .github/workflows/go.yml | 55 ++++++++++++++++++++++++++++++++++++++++ .goreleaser.yml | 37 +++++++++++++++++++++++++++ cmd/cmd.go | 14 ++++++++++ 4 files changed, 117 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/go.yml create mode 100644 .goreleaser.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..ac88ddde --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +*.md +.dockerignore +.git/ +.gitignore +.idea/ +Dockerfile +dist/ +docker-compose.yml +kubedb +out/ +vendor/ diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 00000000..61a8f5c0 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,55 @@ +name: Go + +on: push + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.31 + + build: + name: Build + runs-on: ubuntu-latest + needs: lint + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.16 + id: go + + - name: Upgrade UPX + run: brew install upx + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} + + - uses: actions/upload-artifact@v2 + with: + name: dist + path: dist diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..582ab133 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,37 @@ +builds: + - ldflags: + - -s -w -X github.com/clevyr/kubedb/cmd.Version={{.Version}} -X github.com/clevyr/kubedb/cmd.Commit={{.Commit}} + env: + - CGO_ENABLED=0 + goarch: + - 386 + - amd64 + - arm + - arm64 + goarm: + - 6 + - 7 + hooks: + post: + - upx -q "{{ .Path }}" +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: "checksums.txt" +snapshot: + name_template: "{{ .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - "^:pencil:" +brews: + - tap: + owner: clevyr + name: homebrew-tap + folder: Formula diff --git a/cmd/cmd.go b/cmd/cmd.go index 3985782f..dae2c8dd 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -9,9 +9,15 @@ import ( "path/filepath" ) +var ( + Version = "next" + Commit = "" +) + var Command = &cobra.Command{ Use: "kubedb", Short: "Interact with a database inside of Kubernetes", + Version: buildVersion(), PersistentPreRun: func(cmd *cobra.Command, args []string) { cmd.SilenceUsage = true }, @@ -35,3 +41,11 @@ func init() { restore.Command, ) } + +func buildVersion() string { + result := Version + if Commit != "" { + result += " (" + Commit + ")" + } + return result +}