---
title: Create Release ZIP Files from Git Tags
date: 2014-01-15T12:17:22+00:00
modified: 2015-01-09T13:09:51+00:00
permalink: https://kaspars.net/blog/create-release-zip-git-tags
post_type: post
author:
  name: Kaspars
  avatar: https://reverse.kaspars.net/gravatar/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?s=96&d=mm&r=g
category:
  - Development
post_tag:
  - How to
  - Snippet
  - Tool
---

# Create Release ZIP Files from Git Tags

GitHub provides [a really nice way of creating release zip files](https://github.com/blog/1547-release-your-software) 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:

```
#!/bin/sh

# Specify the project directory that contains .git
slug="project-dir"

# Specify release directory
dest="releases"

# 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-$tag.zip"

echo "Created $dest/$slug-$tag.zip"
```

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.