Skip to content

Commit

Permalink
makefile cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
cplee committed Feb 24, 2020
1 parent 3a65967 commit d54b25d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 42 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
19 changes: 0 additions & 19 deletions .github/workflows/tag.yml

This file was deleted.

36 changes: 14 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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:
$(ACT) -P ubuntu-latest=nektos/act-environments-ubuntu:18.04
build:
go build -ldflags "-X main.version=$(VERSION)" -o dist/local/act main.go

build: check
$(eval export SNAPSHOT_VERSION=$(VERSION))
$(ACT) -ra build
test:
$(ACT) -P ubuntu-latest=nektos/act-environments-ubuntu:18.04

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

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

0 comments on commit d54b25d

Please sign in to comment.