{"thread":{"id":"20605","subject":"Integration of git release workflow with automake \"make dist\"","startedAt":"2009-08-15T14:21:18Z","lastAt":"2009-08-15T14:21:18Z","messageCount":1,"participants":["Roger Leigh"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"120714","messageId":"20090815142117.GE22565@codelibre.net","threadId":"20605","inReplyTo":null,"subject":"Integration of git release workflow with automake \"make dist\"","fromName":"Roger Leigh","fromEmail":"rleigh@codelibre.net","sentAt":"2009-08-15T14:21:18Z","receivedAt":"2009-08-15T14:21:18Z","isPatch":false,"sender":{"key":"rleigh@codelibre.net","avatar":null},"body":"[I'm not subscribed to the list, so I'd appreciate a CC on reply, thanks!]\n\nHi folks,\n\nAfter initially bringing up the idea behind this initial implementation\non the automake mailing list, I want to get some criticism and comments\nfrom automake users who use git (or git experts in general in case my\nuse of the git plumbing is not correct!).\n\nThe initial discussion is here:\nhttp://thread.gmane.org/gmane.comp.sysutils.automake.general/10936\n\nAnd the current implementation is attached.\n\n\nAutomake has a \"dist\" target to generate a \"release\" in the form of a\ncompressed tarfile or zip file.  This file contains files not normally\nkept under version control in the developer's repo (generated autotools\nscripts, other generated files such as changelogs etc.) as well as\npossibly excluding other bits in the repo not needed by end users.\nHowever, this isn't kept under version control, and it would be\nhelpful it it was.\n\nThe above thread contains most of the rationale behind doing this, so\nI won't repeat it all here.\n\nThe attached make fragment implements a \"dist-git\" target.  Instead\nof releasing by creating a tarball, it injects the same tree onto a\nspecified git branch and (optionally) signs both the release and\ndistribution branches.  Branch and tag names and messages are\nconfigurable.  Note this is just an initial proof of concept;\nanything can be changed!\n\nI'd like to make this as generally usable for as many people as\npossible, so it would be great to hear how you are managing releases\nwith automake and git, and if this would be useful for you, and if\nthere's anything that could be added or changed to better accommodate\nyou.\n\n\nMany thanks,\nRoger\n\n-- \n  .''`.  Roger Leigh\n : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/\n `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/\n   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.\n\n\nENABLE_DIST_GIT=false\n\nGIT_RELEASE_BRANCH=HEAD\nGIT_RELEASE_TAG=true\nGIT_RELEASE_TAG_SIGN=true\nGIT_RELEASE_TAG_NAME=release/$(PACKAGE)-$(VERSION)\nGIT_RELEASE_TAG_MESSAGE=\"Release of $(PACKAGE)-$(VERSION)\"\n\nGIT_DIST_BRANCH=distribution\nGIT_DIST_COMMIT_MESSAGE=\"Distribution of $(PACKAGE) version $(VERSION)\"\nGIT_DIST_TAG=true\nGIT_DIST_TAG_SIGN=true\nGIT_DIST_TAG_NAME=distribution/$(PACKAGE)-$(VERSION)\nGIT_DIST_TAG_MESSAGE=\"Distribution of $(PACKAGE)-$(VERSION)\"\n\ndist-git: distdir\n\tif [ \"$(ENABLE_DIST_GIT)\" != \"true\" ]; then \\\n\t    echo \"$@: ENABLE_DIST_GIT not true; not distributing\"; \\\n\t  exit 0; \\\n\tfi; \\\n\tcd \"$(abs_top_srcdir)\"; \\\n\tif [ ! -d .git ]; then \\\n\t    echo \"$@: Not a git repository\" 1>&2; \\\n\t    exit 1; \\\n\tfi; \\\n\tif [ \"$(GIT_RELEASE_TAG)\" = \"true\" ]; then \\\n          if git show-ref --tags -q $(GIT_RELEASE_TAG_NAME); then \\\n\t    echo \"git release tag $(GIT_RELEASE_TAG_NAME) already exists; not distributing\" 1>&2; \\\n\t    exit 1; \\\n\t  fi; \\\n\tfi; \\\n\tif [ \"$(GIT_DIST_TAG)\" = \"true\" ]; then \\\n          if git show-ref --tags -q $(GIT_DIST_TAG_NAME); then \\\n\t    echo \"git distribution tag $(GIT_DIST_TAG_NAME) already exists; not distributing\" 1>&2; \\\n\t    exit 1; \\\n\t  fi; \\\n\tfi; \\\n\techo \"$@: distributing $(PACKAGE)-$(VERSION) on git branch $(GIT_DIST_BRANCH)\"; \\\n\tDISTDIR_INDEX=\"$(abs_top_builddir)/$(distdir).git.idx\"; \\\n\tDISTDIR_TREE=\"$(abs_top_builddir)/$(distdir)\"; \\\n\trm -f \"$$DISTDIR_INDEX\"; \\\n\tGIT_INDEX_FILE=\"$$DISTDIR_INDEX\" GIT_WORK_TREE=\"$$DISTDIR_TREE\" git add -A || exit 1; \\\n\tGIT_INDEX_FILE=\"$$DISTDIR_INDEX\" TREE=\"$$(git write-tree)\"; \\\n\trm -f \"$$DISTDIR_INDEX\"; \\\n\t[ -n \"$$TREE\" ] || exit 1; \\\n\tRELEASE_HEAD=\"$$(git show-ref -s $(GIT_RELEASE_BRANCH))\"; \\\n\tCOMMIT_OPTS=\"-p $$RELEASE_HEAD\"; \\\n\tDIST_PARENT=\"$$(git show-ref --heads -s refs/heads/$(GIT_DIST_BRANCH))\"; \\\n\tif [ -n \"$$DIST_PARENT\" ]; then \\\n\t  COMMIT_OPTS=\"$$COMMIT_OPTS -p $$DIST_PARENT\"; \\\n\tfi; \\\n\tCOMMIT=\"$$(echo $(GIT_DIST_COMMIT_MESSAGE) | git commit-tree \"$$TREE\" $$COMMIT_OPTS)\"; \\\n\t[ -n \"$$COMMIT\" ] || exit 1; \\\n\tgit update-ref \"refs/heads/$(GIT_DIST_BRANCH)\" \"$$COMMIT\" \"$$DIST_PARENT\" || exit 1;\\\n\techo \"$@: tree=$$TREE\"; \\\n\techo \"$@: commit=$$COMMIT\"; \\\n\tif [ \"$(GIT_RELEASE_TAG)\" = \"true\" ]; then \\\n\t  RELEASE_TAG_OPTS=\"\"; \\\n\t  if [ \"$(GIT_RELEASE_TAG_SIGN)\" = \"true\" ]; then \\\n\t    RELEASE_TAG_OPTS=\"$$TAG_OPTS -s\"; \\\n\t  fi; \\\n\t  git tag -m $(GIT_RELEASE_TAG_MESSAGE) $$RELEASE_TAG_OPTS \"$(GIT_RELEASE_TAG_NAME)\" \"$$COMMIT\" || exit 1; \\\n\t    echo \"$@: release tagged as $(GIT_RELEASE_TAG_NAME)\"; \\\n\tfi; \\\n\tif [ \"$(GIT_DIST_TAG)\" = \"true\" ]; then \\\n\t  DIST_TAG_OPTS=\"\"; \\\n\t  if [ \"$(GIT_DIST_TAG_SIGN)\" = \"true\" ]; then \\\n\t    DIST_TAG_OPTS=\"$$TAG_OPTS -s\"; \\\n\t  fi; \\\n\t  git tag -m $(GIT_DIST_TAG_MESSAGE) $$DIST_TAG_OPTS \"$(GIT_DIST_TAG_NAME)\" \"$$COMMIT\" || exit 1; \\\n\t    echo \"$@: distribution tagged as $(GIT_DIST_TAG_NAME)\"; \\\n\tfi;\n\t$(am__remove_distdir)\n"}]}