Skip to content

Instantly share code, notes, and snippets.

@elleryq
Created January 3, 2018 03:36
Show Gist options
  • Save elleryq/3a78530d8c92749ec7b06e3ee021cd32 to your computer and use it in GitHub Desktop.
Save elleryq/3a78530d8c92749ec7b06e3ee021cd32 to your computer and use it in GitHub Desktop.
Archive current branch as zip
#!/bin/bash
TOPDIR=$(git rev-parse --show-toplevel)
DESTDIR="/your_artifacts_folder"
ARTIFACT_FILE="${DESTDIR}/your_project.zip"
MODIFIED_FILES=$(git ls-files -m ${TOPDIR})
if [ ! -z "${MODIFIED_FILES}" ]; then
echo "Please commit first!"
exit -1
fi
CURRENT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2-)
echo "Current branch=${CURRENT_BRANCH}"
cd "${TOPDIR}" && git archive --format=zip ${CURRENT_BRANCH} > "${ARTIFACT_FILE}"
echo "Archived to ${ARTIFACT_FILE}"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment