#!/bin/bash

# Release Automation
#   - Bump Version
#   - Create Tag
#   - Push to Master
#   - Push to Github

# Set git config
git config --global user.email $GIT_EMAIL
git config --global user.name $GIT_NAME
git config --global push.default simple

echo $GITHUB_SSH_KEY > ~/.ssh/id_rsa
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

# Clone Repo
git clone https://$GIT_USERNAME:$GIT_PASSWORD@$AMAZONIA_REPO amazonia-repo && echo "!! GIT CLONE"
cd amazonia-repo

## Merge to Master
git checkout integration && echo "!! GIT CHECKOUT INTEGRATION"
git checkout master && echo "!! GIT CHECKOUT MASTER"
git merge integration --no-edit && echo "!! GIT MERGE INTEGRATION"

## Bump Integration Version
git checkout integration && echo "!! GIT CHECKOUT INTEGRATION"
bumpversion $BUMPVERSION_TYPE --list --verbose --tag && echo "!! BUMPVERSION"

## Push Both Commits and Tags
git push origin --all && echo "!! GIT PUSH --ALL"
git push origin --tags && echo "!! GIT PUSH --TAGS"

git remote add github 
git push github

#!/bin/bash

# Release Automation
#   - Bump Version
#   - Create Tag
#   - Push to Master
#   - Push to Github

# Set git config
git config --global user.email $GIT_EMAIL
git config --global user.name $GIT_NAME
git config --global push.default simple

echo $GITHUB_SSH_KEY > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

# Clone Repo
git clone https://$GIT_USERNAME:$GIT_PASSWORD@$AMAZONIA_REPO amazonia-repo && echo "!! GIT CLONE"
cd amazonia-repo

## Merge to Master
git checkout integration && echo "!! GIT CHECKOUT INTEGRATION"
git checkout master && echo "!! GIT CHECKOUT MASTER"
git merge integration --no-edit && echo "!! GIT MERGE INTEGRATION"

## Bump Integration Version
git checkout integration && echo "!! GIT CHECKOUT INTEGRATION"
bumpversion $BUMPVERSION_TYPE --list --verbose --tag && echo "!! BUMPVERSION"

## Push Both Commits and Tags
git push origin --all && echo "!! GIT PUSH --ALL"
git push origin --tags && echo "!! GIT PUSH --TAGS"

git remote add github git@github.com:geoscienceaustralia/amazonia.git
git push github

Set ssh key permissions, add remote git url
Set ssh key permissions, add remote git url
