From b687b98d60e3ac35448f3879cd665ac97ee6675e Mon Sep 17 00:00:00 2001 From: DC* Date: Sun, 14 Jan 2018 13:35:53 -0300 Subject: [PATCH 1/2] WIP: Update release tooling --- Makefile | 27 +++++++++++++++------------ Makefile.in | 27 +++++++++++++++------------ tests/.antigenrc | 2 +- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 9f848832..196f69c1 100644 --- a/Makefile +++ b/Makefile @@ -93,9 +93,8 @@ define isede mv "$(2).1" "$(2)" endef -.PHONY: itests tests install all -build: +build: ## Builds Antigen with current configuration settings. @echo Building Antigen... @printf "${BANNER}" > ${BIN}/antigen.zsh @printf "${HEADER_TEXT}" >> ${BIN}/antigen.zsh @@ -112,7 +111,7 @@ endif @echo Done. @ls -sh ${TARGET} -release: +release: ## Creates a new release. Specify a version with `VERSION=v1.2.3`. # Move to release branch git checkout develop git checkout -b release/${VERSION} @@ -127,11 +126,11 @@ release: git add ${TARGET} git commit -S -m "Build release ${VERSION}" -publish: +publish: ## Publish a release upstream (origin). Specify a version with `VERSION=v1.2.3`. git push origin release/${VERSION} # Merge release branch into develop before deploying -deploy: +deploy: ## Creates release artifacts and push tag upstream. Specify a version with `VERSION=v1.2.3`. git checkout develop git tag -m "Build release ${VERSION}" -s ${VERSION} git archive --output=${VERSION}.tar.gz --prefix=antigen-$$(echo ${VERSION}|sed s/v//)/ ${VERSION} @@ -148,25 +147,29 @@ else ifeq (${USE_CONTAINER}, no) ${COMMAND} endif -info: +info: ## Display Antigen, zsh, git version and environment variables. @${MAKE} .container COMMAND="sh -c 'cat ${PROJECT}/VERSION; zsh --version; git --version; env'" itests: @${MAKE} tests CRAM_OPTS=-i -tests: +tests: ## Run cram tests, use `TEST=.../path/to/tests.t` to run an specific test. @${MAKE} .container COMMAND="sh -c 'ZDOTDIR=${TESTS} ANTIGEN=${PROJECT} cram ${CRAM_OPTS} --shell=zsh ${TEST}'" -stats: +stats: ## Run stats script with current version. @${MAKE} .container COMMAND="${TOOLS}/stats --zsh zsh --antigen ${PROJECT}" -install: +install: ## Install Antigen locally. mkdir -p ${PREFIX}/share && cp ${TARGET} ${PREFIX}/share/antigen.zsh -clean: +clean: ## Removes Antigen from system. rm -f ${PREFIX}/share/antigen.zsh -install-deps: +install-deps: ## Install Antigen development dependencies. sudo pip install cram=='0.6.*' -all: clean build install +# From: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' + + diff --git a/Makefile.in b/Makefile.in index a4946c74..da654e3f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -81,9 +81,8 @@ define isede mv "$(2).1" "$(2)" endef -.PHONY: itests tests install all -build: +build: ## Builds Antigen with current configuration settings. @echo Building Antigen... @printf "${BANNER}" > ${BIN}/antigen.zsh @printf "${HEADER_TEXT}" >> ${BIN}/antigen.zsh @@ -100,7 +99,7 @@ endif @echo Done. @ls -sh ${TARGET} -release: +release: ## Creates a new release. Specify a version with `VERSION=v1.2.3`. # Move to release branch git checkout develop git checkout -b release/${VERSION} @@ -115,11 +114,11 @@ release: git add ${TARGET} git commit -S -m "Build release ${VERSION}" -publish: +publish: ## Publish a release upstream (origin). Specify a version with `VERSION=v1.2.3`. git push origin release/${VERSION} # Merge release branch into develop before deploying -deploy: +deploy: ## Creates release artifacts and push tag upstream. Specify a version with `VERSION=v1.2.3`. git checkout develop git tag -m "Build release ${VERSION}" -s ${VERSION} git archive --output=${VERSION}.tar.gz --prefix=antigen-$$(echo ${VERSION}|sed s/v//)/ ${VERSION} @@ -136,25 +135,29 @@ else ifeq (${USE_CONTAINER}, no) ${COMMAND} endif -info: +info: ## Display Antigen, zsh, git version and environment variables. @${MAKE} .container COMMAND="sh -c 'cat ${PROJECT}/VERSION; zsh --version; git --version; env'" itests: @${MAKE} tests CRAM_OPTS=-i -tests: +tests: ## Run cram tests, use `TEST=.../path/to/tests.t` to run an specific test. @${MAKE} .container COMMAND="sh -c 'ZDOTDIR=${TESTS} ANTIGEN=${PROJECT} cram ${CRAM_OPTS} --shell=zsh ${TEST}'" -stats: +stats: ## Run stats script with current version. @${MAKE} .container COMMAND="${TOOLS}/stats --zsh zsh --antigen ${PROJECT}" -install: +install: ## Install Antigen locally. mkdir -p ${PREFIX}/share && cp ${TARGET} ${PREFIX}/share/antigen.zsh -clean: +clean: ## Removes Antigen from system. rm -f ${PREFIX}/share/antigen.zsh -install-deps: +install-deps: ## Install Antigen development dependencies. sudo pip install cram=='0.6.*' -all: clean build install +# From: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' + + diff --git a/tests/.antigenrc b/tests/.antigenrc index 9ecd5e2c..817f7f0c 100644 --- a/tests/.antigenrc +++ b/tests/.antigenrc @@ -37,7 +37,7 @@ antigen bundles < Date: Mon, 15 Jan 2018 00:00:46 -0300 Subject: [PATCH 2/2] WIP: make release / make publish -> creates draft release on github --- Makefile | 30 ++++++++++++++++++++---------- Makefile.in | 40 ++++++++++++++++++++++++++++------------ VERSION | 2 +- tools/github-release | 20 ++++++++++++++++++++ 4 files changed, 69 insertions(+), 23 deletions(-) create mode 100644 tools/github-release diff --git a/Makefile b/Makefile index 196f69c1..1ba98573 100644 --- a/Makefile +++ b/Makefile @@ -115,6 +115,8 @@ release: ## Creates a new release. Specify a version with `VERSION=v1.2.3`. # Move to release branch git checkout develop git checkout -b release/${VERSION} + # Update version information + @echo ${VERSION} > ${VERSION_FILE} # Run build and tests ${MAKE} build tests # Update changelog @@ -125,20 +127,28 @@ release: ## Creates a new release. Specify a version with `VERSION=v1.2.3`. # Update binary artifact git add ${TARGET} git commit -S -m "Build release ${VERSION}" + git push origin release/$(cat ${VERSION_FILE}) -publish: ## Publish a release upstream (origin). Specify a version with `VERSION=v1.2.3`. - git push origin release/${VERSION} - # Merge release branch into develop before deploying - -deploy: ## Creates release artifacts and push tag upstream. Specify a version with `VERSION=v1.2.3`. +create-tag: git checkout develop - git tag -m "Build release ${VERSION}" -s ${VERSION} - git archive --output=${VERSION}.tar.gz --prefix=antigen-$$(echo ${VERSION}|sed s/v//)/ ${VERSION} - zcat ${VERSION}.tar.gz | gpg --armor --detach-sign >${VERSION}.tar.gz.sign + git merge release/$$(cat ${VERSION_FILE}) + git tag -m "Build release $$(cat ${VERSION_FILE})" -s $$(cat ${VERSION_FILE}) + +archive: + git archive --output=$$(cat ${VERSION_FILE}).tar.gz --prefix=$$(echo $$(cat ${VERSION_FILE})|sed s/v//)/ $$(cat ${VERSION_FILE}) + +sign-archive: + zcat $$(cat ${VERSION_FILE}).tar.gz | gpg --armor --detach-sign >$$(cat ${VERSION_FILE}).tar.gz.sign # Verify signature - zcat ${VERSION}.tar.gz | gpg --verify ${VERSION}.tar.gz.sign - + zcat $$(cat ${VERSION_FILE}).tar.gz | gpg --verify $$(cat ${VERSION_FILE}).tar.gz.sign - + +publish: create-tag archive sign-archive ## Creates release artifacts and push tag upstream. # Push upstream - git push upstream ${VERSION} + git push upstream $$(cat ${VERSION_FILE}) + +create-release: + echo -e ${TARGET}\\n$$(cat ${VERSION_FILE}).tar.gz\\n$$(cat ${VERSION_FILE}).tar.gz.sign | bash ./tools/github-release Release $$(cat ${VERSION_FILE}) + .container: ifeq (${USE_CONTAINER}, docker) diff --git a/Makefile.in b/Makefile.in index da654e3f..1830984e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -60,6 +60,9 @@ endif VERSION ?= develop VERSION_FILE = ${PROJECT}/VERSION +RELEASE ?= $(cat ${VERSION_FILE}) +TAR_GZ ?= ${RELEASE}.tar.gz +TAR_SIGN ?= ${TAR_GZ}.sign BANNER_SEP =$(shell printf '%*s' 70 | tr ' ' '\#') BANNER_TEXT =This file was autogenerated by \`make\`. Do not edit it directly! @@ -99,10 +102,15 @@ endif @echo Done. @ls -sh ${TARGET} -release: ## Creates a new release. Specify a version with `VERSION=v1.2.3`. - # Move to release branch +build-release: + # All releases starts from develop git checkout develop + # Move to release branch to build this release + git branch -D release/${VERSION} git checkout -b release/${VERSION} + @echo Building release ${VERSION}... + # Update version information + @echo ${VERSION} > ${VERSION_FILE} # Run build and tests ${MAKE} build tests # Update changelog @@ -110,23 +118,31 @@ release: ## Creates a new release. Specify a version with `VERSION=v1.2.3`. # Build release commit git add CHANGELOG.md README.mkd ${VERSION_FILE} git commit -S -m "Update changelog for ${VERSION}" + +release: build-release ## Creates a new release. Specify a version with `VERSION=v1.2.3`. # Update binary artifact git add ${TARGET} git commit -S -m "Build release ${VERSION}" + git push origin release/$(cat ${VERSION_FILE}) -publish: ## Publish a release upstream (origin). Specify a version with `VERSION=v1.2.3`. - git push origin release/${VERSION} - # Merge release branch into develop before deploying - -deploy: ## Creates release artifacts and push tag upstream. Specify a version with `VERSION=v1.2.3`. +create-tag: # Creates a tag for current version. git checkout develop - git tag -m "Build release ${VERSION}" -s ${VERSION} - git archive --output=${VERSION}.tar.gz --prefix=antigen-$$(echo ${VERSION}|sed s/v//)/ ${VERSION} - zcat ${VERSION}.tar.gz | gpg --armor --detach-sign >${VERSION}.tar.gz.sign + git merge release/${RELEASE} + git tag -m "Build release ${RELEASE}" -s ${RELEASE} + +archive: create-tag # Creates an archive for current version. + git archive --output=${TAR_GZ} --prefix=${RELEASE}|sed s/v//)/ ${RELEASE} + +sign-archive: archive # Signs archived versions. + zcat ${TAR_GZ} | gpg --armor --detach-sign >${TAR_SIGN} # Verify signature - zcat ${VERSION}.tar.gz | gpg --verify ${VERSION}.tar.gz.sign - + zcat ${TAR_GZ} | gpg --verify ${TAR_SIGN} - + +publish: sign-archive ## Creates release artifacts and push tag upstream. # Push upstream - git push upstream ${VERSION} + #git push upstream ${RELEASE} + @echo -e ${TARGET}\\n$$(cat ${VERSION_FILE}).tar.gz\\n$$(cat ${VERSION_FILE}).tar.gz.sign | bash ./tools/github-release Release $$(cat ${VERSION_FILE}) + @echo Publish Github release ${RELEASE} from https://github.com/desyncr/antigen/releases .container: ifeq (${USE_CONTAINER}, docker) diff --git a/VERSION b/VERSION index 6563189c..b1d18bc4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -develop +v2.3.0 diff --git a/tools/github-release b/tools/github-release new file mode 100644 index 00000000..7e2a269e --- /dev/null +++ b/tools/github-release @@ -0,0 +1,20 @@ +#!/bin/bash +# Usage: script/cross-compile | script/github-release +# +# Takes in a list of asset filenames + labels via stdin and uploads them to the +# corresponding release on GitHub. The release is created as a draft first if +# missing and its body is the git changelog since the previous tagged release. +set -e + +project_name="${1?}" +version="${2?}" +[[ $version == *-* ]] && pre=1 || pre= + +assets=() +while read -r filename; do + assets+=( -a "${filename}" ) +done + +{ echo "${project_name} ${version}" + echo +} | hub release create -d ${pre:+--prerelease} -f - "${version}" "${assets[@]}"