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 6333049
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
13 changes: 10 additions & 3 deletions scripts/prep-key.sh
@@ -1,10 +1,17 @@
#!/bin/sh
set -e

export DEPLOY_BRANCH=${DEPLOY_BRANCH:-development}
export PUBLISH_BRANCH=${PUBLISH_BRANCH:-master}
[[ $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

if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/open-event-attendee-android" ] || ! [ "$TRAVIS_BRANCH" == "$DEPLOY_BRANCH" -o "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]; then
[[ $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}

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
19 changes: 14 additions & 5 deletions scripts/update-apk.sh
Expand Up @@ -4,18 +4,24 @@ 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
[[ $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_BRANCH =~ ^(development)$ && $IS_FOSS_SLUG ]] && IS_DEV_BRANCH=true || IS_DEV_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}

if $PR_FOR_RELEASE; then
FASTLANE_DRY_RUN="--validate_only true"
fi

if ! ( $DEV_OR_MASTER_BUILD || $PR_FOR_RELEASE ); then
echo "We upload apk only for changes in development or master, and not PRs. So, let's skip this shall we ? :)"
exit 0
return 1
fi

./gradlew bundlePlayStoreRelease
Expand Down Expand Up @@ -57,6 +63,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 6333049

Please sign in to comment.