From 5ee3cfa1641514bba0dc7b62e5c61b1a9f151e23 Mon Sep 17 00:00:00 2001 From: Chen Zhiwei Date: Sat, 21 Aug 2021 19:36:47 +0800 Subject: [PATCH] enable github actions --- .github/workflows/pr.test.yaml | 22 +++++++++++++++++++ .github/workflows/push.build.yaml | 35 +++++++++++++++++++++++++++++++ Makefile | 8 ++++++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pr.test.yaml create mode 100644 .github/workflows/push.build.yaml diff --git a/.github/workflows/pr.test.yaml b/.github/workflows/pr.test.yaml new file mode 100644 index 0000000..b6f8f6f --- /dev/null +++ b/.github/workflows/pr.test.yaml @@ -0,0 +1,22 @@ +name: PR - run test +on: + pull_request + +jobs: + build: + name: build + runs-on: ubuntu-latest + steps: + + - name: checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: setup golang + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: make test + run: make test diff --git a/.github/workflows/push.build.yaml b/.github/workflows/push.build.yaml new file mode 100644 index 0000000..5cf1b9e --- /dev/null +++ b/.github/workflows/push.build.yaml @@ -0,0 +1,35 @@ +name: PUSH - build and release +on: + push: + branches: + - master + tags: + - "*" + +jobs: + build: + name: build + runs-on: ubuntu-latest + steps: + + - name: checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: setup golang + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: make test + run: make test + + - name: make build + run: make build + + - name: create release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: bin/certctl diff --git a/Makefile b/Makefile index 64d2d09..bf7d105 100644 --- a/Makefile +++ b/Makefile @@ -10,5 +10,11 @@ build: $(GOBUILD) -o $(BINDIR)/$(NAME) @strip $(BINDIR)/$(NAME) || true -test: +fmt: + go fmt ./... + +vet: + go vet ./... + +test: fmt vet go test ./pkg/cert