-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from Yoast/dist
Push to yoast-dist on travis task
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env bash | ||
|
||
###################### | ||
## Deployment script # | ||
###################### | ||
## arg 1: git tag ## | ||
## arg 2: repo-name ## | ||
###################### | ||
|
||
set -ex | ||
|
||
if [ -z "$1" ]; then | ||
echo 'The first argument should be the version you want to deploy to dist.' | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$2" ]; then | ||
echo 'The second argument should be the repo name.' | ||
exit 1 | ||
fi | ||
|
||
# Repo to deploy to: | ||
USER="Yoast-dist" | ||
REPO=$2 | ||
REPO_URL="[email protected]:$USER/$REPO.git" | ||
|
||
# Get the latest tag. | ||
lastTag=$1 | ||
branch="master" | ||
mainDir=$(pwd) | ||
|
||
if [[ $lastTag =~ ^feature/* || $lastTag =~ ^release/* || $lastTag =~ ^hotfix/* || $lastTag == "develop" || $lastTag == "trunk" ]]; then | ||
branch=$lastTag | ||
fi | ||
|
||
# Clone the dist repo. | ||
rm -rf ./dist-repo | ||
git clone ${REPO_URL} dist-repo | ||
cd dist-repo | ||
git checkout $branch 2>/dev/null || git checkout -b $branch | ||
cd .. | ||
|
||
# Copy the git folder with the entire history. | ||
cp -r ./dist-repo/.git ./artifact | ||
cp composer.json ./artifact | ||
|
||
# Remove the vendor directory from the artifact, composer will generate it's own autoload. | ||
rm -rf ./artifact/vendor | ||
|
||
# Navigate to the to be committed folder. | ||
cd ./artifact | ||
|
||
# Commit the files. | ||
git add -A | ||
|
||
# If it's a feature, release or trunk branch. | ||
if [[ $lastTag =~ ^feature/* || $lastTag =~ ^release/* || $lastTag =~ ^hotfix/* || $lastTag == "develop" || $lastTag == "trunk" ]]; then | ||
git commit --allow-empty -m "${TRAVIS_COMMIT_MESSAGE}" | ||
else | ||
git commit -m "Release ${lastTag}" | ||
# Tag the commit. | ||
git tag ${lastTag} | ||
fi | ||
|
||
# Push to remote. | ||
git push -u origin $branch --tags |