makefile cleanups

This commit is contained in:
Casey Lee 2020-02-24 15:04:33 -08:00
parent 3a65967b95
commit d54b25d983
No known key found for this signature in database
GPG Key ID: 1899120ECD0A1784
3 changed files with 30 additions and 42 deletions

View File

@ -5,7 +5,6 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- run: echo ${{github.ref}}
- uses: actions/checkout@v2
- uses: docker://golangci/golangci-lint:v1.23.6
with:
@ -24,3 +23,19 @@ jobs:
env:
CGO_ENABLED: 0
GOFLAGS: -mod=vendor
release:
if: startsWith(github.ref, "refs/tags/v")
needs:
- lint
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}

View File

@ -1,19 +0,0 @@
name: tag
on:
push:
tags:
- 'v*'
jobs:
release:
if: startsWith(github.ref, "v")
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}

View File

@ -1,29 +1,21 @@
LATEST_VERSION := $(shell git tag -l --sort=creatordate | grep "^v[0-9]*.[0-9]*.[0-9]*$$" | tail -1 | cut -c 2-)
ifeq "$(shell git tag -l v$(LATEST_VERSION) --points-at HEAD)" "v$(LATEST_VERSION)"
### latest tag points to current commit, this is a release build
VERSION ?= $(LATEST_VERSION)
else
### latest tag points to prior commit, this is a snapshot build
MAJOR_VERSION := $(word 1, $(subst ., ,$(LATEST_VERSION)))
MINOR_VERSION := $(word 2, $(subst ., ,$(LATEST_VERSION)))
PATCH_VERSION := $(word 3, $(subst ., ,$(LATEST_VERSION)))
VERSION ?= $(MAJOR_VERSION).$(MINOR_VERSION).$(shell echo $$(( $(PATCH_VERSION) + 1)) )-develop
endif
VERSION?=$(shell git describe --tags --dirty | cut -c 2-)
IS_SNAPSHOT = $(if $(findstring -, $(VERSION)),true,false)
TAG_VERSION = v$(VERSION)
MAJOR_VERSION = $(word 1, $(subst ., ,$(VERSION)))
MINOR_VERSION = $(word 2, $(subst ., ,$(VERSION)))
PATCH_VERSION = $(word 3, $(subst ., ,$(word 1,$(subst -, , $(VERSION)))))
NEW_VERSION ?= $(MAJOR_VERSION).$(MINOR_VERSION).$(shell echo $$(( $(PATCH_VERSION) + 1)) )
ACT ?= go run main.go
export GITHUB_TOKEN = $(shell cat ~/.config/github/token)
check:
build:
go build -ldflags "-X main.version=$(VERSION)" -o dist/local/act main.go
test:
$(ACT) -P ubuntu-latest=nektos/act-environments-ubuntu:18.04
build: check
$(eval export SNAPSHOT_VERSION=$(VERSION))
$(ACT) -ra build
install: build
@cp dist/$(shell go env GOOS)_$(shell go env GOARCH)/act /usr/local/bin/act
@cp dist/local/act /usr/local/bin/act
@chmod 755 /usr/local/bin/act
@act --version
@ -32,7 +24,8 @@ installer:
godownloader -r nektos/act -o install.sh
promote: vendor
@echo "VERSION:$(VERSION) IS_SNAPSHOT:$(IS_SNAPSHOT) LATEST_VERSION:$(LATEST_VERSION)"
@git fetch --tags
@echo "VERSION:$(VERSION) IS_SNAPSHOT:$(IS_SNAPSHOT) NEW_VERSION:$(NEW_VERSION)"
ifeq (false,$(IS_SNAPSHOT))
@echo "Unable to promote a non-snapshot"
@exit 1
@ -41,9 +34,8 @@ ifneq ($(shell git status -s),)
@echo "Unable to promote a dirty workspace"
@exit 1
endif
$(eval NEW_VERSION := $(word 1,$(subst -, , $(TAG_VERSION))))
git tag -a -m "releasing $(NEW_VERSION)" $(NEW_VERSION)
git push origin $(NEW_VERSION)
git tag -a -m "releasing v$(NEW_VERSION)" v$(NEW_VERSION)
git push origin v$(NEW_VERSION)
vendor:
go mod vendor