diff --git a/src/main/scripts/cd/before-deploy.sh b/src/main/scripts/cd/before-deploy.sh index 0232f83..74c5259 100755 --- a/src/main/scripts/cd/before-deploy.sh +++ b/src/main/scripts/cd/before-deploy.sh @@ -6,52 +6,52 @@ BEFORE_DEPLOY_EXEC_FILES=$(find $DIRNAME -name 'before-deploy-*.sh') echo Running $0 echo *-*-*-*-*-*-*-*-*-*-*-*-*-* -function decryptsecrets { - echo decrypting secrets - echo *-*-*-*-*-*-*-*-*-*-*-* - mkdir -p ~/tmp - openssl aes-256-cbc -K $encrypted_SOME_key -iv $encrypted_SOME_iv -in $TRAVIS_BUILD_DIR/src/main/scripts/cd/secrets.tar.enc -out ~/tmp/secrets.tar -d - md5sum ~/tmp/secrets.tar - tar -xvf ~/tmp/secrets.tar -C ~/.ssh - shred -z -u ~/tmp/secrets.tar +decryptsecrets() { + echo decrypting secrets + echo *-*-*-*-*-*-*-*-*-*-*-* + mkdir -p ~/tmp + openssl aes-256-cbc -K $encrypted_SOME_key -iv $encrypted_SOME_iv -in $TRAVIS_BUILD_DIR/src/main/scripts/cd/secrets.tar.enc -out ~/tmp/secrets.tar -d + md5sum ~/tmp/secrets.tar + tar -xvf ~/tmp/secrets.tar -C ~/.ssh + shred -z -u ~/tmp/secrets.tar } -function importpgp { - echo importing pgp secret - echo *-*-*-*-*-*-*-*-*-*-*-* - eval $(gpg-agent --daemon --batch) +importpgp() { + echo importing pgp secret + echo *-*-*-*-*-*-*-*-*-*-*-* + eval $(gpg-agent --daemon --batch) gpg --batch --passphrase $GPG_PASSPHRASE --import ~/.ssh/codesigning.asc shred -z -u ~/.ssh/codesigning.asc } -function setupssh { - echo importing ssh secret - echo *-*-*-*-*-*-*-*-*-*-*-* +setupssh() { + echo importing ssh secret + echo *-*-*-*-*-*-*-*-*-*-*-* chmod 400 ~/.ssh/id_rsa touch ~/.ssh/config echo "Host github.com" >> $HOME/.ssh/config echo " IdentityFile $HOME/.ssh/id_rsa" >> $HOME/.ssh/config echo " StrictHostKeyChecking no" >> $HOME/.ssh/config - - eval "$(ssh-agent -s)" - ssh-add ~/.ssh/id_rsa - ssh -T git@github.com | true + + eval "$(ssh-agent -s)" + ssh-add ~/.ssh/id_rsa + ssh -T git@github.com | true } - -function setupgit { - echo setting git up - echo *-*-*-*-*-*-*-*-*-*-*-* + +setupgit() { + echo setting git up + echo *-*-*-*-*-*-*-*-*-*-*-* git remote set-url origin git@github.com:$TRAVIS_REPO_SLUG.git - git config --global user.email "io.scalecube.ci@gmail.com" + git config --global user.email "io.scalecube.ci@gmail.com" git config --global user.name "io-scalecube-ci" - git checkout -B $TRAVIS_BRANCH | true + git checkout -B $TRAVIS_BRANCH | true } -function deployment { - if [ "$TRAVIS_PULL_REQUEST" == 'false' ] && [ "$TRAVIS_BRANCH" = 'master' ] || [ "$TRAVIS_BRANCH" = 'develop' ]; then - echo deployment - echo *-*-*-*-*-*-*-*-*-*-*-* +deployment() { + if [ "$TRAVIS_PULL_REQUEST" = 'false' -a "$TRAVIS_BRANCH" = 'master' -o "$TRAVIS_BRANCH" = 'develop' -o -n "$TRAVIS_TAG" ]; then + echo deployment + echo *-*-*-*-*-*-*-*-*-*-*-* decryptsecrets importpgp setupssh diff --git a/src/main/scripts/cd/release.sh b/src/main/scripts/cd/release.sh index f3711f2..cfb592a 100755 --- a/src/main/scripts/cd/release.sh +++ b/src/main/scripts/cd/release.sh @@ -6,13 +6,15 @@ RELEASE_EXEC_FILES=$(find $DIRNAME -name 'release-*.sh') echo Running $0 echo *-*-*-*-*-*-*-*-*-*-*-*-*-* +. $DIRNAME/before-deploy.sh + commit_to_develop() { - git fetch - git branch -r - git checkout -B develop - git rebase $TRAVIS_BRANCH - git commit --amend -m "++++ Prepare for next development iteration build: $TRAVIS_BUILD_NUMBER ++++" - git push origin develop + git fetch + git branch -r + git checkout -B develop + git rebase $TRAVIS_BRANCH + git commit --amend -m "++++ Prepare for next development iteration build: $TRAVIS_BUILD_NUMBER ++++" + git push origin develop } check_next_version() { @@ -31,6 +33,10 @@ check_tag_for_rc() { export NEW_RC_VERSION=$(echo $VERSION | sed "s/SNAPSHOT/$RC_VER/g") echo Release candidate: $NEW_RC_VERSION echo *-*-*-*-*-*-*-*-*-*-*-* + decryptsecrets + importpgp + setupssh + setupgit export MVN_RELEASE_VERSION=-DreleaseVersion=$NEW_RC_VERSION if [ -n "$MVN_NEXT_VERSION" ] ; then export MVN_NEXT_VERSION=-DdevelopmentVersion=$VERSION;