Integration of git release workflow with automake "make dist"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[I'm not subscribed to the list, so I'd appreciate a CC on reply, thanks!]

Hi folks,

After initially bringing up the idea behind this initial implementation
on the automake mailing list, I want to get some criticism and comments
from automake users who use git (or git experts in general in case my
use of the git plumbing is not correct!).

The initial discussion is here:
http://thread.gmane.org/gmane.comp.sysutils.automake.general/10936

And the current implementation is attached.


Automake has a "dist" target to generate a "release" in the form of a
compressed tarfile or zip file.  This file contains files not normally
kept under version control in the developer's repo (generated autotools
scripts, other generated files such as changelogs etc.) as well as
possibly excluding other bits in the repo not needed by end users.
However, this isn't kept under version control, and it would be
helpful it it was.

The above thread contains most of the rationale behind doing this, so
I won't repeat it all here.

The attached make fragment implements a "dist-git" target.  Instead
of releasing by creating a tarball, it injects the same tree onto a
specified git branch and (optionally) signs both the release and
distribution branches.  Branch and tag names and messages are
configurable.  Note this is just an initial proof of concept;
anything can be changed!

I'd like to make this as generally usable for as many people as
possible, so it would be great to hear how you are managing releases
with automake and git, and if this would be useful for you, and if
there's anything that could be added or changed to better accommodate
you.


Many thanks,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
ENABLE_DIST_GIT=false

GIT_RELEASE_BRANCH=HEAD
GIT_RELEASE_TAG=true
GIT_RELEASE_TAG_SIGN=true
GIT_RELEASE_TAG_NAME=release/$(PACKAGE)-$(VERSION)
GIT_RELEASE_TAG_MESSAGE="Release of $(PACKAGE)-$(VERSION)"

GIT_DIST_BRANCH=distribution
GIT_DIST_COMMIT_MESSAGE="Distribution of $(PACKAGE) version $(VERSION)"
GIT_DIST_TAG=true
GIT_DIST_TAG_SIGN=true
GIT_DIST_TAG_NAME=distribution/$(PACKAGE)-$(VERSION)
GIT_DIST_TAG_MESSAGE="Distribution of $(PACKAGE)-$(VERSION)"

dist-git: distdir
	if [ "$(ENABLE_DIST_GIT)" != "true" ]; then \
	    echo "$@: ENABLE_DIST_GIT not true; not distributing"; \
	  exit 0; \
	fi; \
	cd "$(abs_top_srcdir)"; \
	if [ ! -d .git ]; then \
	    echo "$@: Not a git repository" 1>&2; \
	    exit 1; \
	fi; \
	if [ "$(GIT_RELEASE_TAG)" = "true" ]; then \
          if git show-ref --tags -q $(GIT_RELEASE_TAG_NAME); then \
	    echo "git release tag $(GIT_RELEASE_TAG_NAME) already exists; not distributing" 1>&2; \
	    exit 1; \
	  fi; \
	fi; \
	if [ "$(GIT_DIST_TAG)" = "true" ]; then \
          if git show-ref --tags -q $(GIT_DIST_TAG_NAME); then \
	    echo "git distribution tag $(GIT_DIST_TAG_NAME) already exists; not distributing" 1>&2; \
	    exit 1; \
	  fi; \
	fi; \
	echo "$@: distributing $(PACKAGE)-$(VERSION) on git branch $(GIT_DIST_BRANCH)"; \
	DISTDIR_INDEX="$(abs_top_builddir)/$(distdir).git.idx"; \
	DISTDIR_TREE="$(abs_top_builddir)/$(distdir)"; \
	rm -f "$$DISTDIR_INDEX"; \
	GIT_INDEX_FILE="$$DISTDIR_INDEX" GIT_WORK_TREE="$$DISTDIR_TREE" git add -A || exit 1; \
	GIT_INDEX_FILE="$$DISTDIR_INDEX" TREE="$$(git write-tree)"; \
	rm -f "$$DISTDIR_INDEX"; \
	[ -n "$$TREE" ] || exit 1; \
	RELEASE_HEAD="$$(git show-ref -s $(GIT_RELEASE_BRANCH))"; \
	COMMIT_OPTS="-p $$RELEASE_HEAD"; \
	DIST_PARENT="$$(git show-ref --heads -s refs/heads/$(GIT_DIST_BRANCH))"; \
	if [ -n "$$DIST_PARENT" ]; then \
	  COMMIT_OPTS="$$COMMIT_OPTS -p $$DIST_PARENT"; \
	fi; \
	COMMIT="$$(echo $(GIT_DIST_COMMIT_MESSAGE) | git commit-tree "$$TREE" $$COMMIT_OPTS)"; \
	[ -n "$$COMMIT" ] || exit 1; \
	git update-ref "refs/heads/$(GIT_DIST_BRANCH)" "$$COMMIT" "$$DIST_PARENT" || exit 1;\
	echo "$@: tree=$$TREE"; \
	echo "$@: commit=$$COMMIT"; \
	if [ "$(GIT_RELEASE_TAG)" = "true" ]; then \
	  RELEASE_TAG_OPTS=""; \
	  if [ "$(GIT_RELEASE_TAG_SIGN)" = "true" ]; then \
	    RELEASE_TAG_OPTS="$$TAG_OPTS -s"; \
	  fi; \
	  git tag -m $(GIT_RELEASE_TAG_MESSAGE) $$RELEASE_TAG_OPTS "$(GIT_RELEASE_TAG_NAME)" "$$COMMIT" || exit 1; \
	    echo "$@: release tagged as $(GIT_RELEASE_TAG_NAME)"; \
	fi; \
	if [ "$(GIT_DIST_TAG)" = "true" ]; then \
	  DIST_TAG_OPTS=""; \
	  if [ "$(GIT_DIST_TAG_SIGN)" = "true" ]; then \
	    DIST_TAG_OPTS="$$TAG_OPTS -s"; \
	  fi; \
	  git tag -m $(GIT_DIST_TAG_MESSAGE) $$DIST_TAG_OPTS "$(GIT_DIST_TAG_NAME)" "$$COMMIT" || exit 1; \
	    echo "$@: distribution tagged as $(GIT_DIST_TAG_NAME)"; \
	fi;
	$(am__remove_distdir)

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]