Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Update release tooling #646

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -112,10 +111,12 @@ 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}
# Update version information
@echo ${VERSION} > ${VERSION_FILE}
# Run build and tests
${MAKE} build tests
# Update changelog
Expand All @@ -126,20 +127,28 @@ release:
# Update binary artifact
git add ${TARGET}
git commit -S -m "Build release ${VERSION}"
git push origin release/$(cat ${VERSION_FILE})

publish:
git push origin release/${VERSION}
# Merge release branch into develop before deploying

deploy:
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)
Expand All @@ -148,25 +157,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}'


61 changes: 40 additions & 21 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -81,9 +84,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
Expand All @@ -100,34 +102,47 @@ endif
@echo Done.
@ls -sh ${TARGET}

release:
# 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
${EDITOR} CHANGELOG.md
# 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:
git push origin release/${VERSION}
# Merge release branch into develop before deploying

deploy:
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)
Expand All @@ -136,25 +151,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}'


2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
develop
v2.3.0
2 changes: 1 addition & 1 deletion tests/.antigenrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ antigen bundles <<EOBUNDLES
chrissicool/zsh-256color
pass
sprunge
git@github.com:desyncr/gitr.git --branch=develop
github.com/desyncr/gitr.git --branch=develop
git://repo.or.cz/safe-rm.git
EOBUNDLES

Expand Down
20 changes: 20 additions & 0 deletions tools/github-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# Usage: script/cross-compile | script/github-release <name> <version>
#
# 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[@]}"