From 60e166b881d6169353580a3100924d19d986b054 Mon Sep 17 00:00:00 2001 From: Adriel Perkins Date: Mon, 20 Jun 2022 17:51:42 -0400 Subject: [PATCH] feat(ci): add github action workflows for ci and release --- .github/workflows/gorelease.yaml | 39 ++++++++++++++++++++++++++++ .github/workflows/main.yaml | 22 ++++++++++++++++ .github/workflows/semrelease.yaml | 22 ++++++++++++++++ .github/workflows/test-check-go.yaml | 36 +++++++++++++++++++++++++ Makefile | 7 +++-- 5 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/gorelease.yaml create mode 100644 .github/workflows/main.yaml create mode 100644 .github/workflows/semrelease.yaml create mode 100644 .github/workflows/test-check-go.yaml diff --git a/.github/workflows/gorelease.yaml b/.github/workflows/gorelease.yaml new file mode 100644 index 00000000..693b916d --- /dev/null +++ b/.github/workflows/gorelease.yaml @@ -0,0 +1,39 @@ +name: Go Releaser + +on: + push: + # run only against tags + tags: + - '*' + +permissions: + contents: write + packages: write + issues: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fetch all tags + run: git fetch --force --tags + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..425ade26 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,22 @@ +# This is the workflow for the main release branch. + +name: Main Build, Test, and Publish + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + + test-check-go: + uses: ./.github/workflows/test-check-go.yaml + + semrelease: + uses: ./.github/workflows/semrelease.yaml + needs: test-check-go + if: + contains(' + refs/heads/main + ', github.ref) diff --git a/.github/workflows/semrelease.yaml b/.github/workflows/semrelease.yaml new file mode 100644 index 00000000..5214d89a --- /dev/null +++ b/.github/workflows/semrelease.yaml @@ -0,0 +1,22 @@ +# This workflow runs conventional commit checker, semantic release, and goreleaser. + +name: Semantic Release + +on: + workflow_call: + +jobs: + + semrelease: + + name: Sem Release + runs-on: ubuntu-latest + + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - uses: go-semantic-release/action@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + changelog-generator-opt: "emojis=true" diff --git a/.github/workflows/test-check-go.yaml b/.github/workflows/test-check-go.yaml new file mode 100644 index 00000000..0315b323 --- /dev/null +++ b/.github/workflows/test-check-go.yaml @@ -0,0 +1,36 @@ +# This workflow runs tests and checks via the makefile against the project + +name: Make Test and Checks + +on: + workflow_call: + +jobs: + + test: + + name: Test and Check + runs-on: ubuntu-latest + + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Install Dependencies + run: | + go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/securego/gosec/v2/cmd/gosec@latest + go install golang.org/x/tools/cmd/goimports@latest + + - name: Make Test + run: | + make test + make checks + + + diff --git a/Makefile b/Makefile index dec930c7..df244cee 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ INSTALL_PATH ?= /usr/local/bin BIN_NAME ?= schemacheck BINDIR := $(CURDIR)/bin -.PHONY: tidy build test checks clean +.PHONY: tidy build test checks clean release default: build @@ -11,7 +11,10 @@ tidy: @go mod tidy build: - @goreleaser build --rm-dist --skip-validate + @go build -o dist/bin/schemacheck + +release: + @goreleaser build --rm-dist test: @go test -v