Last active
March 2, 2021 20:09
-
-
Save SylarRuby/9027579ad5071896c5476d24e37ec1e0 to your computer and use it in GitHub Desktop.
Creates a tar file for your git repository then copies to a remote server.
This file contains hidden or 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 | |
# This file must be locatated inside your project | |
# and there must be at least one branch: master. | |
# Make this file executable with | |
# chmod +x artifact.sh | |
# Branch to archive. | |
# Defaults to master branch if no param passed ie: | |
# ./artifact.sh | |
# To specify a different branch (develop), use ./artifact.sh develop | |
BRANCH=${1:-master} | |
# Uses your last git tag ie 0.1.2 | |
# This ensures your file/folder name is unique. | |
TAG=$(git describe --tags --abbrev=0) | |
# Creates a unique folder: release-0.1.2.tar | |
# Assuming you have git tags. | |
# See: http://www.inanzzz.com/index.php/post/cs32/working-with-git-release-branches | |
BUILDNAME=release-${TAG} | |
# File is exported to the parent directory. To export in same | |
# directory or somewhere else, feel free to modify. | |
# Change ../$BUILDNAME.tar to $BUILDNAME.tar or | |
# /export/file/to/$BUILDNAME.tar | |
EXPORT_TO=../$BUILDNAME.tar | |
# To explore formats, use git archive --help | |
git archive --format tar -o $EXPORT_TO $BRANCH | |
# Remote server details | |
# REMOTE_HOST= | |
# REMOTE_USER= | |
# Copy file to remote server | |
# Ensure you have ssh access/permission between your computer and remote server. | |
# scp -v $EXPORT_TO REMOTE_USER@${REMOTE_HOST}:. | |
# Do something on the remote server | |
# ssh $REMOTE_USER@${REMOTE_HOST} ./<bash-script-to-execute>.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment