NOTHING_ELSE ?=
export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
_empty = _sp = $(_empty) $(_empty)
member-check = \ $(strip \ $(if $($(1)), \ $(if $(findstring $(_sp),$($(1))), \ $(error invalid $(1): '$($(1))', expected $(2)), \ $(or $(findstring $(_sp)$($(1))$(_sp),$(_sp)$(2)$(_sp)), \ $(error invalid $(1): '$($(1))', expected $(2)))), \ $(error $(1) undefined)))
include Makefile
GIT ?= git LUA ?= lua LUAROCKS ?= luarocks TAR ?= tar
today ?= $(shell date +%Y-%m-%d)
release_archive_dir ?= ../release
release-prep-hook ?= release-prep
build-aux ?= build-aux my_distdir ?= $(PACKAGE)-$(VERSION) prev_version_file ?= $(srcdir)/.prev-version old_NEWS_hash-file ?= $(srcdir)/local.mk gl_noteworthy_news = ## Noteworthy changes in release ?.? (????-??-??) [?]
PREV_VERSION = $(shell cat $(prev_version_file) 2>/dev/null) VERSION_REGEXP = $(subst .,.,$(VERSION)) PREV_VERSION_REGEXP = $(subst .,.,$(PREV_VERSION))
gitlog_to_changelog = $(srcdir)/build-aux/gitlog-to-changelog
dist-hook: ChangeLog .PHONY: ChangeLog ChangeLog: $(AM_V_GEN)if test -d '$(srcdir)/.git'; then \ $(gitlog_to_changelog) $(gitlog_args) > '$@T'; \ rm -f '$@'; mv '$@T' '$@'; \ fi
_travis_yml ?= .travis.yml travis.yml.in
release_extra_dist ?= \ .autom4te.cfg \ GNUmakefile \ bootstrap \ bootstrap.conf \ local.mk \ $(_travis_yml) \ $(NOTHING_ELSE)
EXTRA_DIST += \ $(_build-aux)/release.mk \ $(gitlog_to_changelog) \ $(release_extra_dist) \ $(NOTHING_ELSE)
all-am: $(_travis_yml)
RELEASE_TYPES = alpha beta stable release-type = $(call member-check,RELEASE_TYPE,$(RELEASE_TYPES))
.PHONY: release release: $(AM_V_GEN)$(MAKE) $(release-type) $(AM_V_GEN)$(MAKE) push $(AM_V_GEN)$(MAKE) upload $(AM_V_GEN)$(MAKE) mail
submodule-checks ?= no-submodule-changes public-submodule-commit
.PHONY: no-submodule-changes no-submodule-changes: $(AM_V_GEN)if test -d $(srcdir)/.git \ && git --version >/dev/null 2>&1; then \ diff=$$(cd $(srcdir) && git submodule -q foreach \ git diff-index --name-only HEAD); \ case $$diff in '') ;; \ *) echo '$(ME): submodule files are locally modified:'; \ echo "$$diff"; exit 1;; esac; \ else \ : ; \ fi
.PHONY: public-submodule-commit public-submodule-commit: $(AM_V_GEN)if test -d $(srcdir)/.git \ && git --version >/dev/null 2>&1; then \ cd $(srcdir) && \ git submodule --quiet foreach \ 'test "$$(git rev-parse "$$sha1")" \ = "$$(git merge-base origin "$$sha1")"' \ || { echo '$(ME): found non-public submodule commit' >&2; \ exit 1; }; \ else \ : ; \ fi
gl_public_submodule_commit ?= public-submodule-commit check: $(gl_public_submodule_commit)
.PHONY: alpha beta stable alpha beta stable: $(submodule-checks) $(AM_V_GEN)test $@ = stable && \ { echo $(VERSION) |$(EGREP) '^[0-9]+(.[0-9]+)*$$' >/dev/null \ || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\ || : $(AM_V_at)$(MAKE) prev-version-check $(AM_V_at)$(MAKE) vc-diff-check $(AM_V_at)$(MAKE) release-commit RELEASE_TYPE=$@ $(AM_V_at)$(MAKE) news-check $(AM_V_at)$(MAKE) distcheck $(AM_V_at)$(MAKE) check $(AM_V_at)$(MAKE) $(release-prep-hook) RELEASE_TYPE=$@ $(AM_V_at)$(MAKE) check-in-release-branch
prev-version-check:
$(AM_V_at)if test -z "$(GIT) ls-files $(prev_version_file)
"; \
then \
echo "error: checked in $(prev_version_file) required." >&2; \
exit 1; \
fi
vc-diff-check: $(AM_V_at)if ! $(GIT) diff --exit-code; then \ $(GIT) diff >/dev/null; \ echo "error: Some files are locally modified" >&2; \ exit 1; \ fi
news-check-lines-spec ?= 3 news-check-regexp ?= '^##.* $(VERSION_REGEXP) ($(today))'
Makefile.in: NEWS
NEWS: $(AM_V_GEN)if test -f NEWS.md; then ln -s NEWS.md NEWS; \ elif test -f NEWS.rst; then ln -s NEWS.rst NEWS; \ elif test -f NEWS.txt; then ln -s NEWS.txt NEWS; \ fi
news-check: NEWS $(AM_V_GEN)if $(SED) -n $(news-check-lines-spec)p $< \ | $(EGREP) $(news-check-regexp) >/dev/null; then \ :; \ else \ echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \ exit 1; \ fi
.PHONY: release-commit release-commit: NEWS $(AM_V_GEN)cd $(srcdir) \ && $(_build-aux)/do-release-commit-and-tag \ -C $(abs_builddir) $(VERSION) $(RELEASE_TYPE)
define emit-commit-log printf '%s\n' 'maint: post-release administrivia.' '' \ ' NEWS: Add header line for next release.' \ ' .prev-version: Record previous version.' \ '* $(old_NEWS_hash-file) (old_NEWS_hash): Auto-update.' endef
.PHONY: release-prep
release-prep: $(scm_rockspec)
$(AM_V_GEN)$(MAKE) --no-print-directory -s announcement \
> ~/announce-$(my_distdir)
$(AM_V_at)if test -d $(release_archive_dir); then \
ln $(rel-files) $(release_archive_dir); \
chmod a-w $(rel-files); \
fi
$(AM_V_at)echo $(VERSION) > $(prev_version_file)
$(AM_V_at)$(MAKE) update-old-NEWS-hash
$(AM_V_at)perl -pi \
-e '$$. == 3 and print "$(gl_noteworthy_news_)\n\n\n"' \
readlink $(srcdir)/NEWS 2>/dev/null || echo $(srcdir)/NEWS
$(AM_V_at)msg=$$($(emit-commit-log)) || exit 1; \
cd $(srcdir) && $(GIT) commit -s -m "$$msg" -a
@echo '**** Release announcement in ~/announce-$(my_distdir)'
NEWS_hash = \ $$(sed -n '/^*. $(PREV_VERSION_REGEXP) ([0-9-])/,$$p' \ $(srcdir)/NEWS \ | perl -0777 -pe 's/^Copyright.+?[12][0-9]{3}.+?\n//ms' \ | md5sum - \ | sed 's/ .*//')
old-NEWS-regexp = '^old_NEWS_hash[ \t]+?=[ \t]+' update-old-NEWS-hash: NEWS $(AM_V_GEN)if $(EGREP) $(old-NEWS-regexp) $(old_NEWS_hash-file); then \ perl -pi -e 's/^(old_NEWS_hash[ \t]+:?=[ \t]+).*/$${1}'"$(NEWS_hash)/" \ $(old_NEWS_hash-file); \ else \ printf '%s\n' '' "old_NEWS_hash = $(NEWS_hash)" \ >> $(old_NEWS_hash-file); \ fi
ANNOUNCE_ENV = LUA_INIT= LUA_PATH='$(abs_srcdir)/?-git-1.rockspec' ANNOUNCE_PRINT = $(ANNOUNCE_ENV) $(LUA) -l$(PACKAGE) -e
_PRE = " https://raw.githubusercontent" _POST = "/release-v$(VERSION)/$(PACKAGE)-$(VERSION)-$(rockspec_revision).rockspec" GITHUB_ROCKSPEC = (source.url:gsub ("^git://github", $(_PRE)):gsub ("%.git$$", $(_POST)))
announcement: NEWS
$(AM_V_at)printf '%s\n' \ '# [ANN] $(PACKAGE_NAME) $(VERSION) released' \ '' $(AM_V_at)$(ANNOUNCE_PRINT) 'print (description.detailed)' $(AM_V_at)printf '%s\n' '' \ 'I am happy to announce release $(VERSION) of $(PACKAGE_NAME).' \ '' $(AM_V_at)$(ANNOUNCE_PRINT) \ 'print ("$(PACKAGE_NAME)'\''s home page is at " .. description.homepage)' $(AM_V_at)printf '\n' $(AM_V_at)$(SED) -n \ -e '/^\#\# Noteworthy changes in release $(PREV_VERSION)/q' \ -e p NEWS |$(SED) -e 1,2d $(AM_V_at)printf '%s\n' \ 'Install it with LuaRocks, using:' '' \ ' luarocks install $(PACKAGE) $(VERSION)' $(AM_V_at)$(ANNOUNCE_PRINT) 'print ($(GITHUB_ROCKSPEC))'
branch = $(shell $(GIT) branch |$(SED) -ne '/^* /{s///;p;q;}') GCO = $(GIT) checkout release-tarball = $(my_distdir).tar.gz
_save-files = \ $(release-tarball) \ $(save_release_files) \ $(NOTHING_ELSE)
list-to-rexp = $(SED) -e 's|^|(|' -e 's/|$$/)/'
git-clean-files = printf -- '-e %s ' $(_save-files)
grep-clean-files = printf -- '%s|' $(_save-files) |$(list-to-rexp)
submodule-regexp ?= '^[submodule "' submodule-extract-spec ?= 's|^."([^"])".*$$|\1|'
.PHONY: check-in-release-branch
check-in-release-branch:
$(AM_V_GEN)$(GCO) -b release v$(VERSION) 2>/dev/null || $(GCO) release
$(AM_V_at)$(GIT) pull origin release 2>/dev/null || true
$(AM_V_at)if $(EGREP) $(submodule-regexp) .gitmodules >/dev/null 2>&1; then \
$(EGREP) $(submodule-regexp) .gitmodules \
| $(SED) $(submodule-extract-spec) | xargs rm -rf; \
fi
$(AM_V_at)$(GIT) clean -dfx $(git-clean-files)
$(AM_V_at)remove_re=$(grep-clean-files); \
$(GIT) rm -f $(GIT) ls-files |$(EGREP) -v "$$remove_re"
$(AM_V_at)ln -s . '$(my_distdir)'
$(AM_V_at)$(TAR) zxf '$(release-tarball)'
$(AM_V_at)rm -f '$(my_distdir)' '$(release-tarball)'
$(AM_V_at)$(GIT) add .
$(AM_V_at)$(GIT) commit -s -a -m 'Release v$(VERSION).'
$(AM_V_at)$(GIT) tag -s -a -m 'Full source release v$(VERSION)' release-v$(VERSION)
$(AM_V_at)$(GCO) $(branch)
.PHONY: push push: $(AM_V_at)$(GIT) push origin master $(AM_V_at)$(GIT) push origin release $(AM_V_at)$(GIT) push origin v$(VERSION) $(AM_V_at)$(GIT) push origin release-v$(VERSION)
.PHONY: upload upload: rockspecs $(AM_V_at)$(LUAROCKS) upload $${API_KEY+--api-key=$$API_KEY} \ '$(PACKAGE)-$(VERSION)-$(rockspec_revision).rockspec'
announce_emails ?= lua-l@lists.lua.org
.PHONY: mail mail: rockspecs $(AM_V_at)cat ~/announce-$(my_distdir) \ | mail -s '[ANN] $(PACKAGE) $(VERSION) released' -- \ $(announce_emails)