Skip to content

Commit

Permalink
feat(ci): add github action workflows for ci and release
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriel Perkins committed Jun 20, 2022
1 parent cb59f4a commit 60e166b
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 2 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/gorelease.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
22 changes: 22 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -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)
22 changes: 22 additions & 0 deletions .github/workflows/semrelease.yaml
Original file line number Diff line number Diff line change
@@ -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"
36 changes: 36 additions & 0 deletions .github/workflows/test-check-go.yaml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ 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

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
Expand Down

0 comments on commit 60e166b

Please sign in to comment.