Create Release ZIP Files from Git Tags

GitHub provides a really nice way of creating release zip files for any of your GitHub projects. Here is a very simple shell script that can be used with any non-GitHub repository for creating release ZIP files out of Git tags:


# Specify the project directory that contains .git

# Specify release directory

# Store releases in release directory
mkdir -p $dest

# Set the git working dir inside our project
export GIT_DIR=$slug/.git

# Get the latest tag
tag=$(git describe --tags --abbrev=0)

# Create a zip file out of the latest tag release
git archive $tag --prefix="$slug/" --format=zip --output="./$dest/$slug-$"

echo "Created $dest/$slug-$"

Where slug is the directory of your repository that contains .git, and dest is the directory for storing release ZIP files.

Place this script one level below your project directory, name it do-release and make sure it’s executable (chmod +x do-release).

Please leave a comment if you know how to achieve this using Git hooks.

Use Contact Form 7 to collect business leads and enquiries? I created Storage for Contact Form 7 plugin which stores them safely in WordPress database.

Get it now for only $19 →

Leave a Reply