Skip to content

Commit

Permalink
added github workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Yuvraj <evalsocket@users.noreply.github.com>
  • Loading branch information
Yuvraj committed Jan 9, 2023
1 parent a87ef1a commit 0087a92
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 6 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/publish.yaml
@@ -0,0 +1,34 @@
name: Publish

on:
push:
tags:
- "v*"

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-go@v3
with:
go-version: '>=1.18.1'
cache: true

- name: Check quality
run: make quality

- name: Run tests
run: make test

- name: Release Binaries
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .goreleaser.yml
@@ -0,0 +1,35 @@
before:
hooks:
- go mod tidy
builds:
- binary: rollback-buildkite-plugin
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- "386"
- amd64
- arm
- arm64
- ppc64le

checksum:
name_template: 'checksums.txt'

archives:
- format: 'binary'
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
files:
- completions/*

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
46 changes: 40 additions & 6 deletions Makefile
@@ -1,9 +1,43 @@
all: test
NAME=rollback-buildkite-plugin

test:
go test -timeout=3s -v ./...
HAS_DOCKER=$(shell command -v docker;)
HAS_GORELEASER=$(shell command -v goreleaser;)

build:
go build main.go
.PHONY: all
all: quality test

.PHONY: test-go
test-go:
go test -race -coverprofile=coverage.out -covermode=atomic

.PHONY: build-docker-test
build-docker-test:
ifneq (${HAS_DOCKER},)
docker-compose build plugin_test
endif

.PHONY: test-docker
test-docker: build-docker-test
ifneq (${HAS_DOCKER},)
docker-compose run --rm plugin_test
endif

.PHONY: all build test
.PHONY: test
test: test-go test-docker

.PHONY: quality
quality:
go vet
go fmt
go mod tidy
ifneq (${HAS_DOCKER},)
docker-compose run --rm plugin_lint
endif

.PHONY: build
build:
ifneq (${HAS_GORELEASER},)
goreleaser build --rm-dist --skip-validate
else
$(error goreleaser binary is missing, please install goreleaser)
endif
1 change: 1 addition & 0 deletions hooks/post-command
Expand Up @@ -2,6 +2,7 @@

set -euo pipefail

# Ref: https://github.com/monebag/monorepo-diff-buildkite-plugin/blob/master/hooks/command
check_cmd() {
command -v "$1" > /dev/null 2>&1
return $?
Expand Down

0 comments on commit 0087a92

Please sign in to comment.