File: release.mk

package info (click to toggle)
lua-curses 1%3A9.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,328 kB
  • sloc: sh: 11,898; ansic: 2,704; makefile: 52
file content (393 lines) | stat: -rw-r--r-- 13,604 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# Slingshot release rules for GNU Make.

# ======================================================================
# Copyright (C) 2001-2016 Free Software Foundation, Inc.
# Originally by Jim Meyering, Simon Josefsson, Eric Blake,
#               Akim Demaille, Gary V. Vaughan, and others.
# This version by Gary V. Vaughan, 2013.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# ======================================================================

NOTHING_ELSE ?=


## --------------- ##
## GNU Make magic. ##
## --------------- ##

# This file uses GNU Make extensions. Include it from GNUmakefile with:
#
#   include build-aux/release.mk

# Make tar archive easier to reproduce.
export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner

# Helper variables.
_empty =
_sp = $(_empty) $(_empty)

# member-check,VARIABLE,VALID-VALUES
# ----------------------------------
# Check that $(VARIABLE) is in the space-separated list of VALID-VALUES, and
# return it.  Die otherwise.
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

## --------- ##
## Defaults. ##
## --------- ##

GIT	 ?= git
LUA	 ?= lua
LUAROCKS ?= luarocks
TAR	 ?= tar

# Override this in cfg.mk if you are using a different format in your
# NEWS file.
today ?= $(shell date +%Y-%m-%d)

# Old releases are stored here.
release_archive_dir ?= ../release

# Override this in cfg.mk if you follow different procedures.
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))


## ------------- ##
## Distribution. ##
## ------------- ##

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

# Override this in GNUmakefile if you don't want to automatically
# redistribute all the maintainer support files (take care that
# Travis CI is finicky about this, and will likely need tweaking
# to cope with missing any of these if you decide to omit them).

_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. ##
## -------- ##

# The vast majority of what follows is preparation -in the form
# of early bail-out if something is not right yet- for the final
# check-in-release-branch rule that makes the tip of the release
# branch match the contents of a 'make distcheck' tarball.

# Validate and return $(RELEASE_TYPE), or die.
RELEASE_TYPES = alpha beta stable
release-type = $(call member-check,RELEASE_TYPE,$(RELEASE_TYPES))

# This will actually make the release, including sending release
# announcements, and pushing changes back to the origin.
# Use it like this, eg:
#				make RELEASE_TYPE=beta
.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

# Ensure that each sub-module commit we're using is public.
# Without this, it is too easy to tag and release code that
# cannot be built from a fresh clone.
.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
# This rule has a high enough utility/cost ratio that it should be a
# dependent of "check" by default.  However, some of us do occasionally
# commit a temporary change that deliberately points to a non-public
# submodule commit, and want to be able to use rules like "make check".
# In that case, run e.g., "make check gl_public_submodule_commit="
# to disable this test.
gl_public_submodule_commit ?= public-submodule-commit
check: $(gl_public_submodule_commit)

# These targets do all the file shuffling necessary for a release, but
# purely locally, so you can rewind and redo before pushing anything
# to origin or sending release announcements. Use it like this, eg:
#
#				make beta
.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

# Abort the release if there are unchecked in changes remaining.
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

# Select which lines of NEWS are searched for $(news-check-regexp).
# This is a sed line number spec.  The default says that we search
# only line 3 of NEWS for $(news-check-regexp), to match the behaviour
# of '$(_build-aux)/do-release-commit-and-tag'.
# If you want to search only lines 1-10, use "1,10".
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)'

# Strip out copyright messages with years, so that changing those (e.g.
# with 'make update-copyight') doesn't change the old_NEWS_hash.
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/ .*//')

# Update the hash stored above.  Do this after each release and
# for any corrections to old entries.

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
# Not $(AM_V_GEN) since the output of this command serves as
# announcement message: else, it would start with " GEN announcement".
	$(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

# Anything in $(_save-files) is not removed after switching to the
# release branch, and is thus "in the release". Add addtional partial
# filenames to save in save_release_files, for example:
#    save_release_files = RELEASE-NOTES-
_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)`

# Switch to (or create) 'release' branch, remove all files, except the
# newly generated dist tarball, then unpack the dist tarball and check
# in all the files it creates, and tag that as the next release.
# Github creates automatic zipballs of tagged git revisions, so we can
# safely use this tag in the rockspecs we distribute.
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) zxhf '$(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)