diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..c0c330b8 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,30 @@ +name: ci + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.13 + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: gofmt + run: make fmt + + - name: Build + run: go bulid -v . + + - name: Test + run: make test diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 00000000..9d240647 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,22 @@ +name: publish + +on: + push: + tags: + - '*' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + fetch-depth: 1 + - name: Make + run: make all + - name: Upload release binaries + uses: alexellis/upload-assets@0.2.3 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + asset_paths: '["./bin/*"]' diff --git a/Makefile b/Makefile index 1e5607aa..5690a8a5 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,22 @@ Version := $(shell git describe --tags --dirty) GitCommit := $(shell git rev-parse HEAD) LDFLAGS := "-s -w -X main.Version=$(Version) -X main.GitCommit=$(GitCommit)" - +export GO111MODULE=on .PHONY: all -all: dist +all: gofmt test dist + +.PHONY: test +test: + CGO_ENABLED=0 go test $(shell go list ./... | grep -v /vendor/|xargs echo) -cover + +.PHONY: gofmt +gofmt: + @test -z $(shell gofmt -l -s $(SOURCE_DIRS) ./ | tee /dev/stderr) || (echo "[WARN] Fix formatting issues with 'make fmt'" && exit 1) .PHONY: dist dist: + mkdir -p bin/ + rm -rf bin/inlets* CGO_ENABLED=0 GOOS=linux go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/inletsctl CGO_ENABLED=0 GOOS=darwin go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/inletsctl-darwin CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/inletsctl.exe