From 23436be00699584d97d5c49cf1a2e0faeb93aa0f Mon Sep 17 00:00:00 2001 From: Khosrow Moossavi Date: Thu, 6 May 2021 15:09:31 -0400 Subject: [PATCH 1/2] Update release scripts Signed-off-by: Khosrow Moossavi --- .github/workflows/release.yaml | 2 +- scripts/release/release.sh | 3 ++- scripts/release/update-choco.sh | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index be3e6ee..034abe8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -59,7 +59,7 @@ jobs: git-user: terraform-docs-bot git-user-email: bot@terraform-docs.io git-commit-message: "Chocolatey update for terraform-docs version v${{ steps.vars.outputs.tag }}" - excludes: README.md:LICENSE:.git:.github + excludes: README.md:LICENSE:DCO:.git:.github homebrew: runs-on: ubuntu-latest diff --git a/scripts/release/release.sh b/scripts/release/release.sh index 3cd5ed9..c436bfa 100755 --- a/scripts/release/release.sh +++ b/scripts/release/release.sh @@ -68,7 +68,8 @@ CLOSEST_VERSION=$(getClosestVersion) # Bump the released version in README and version.go if [[ $RELEASE_VERSION != *"-alpha"* && $RELEASE_VERSION != *"-beta"* && $RELEASE_VERSION != *"-rc"* ]]; then sed -i -E "s|${CLOSEST_VERSION}|${RELEASE_VERSION}|g" README.md - git add README.md + sed -i -E "s|${CLOSEST_VERSION}|${RELEASE_VERSION}|g" docs/user-guide/installation.md + git add README.md docs/user-guide/installation.md fi sed -i -E "s|v${RELEASE_VERSION}-alpha|v${RELEASE_VERSION}|g" internal/version/version.go diff --git a/scripts/release/update-choco.sh b/scripts/release/update-choco.sh index bd3efa1..07a116d 100755 --- a/scripts/release/update-choco.sh +++ b/scripts/release/update-choco.sh @@ -50,7 +50,11 @@ git clone https://github.com/terraform-docs/chocolatey-package "${PWD}/chocolate sed -i -E "s|${CLOSEST_VERSION}|${RELEASE_VERSION}|g" "${PWD}/chocolatey-package/terraform-docs.nuspec" # Bump version and checksum in tools/chocolateyinstall.ps1 -CHECKSUM=$(grep windows-amd64.exe "${PWD}/../../dist/terraform-docs-v${RELEASE_VERSION}.sha256sum" | awk '{print $1}') +CHECKSUM=$(grep windows-amd64.zip "${PWD}/../../dist/terraform-docs-v${RELEASE_VERSION}.sha256sum" | awk '{print $1}') sed -i -E "s|checksum = '.*$|checksum = '${CHECKSUM}'|g" "${PWD}/chocolatey-package/tools/chocolateyinstall.ps1" sed -i -E "s|v${CLOSEST_VERSION}|v${RELEASE_VERSION}|g" "${PWD}/chocolatey-package/tools/chocolateyinstall.ps1" + +pushd "${PWD}/chocolatey-package/" +git diff +popd From 5df7ff2bc8f0620e897ebbc0368f51642d785ee5 Mon Sep 17 00:00:00 2001 From: Khosrow Moossavi Date: Thu, 6 May 2021 16:17:06 -0400 Subject: [PATCH 2/2] Improve Makefile help message Signed-off-by: Khosrow Moossavi --- Makefile | 88 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index d67f04c..be08cc9 100644 --- a/Makefile +++ b/Makefile @@ -46,41 +46,41 @@ GOLANGCI_VERSION := v1.38.0 .PHONY: all all: clean verify checkfmt lint test build -######################### -## Development targets ## -######################### +############### +##@ Development + .PHONY: checkfmt -checkfmt: ## Check formatting of all go files +checkfmt: ## Check formatting of all go files @ $(MAKE) --no-print-directory log-$@ @ goimports -l $(GOIMPORTS_LOCAL_ARG) main.go cmd/ internal/ scripts/docs/ && echo "OK" .PHONY: clean -clean: ## Clean workspace +clean: ## Clean workspace @ $(MAKE) --no-print-directory log-$@ rm -rf ./$(BUILD_DIR) ./$(COVERAGE_OUT) .PHONY: fmt -fmt: ## Format all go files +fmt: ## Format all go files @ $(MAKE) --no-print-directory log-$@ goimports -w $(GOIMPORTS_LOCAL_ARG) main.go cmd/ internal/ scripts/docs/ .PHONY: lint -lint: ## Run linter +lint: ## Run linter @ $(MAKE) --no-print-directory log-$@ golangci-lint run ./... .PHONY: staticcheck -staticcheck: ## Run staticcheck +staticcheck: ## Run staticcheck @ $(MAKE) --no-print-directory log-$@ $(GO) run honnef.co/go/tools/cmd/staticcheck -- ./... .PHONY: test -test: ## Run tests +test: ## Run tests @ $(MAKE) --no-print-directory log-$@ $(GO) test -coverprofile=$(COVERAGE_OUT) -covermode=atomic -v ./... .PHONY: verify -verify: ## Verify 'vendor' dependencies +verify: ## Verify 'vendor' dependencies @ $(MAKE) --no-print-directory log-$@ $(GO) mod verify @@ -89,32 +89,32 @@ verify: ## Verify 'vendor' dependencies vendor: deps: -################### -## Build targets ## -################### +######### +##@ Build + .PHONY: build build: clean ## Build binary for current OS/ARCH @ $(MAKE) --no-print-directory log-$@ $(GOBUILD) -o ./$(BUILD_DIR)/$(GOOS)-$(GOARCH)/$(PROJECT_NAME) .PHONY: docker -docker: ## Build Docker image +docker: ## Build Docker image @ $(MAKE) --no-print-directory log-$@ docker build --pull --tag $(DOCKER_IMAGE):$(DOCKER_TAG) --file Dockerfile . .PHONY: push -push: ## Push Docker image +push: ## Push Docker image @ $(MAKE) --no-print-directory log-$@ docker push $(DOCKER_IMAGE):$(DOCKER_TAG) .PHONY: docs -docs: ## Generate document of formatter commands +docs: ## Generate document of formatter commands @ $(MAKE) --no-print-directory log-$@ $(GORUN) ./scripts/docs/generate.go -##################### -## Release targets ## -##################### +########### +##@ Release + PATTERN = # if the last relase was alpha, beta or rc, 'release' target has to used with current @@ -122,39 +122,39 @@ PATTERN = # released the following should be executed: "make release version=0.8.0" .PHONY: release release: VERSION ?= $(shell echo $(CUR_VERSION) | sed 's/^v//' | awk -F'[ .]' '{print $(PATTERN)}') -release: ## Prepare release +release: ## Prepare release @ $(MAKE) --no-print-directory log-$@ @ ./scripts/release/release.sh "$(VERSION)" "$(CUR_VERSION)" "1" .PHONY: patch patch: PATTERN = '\$$1\".\"\$$2\".\"\$$3+1' -patch: release ## Prepare Patch release +patch: release ## Prepare Patch release .PHONY: minor minor: PATTERN = '\$$1\".\"\$$2+1\".0\"' -minor: release ## Prepare Minor release +minor: release ## Prepare Minor release .PHONY: major major: PATTERN = '\$$1+1\".0.0\"' -major: release ## Prepare Major release +major: release ## Prepare Major release + +########### +##@ Helpers -#################### -## Helper targets ## -#################### .PHONY: goimports -goimports: +goimports: ## Install goimports ifeq (, $(shell which goimports)) GO111MODULE=off $(GO) get -u golang.org/x/tools/cmd/goimports endif .PHONY: golangci -golangci: +golangci: ## Install golangci ifeq (, $(shell which golangci-lint)) curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(shell $(GO) env GOPATH)/bin $(GOLANGCI_VERSION) endif .PHONY: tools -tools: ## Install required tools +tools: ## Install required tools @ $(MAKE) --no-print-directory log-$@ @ $(MAKE) --no-print-directory goimports golangci @@ -162,9 +162,33 @@ tools: ## Install required tools ## Self-Documenting Makefile Help ## ## https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html ## ######################################################################## + +######## +##@ Help + .PHONY: help -help: - @ grep -h -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' +help: ## Display this help + @awk \ + -v "col=\033[36m" -v "nocol=\033[0m" \ + ' \ + BEGIN { \ + FS = ":.*##" ; \ + printf "Usage:\n make %s%s\n", col, nocol \ + } \ + /^[a-zA-Z_-]+:.*?##/ { \ + printf " %s%-12s%s %s\n", col, $$1, nocol, $$2 \ + } \ + /^##@/ { \ + printf "\n%s%s%s\n", nocol, substr($$0, 5), nocol \ + } \ + ' $(MAKEFILE_LIST) log-%: - @ grep -h -E '^$*:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m==> %s\033[0m\n", $$2}' + @grep -h -E '^$*:.*?## .*$$' $(MAKEFILE_LIST) | \ + awk \ + 'BEGIN { \ + FS = ":.*?## " \ + }; \ + { \ + printf "\033[36m==> %s\033[0m\n", $$2 \ + }'