Over a million developers have joined DZone.

How to Zip Up a Release From a hg Repository

· Java Zone

Learn more about the advantages of moving from a monolithic to microservices architecture.  Brought to you in partnership with IBM.

Did you know hg archive command can quickly zip up your project by given a revision or release name? This is very handy to package up a distribution and share with other who is refusing to use the same client.

I wrote a simple bash script to do this with couple extras. It will create a zip file with a nice basename so it’s easy for unzipping. It also auto generate and append the given revision or tag name into the RELEASE.txt file, so you know what’s been released.

Just add the following file into any root of your hg based project’s bin directory and it’s ready to use.

This script will not tag your repository. It assumed you already have tagged. It simply will package up a release into a nice little zip file.
#!/usr/bin/env bash
# Package a release or snapshot from Hg repository for distribution.
# :Author: Zemian Deng
# :Date: 2013/02/01
# Usage example:
#   # release a specific tag
#   cd /path/to/project
#   bin/zip-release.sh 1.0.1
#   # release a snapshot
#   bin/zip-release.sh

# Command line arguments and options
# Assume this script is in bin, which one directory up.
APP_HOME=`cd $(dirname $0)/.. && pwd`
if [[ `command -v realpath` != "" ]]; then
	# resolve symbolic link if possible.
    APP_HOME=`realpath $APP_HOME`
HG_REVISION=`hg id -i`
if [[ "$REL_VERSION" == "" ]]; then

# Generate the zip package
printf "Generating $REL_NAME in directory=`pwd`\n"
mkdir -p $REL_DIR

# Auto append revision id to release file.
if [[ -e $APP_HOME/RELEASE.txt ]]; then
printf "$REL_NAME revsion=$HG_REVISION date=`date`\n" >> $REL_DIR/RELEASE.txt

# Clean up the tmp rel dir.
rm -r $REL_DIR

printf "$REL_ZIPFILE created.\n"

From Idea to Application gives you the architecture to quickly build, manage and run a range of applications (web, mobile, big data, new smart devices, etc.) on an open-standard, cloud-based platform. See why developers are using IBM Bluemix. Brought to you in partnership with IBM.


Published at DZone with permission of Zemian Deng, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}