Skip to content

Commit

Permalink
👷 Add initial CI
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 22, 2021
1 parent b7c6051 commit 8166d48
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.md
.dockerignore
.git/
.gitignore
.idea/
Dockerfile
dist/
docker-compose.yml
kubedb
out/
vendor/
55 changes: 55 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand All @@ -35,3 +41,11 @@ func init() {
restore.Command,
)
}

func buildVersion() string {
result := Version
if Commit != "" {
result += " (" + Commit + ")"
}
return result
}

0 comments on commit 8166d48

Please sign in to comment.