Skip to content

Commit

Permalink
Updated makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Aug 15, 2020
1 parent 9c3c435 commit e688e02
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 39 deletions.
65 changes: 65 additions & 0 deletions .make/Makefile.common
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
## Default repository domain name
ifndef GIT_DOMAIN
override GIT_DOMAIN=github.com
endif

## Do we have git available?
HAS_GIT := $(shell command -v git 2> /dev/null)

ifdef HAS_GIT
## Do we have a repo?
HAS_REPO := $(shell git rev-parse --is-inside-work-tree 2> /dev/null)
ifdef HAS_REPO
## Automatically detect the repo owner and repo name (for local use with Git)
REPO_NAME=$(shell basename "$(shell git rev-parse --show-toplevel 2> /dev/null)")
REPO_OWNER=$(shell git config --get remote.origin.url | sed 's/git@$(GIT_DOMAIN)://g' | sed 's/\/$(REPO_NAME).git//g')
VERSION_SHORT=$(shell git describe --tags --always --abbrev=0)
export REPO_NAME, REPO_OWNER, VERSION_SHORT
endif
endif

## Set the distribution folder
ifndef DISTRIBUTIONS_DIR
override DISTRIBUTIONS_DIR=./dist
endif
export DISTRIBUTIONS_DIR

help: ## Show this help message
@egrep -h '^(.+)\:\ ##\ (.+)' ${MAKEFILE_LIST} | column -t -c 2 -s ':#'

release:: ## Full production release (creates release in Github)
@test $(github_token)
@export GITHUB_TOKEN=$(github_token) && goreleaser --rm-dist

release-test: ## Full production test release (everything except deploy)
@goreleaser --skip-publish --rm-dist

release-snap: ## Test the full release (build binaries)
@goreleaser --snapshot --skip-publish --rm-dist

replace-version: ## Replaces the version in HTML/JS (pre-deploy)
@test $(version)
@test "$(path)"
@find $(path) -name "*.html" -type f -exec sed -i '' -e "s/{{version}}/$(version)/g" {} \;
@find $(path) -name "*.js" -type f -exec sed -i '' -e "s/{{version}}/$(version)/g" {} \;

tag: ## Generate a new tag and push (tag version=0.0.0)
@test $(version)
@git tag -a v$(version) -m "Pending full release..."
@git push origin v$(version)
@git fetch --tags -f

tag-remove: ## Remove a tag if found (tag-remove version=0.0.0)
@test $(version)
@git tag -d v$(version)
@git push --delete origin v$(version)
@git fetch --tags

tag-update: ## Update an existing tag to current commit (tag-update version=0.0.0)
@test $(version)
@git push --force origin HEAD:refs/tags/v$(version)
@git fetch --tags -f

update-releaser: ## Update the goreleaser application
@brew update
@brew upgrade goreleaser
40 changes: 1 addition & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
## Set the distribution folder
ifndef DISTRIBUTIONS_DIR
override DISTRIBUTIONS_DIR=./release
endif

.PHONY: clean release
.PHONY: clean

audit: ## Checks for vulnerabilities in dependencies
@npm audit

clean: ## Remove previous builds and any test cache data
@if [ -d $(DISTRIBUTIONS_DIR) ]; then rm -r $(DISTRIBUTIONS_DIR); fi

help: ## Show all commands available
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

install: ## Installs the dependencies for the packge
@npm install

Expand All @@ -23,35 +15,5 @@ lint: ## Runs the standard-js lint tool
outdated: ## Checks for outdated packages via npm
@npm outdated

release: ## Full production release (creates release in Github)
@goreleaser --rm-dist

release-test: ## Full production test release (everything except deploy)
@goreleaser --skip-publish --rm-dist

release-snap: ## Test the full release (build binaries)
@goreleaser --snapshot --skip-publish --rm-dist

start: ## Starts running the bot
@npm run start

tag: ## Generate a new tag and push (IE: tag version=0.0.0)
@test $(version)
@git tag -a v$(version) -m "Pending full release..."
@git push origin v$(version)
@git fetch --tags -f

tag-remove: ## Remove a tag if found (IE: tag-remove version=0.0.0)
@test $(version)
@git tag -d v$(version)
@git push --delete origin v$(version)
@git fetch --tags

tag-update: ## Update an existing tag to current commit (IE: tag-update version=0.0.0)
@test $(version)
@git push --force origin HEAD:refs/tags/v$(version)
@git fetch --tags -f

update-releaser: ## Update the goreleaser application
@brew update
@brew upgrade goreleaser

0 comments on commit e688e02

Please sign in to comment.