Created
January 3, 2018 03:36
-
-
Save elleryq/3a78530d8c92749ec7b06e3ee021cd32 to your computer and use it in GitHub Desktop.
Archive current branch as zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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