diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index e3323f4..a167234 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -23,10 +23,16 @@ jobs: with: path-to-profile: ./build/test-all.cover - - name: Release and publish + - name: Release new version env: GH_TOKEN: ${{ github.token }} if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} run: |- make --file=Makefile.base --trace release && \ - make --file=Makefile.base --trace publish + + - name: Publish new version + env: + GH_TOKEN: ${{ github.token }} + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + run: |- + make --file=Makefile.base --trace publish || true diff --git a/Makefile b/Makefile index fa6b60a..24c2f44 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,5 @@ TARGETS := $(shell command -v go-make >/dev/null || \ # Delegate all targets to go-make in one call. # TODO: consider solution that does not delegate local goals. -$(eval $(lastwords $(MAKECMDGOALS)):;@:) -all $(firstword $(MAKECMDGOALS)):: +$(firstword $(MAKECMDGOALS) all):: $(GOBIN)/go-make $(MAKEFLAGS) $(MAKECMDGOALS); diff --git a/Makefile.base b/Makefile.base index c566ccc..e425cb4 100644 --- a/Makefile.base +++ b/Makefile.base @@ -23,7 +23,7 @@ CODE_QUALITY ?= base TEST_TIMEOUT ?= 10s # Function to search default config files -search-default = $(firstword $(wildcard $(1)) $(wildcard $(DIR_CONFIG)/$(1))) +search-default = $(firstword $(wildcard $(1)) $(wildcard $(DIR_CONFIG)$(1))) FILE_MAKE ?= $(call search-default,Makefile) FILE_VARS ?= $(call search-default,Makefile.vars) @@ -373,10 +373,13 @@ targets:: push:: @git push --set-upstream origin \ $$(git branch 2> /dev/null | sed -e '/^[^*]/d; s/* \(.*\)/\1/'); -#@ pushes the latest changes adding it to the previous commit of the origin. +#@ pushes the latest changes to the previous commit of the origin. fix:: @git commit --amend --no-edit && git push --force; -#@ pushes the latest changes adding it to the previous commit updating the message of the origin. +#@ pushes the latest changes to the previous commit of the origin without verifying them. +fix-no-verify:: + @git commit --amend --no-edit --no-verify && git push --force; +#@ pushes the latest changes to the previous commit of the origin updating the message. fix-update:: @git commit --amend && git push --force; @@ -1253,14 +1256,19 @@ update/go.mod?: $(GOBIN)/gomajor #@ update this build environment to latest version. update-make:: $(TARGETS_UPDATE_MAKE) $(TARGETS_UPDATE_MAKE):: update/%: update-base - @DIR="$$(pwd)"; cd $(BASEDIR); \ - if [ ! -e "$${DIR}/$*" ]; then touch "$${DIR}/$*"; fi; \ - DIFF="$$(diff <(git show HEAD:$* 2>/dev/null) $${DIR}/$*)"; \ - if [ -n "$${DIFF}" ]; then \ - if [ -n "$$(cd $${DIR}; git diff $*)" ]; then \ - echo "info: $* is blocked (has been changed)"; \ - else echo "info: $* is updated"; \ - git show HEAD:$* > $${DIR}/$* 2>/dev/null; \ + @DIR="$$(pwd)"; FILE="$*"; FILE="$${FILE##$(DIR_CONFIG)}"; \ + if [ ! -e "$${DIR}/$${FILE}" ]; then \ + echo "info: $${DIR}/$${FILE} (not configured - update skipped)"; \ + else cd "$(BASEDIR)"; \ + DIFF="$$(diff <(git show HEAD:$${FILE} 2>/dev/null) $${DIR}/$${FILE})"; \ + if [ -n "$${DIFF}" ]; then \ + if [ -n "$$(cd $${DIR}; git diff $${FILE})" ]; then \ + echo "info: $${DIR}/$${FILE} (was updated - update blocked)"; \ + else echo "info: $${DIR}/$${FILE} (has changed - update executed)"; \ + git show HEAD:$${FILE} > $${DIR}/$${FILE} 2>/dev/null; \ + fi; \ + else \ + echo "info: $${DIR}/$${FILE} (not changed - update skipped)" >/dev/null; \ fi; \ fi; \ diff --git a/README.md b/README.md index 571a6d9..2b88c38 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ also [Makefile](Makefile)): ```Makefile GOBIN ?= $(shell go env GOPATH)/bin -GOMAKE ?= github.com/tkrop/go-make@v0.0.10 +GOMAKE ?= github.com/tkrop/go-make@latest TARGETS := $(shell command -v go-make >/dev/null || \ go install $(GOMAKE) && go-make targets) @@ -156,8 +156,8 @@ TARGETS := $(shell command -v go-make >/dev/null || \ .PHONY: $(TARGETS) # Delegate all targets to go-make in one call. -$(eval $(lastwords $(MAKECMDGOALS)):;@:) -$(firstword $(MAKECMDGOALS)):: +# TODO: consider solution that does not delegate local goals. +$(firstword $(MAKECMDGOALS) all):: $(GOBIN)/go-make $(MAKEFLAGS) $(MAKECMDGOALS); ``` diff --git a/internal/make/fixtures/targets-trace.out b/internal/make/fixtures/targets-trace.out index 683f31b..08beb4c 100644 --- a/internal/make/fixtures/targets-trace.out +++ b/internal/make/fixtures/targets-trace.out @@ -24,6 +24,7 @@ clean-run-aws clean-run-db commit fix +fix-no-verify fix-update go.sum help diff --git a/internal/make/fixtures/targets.out b/internal/make/fixtures/targets.out index f8c665f..322e491 100644 --- a/internal/make/fixtures/targets.out +++ b/internal/make/fixtures/targets.out @@ -16,6 +16,7 @@ clean-run-aws clean-run-db commit fix +fix-no-verify fix-update go.sum help diff --git a/internal/make/make_test.go b/internal/make/make_test.go index ca6adb0..c9f0322 100644 --- a/internal/make/make_test.go +++ b/internal/make/make_test.go @@ -838,7 +838,7 @@ var ( // regexMatchTestDir is the regular expression that is used to remove the // test execution path dependent parts. regexMatchTestDir = regexp.MustCompile( - "(?m)/?/tmp/go-build.*/make.test.config/") + "(?m)/tmp/go-build.*/make.test.config/") // regexMatchBuildDir is the regular expression that is used to remove the // build path dependent parts. //lint:ignore S1007 // Escaping makes it less readable.