Skip to content

Commit

Permalink
chore: improve bash script for release
Browse files Browse the repository at this point in the history
  • Loading branch information
adityastic committed Oct 18, 2019
1 parent 3977c7f commit 9e0110d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -18,6 +18,7 @@ cache:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
before_script:
- bash scripts/prep-variables.sh
- bash scripts/prep-key.sh
script:
- ./gradlew spotlessCheck
Expand Down
5 changes: 1 addition & 4 deletions scripts/prep-key.sh
@@ -1,10 +1,7 @@
#!/bin/sh
set -e

export DEPLOY_BRANCH=${DEPLOY_BRANCH:-development}
export PUBLISH_BRANCH=${PUBLISH_BRANCH:-master}

if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/open-event-attendee-android" ] || ! [ "$TRAVIS_BRANCH" == "$DEPLOY_BRANCH" -o "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]; then
if ! ( $DEV_OR_MASTER_BUILD || $PR_FOR_RELEASE ); then
echo "We decrypt key only for pushes to the master branch and not PRs. So, skip."
exit 0
fi
Expand Down
11 changes: 11 additions & 0 deletions scripts/prep-variables.sh
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

[[ $TRAVIS_REPO_SLUG =~ ^(fossasia/open-event-attendee-android)$ ]] && IS_FOSS_SLUG=true || IS_FOSS_SLUG=false
[[ $TRAVIS_PULL_REQUEST_SLUG =~ ^(fossasia/open-event-attendee-android)$ ]] && IS_FOSS_PR=true || IS_FOSS_PR=false
[[ $TRAVIS_BRANCH =~ ^(development|master)$ && $IS_FOSS_SLUG ]] && BRANCH_DEPLOYORDEV=true || BRANCH_DEPLOYORDEV=false
[[ $TRAVIS_BRANCH =~ ^(master)$ && $IS_FOSS_SLUG ]] && IS_PUBLISH_BRANCH=true || IS_PUBLISH_BRANCH=false

[[ $TRAVIS_PULL_REQUEST =~ ^(false)$ && $BRANCH_DEPLOYORDEV ]] && export DEV_OR_MASTER_BUILD=${DEV_OR_MASTER_BUILD:-true} || export DEV_OR_MASTER_BUILD=${DEV_OR_MASTER_BUILD:-false}

[[ $IS_PUBLISH_BRANCH && $IS_FOSS_PR =~ ^(true)$ ]] && export PR_FOR_RELEASE=${PR_FOR_RELEASE:-true} || export PR_FOR_RELEASE=${PR_FOR_RELEASE:-false}
8 changes: 3 additions & 5 deletions scripts/update-apk.sh
Expand Up @@ -4,11 +4,6 @@ set -e
git config --global user.name "Travis CI"
git config --global user.email "noreply+travis@fossasia.org"

[[ $TRAVIS_BRANCH =~ ^(master)$ && $TRAVIS_REPO_SLUG =~ ^(fossasia/open-event-attendee-android)$ ]] && IS_PUBLISH_BRANCH=true || IS_PUBLISH_BRANCH=false
[[ $TRAVIS_BRANCH =~ ^(development)$ && $TRAVIS_REPO_SLUG =~ ^(fossasia/open-event-attendee-android)$ ]] && IS_DEV_BRANCH=true || IS_DEV_BRANCH=false
[[ $TRAVIS_PULL_REQUEST =~ ^(false)$ && $TRAVIS_REPO_SLUG =~ ^(fossasia/open-event-attendee-android)$ && $TRAVIS_BRANCH =~ ^(development|master)$ ]] && DEV_OR_MASTER_BUILD=true || DEV_OR_MASTER_BUILD=false
[[ $IS_PUBLISH_BRANCH && $TRAVIS_PULL_REQUEST_SLUG =~ ^(fossasia/open-event-attendee-android)$ ]] && PR_FOR_RELEASE=true || PR_FOR_RELEASE=false

if $PR_FOR_RELEASE; then
FASTLANE_DRY_RUN="--validate_only true"
fi
Expand Down Expand Up @@ -57,6 +52,9 @@ if $IS_PUBLISH_BRANCH ;then
cd ..
gem install fastlane
fastlane supply --aab ./apk/eventyay-attendee-master-app-playStore-release.aab --skip_upload_apk true --track alpha --json_key ./scripts/fastlane.json --package_name $PACKAGE_NAME $FASTLANE_DRY_RUN
if [ $? -ne 0 ]; then
exit 1
fi
if $PR_FOR_RELEASE ;then
exit 0
fi
Expand Down

0 comments on commit 9e0110d

Please sign in to comment.