Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign app for release in tools/install-app-bundle.sh #9883

Merged
merged 1 commit into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions libs/mocks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ allprojects {

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing the scripts to fail and it deletes the build/ directory where the outputs are placed.

27 changes: 8 additions & 19 deletions tools/build-app-bundle-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,15 @@ trap cleanup ERR

# This script defines some shared functions that are used by the build-app-bundle* set.

function get_gradle_property {
PROP_KEY=$1
PROP_VALUE=`cat "gradle.properties" | grep "$PROP_KEY" | cut -d'=' -f2`
echo $PROP_VALUE
}

function gradle_version_name {
grep -E 'versionName' $BUILDFILE | sed s/versionName// | grep -Eo "[a-zA-Z0-9.-]+"
}

function gradle_version_code {
grep -E 'versionCode' $BUILDFILE | sed s/versionCode// | grep -Eo "[a-zA-Z0-9.-]+"
}
# Load the Gradle helper functions
source "./tools/gradle-functions.sh"

function build_app_bundle {
branch=$1
flavor=$2
git checkout $branch >> $LOGFILE 2>&1
version_code=`gradle_version_code`
version_name=`gradle_version_name`
version_code=`gradle_version_code "$BUILDFILE"`
version_name=`gradle_version_name "$BUILDFILE"`
name="wpandroid-$version_name.aab"
apk_name="wpandroid-$version_name-universal.apk"
aab="WordPress.aab"
Expand All @@ -58,10 +47,10 @@ function extract_universal_apk {
bundletool build-apks --bundle="$app_bundle" \
--output="$tmp_dir/universal.apks" \
--mode=universal \
--ks="$(get_gradle_property storeFile)" \
--ks-pass="pass:$(get_gradle_property storePassword)" \
--ks-key-alias="$(get_gradle_property keyAlias)" \
--key-pass="pass:$(get_gradle_property keyPassword)" >> $LOGFILE 2>&1
--ks="$(get_gradle_property gradle.properties storeFile)" \
--ks-pass="pass:$(get_gradle_property gradle.properties storePassword)" \
--ks-key-alias="$(get_gradle_property gradle.properties keyAlias)" \
--key-pass="pass:$(get_gradle_property gradle.properties keyPassword)" >> $LOGFILE 2>&1

unzip "$tmp_dir/universal.apks" -d "$tmp_dir" >> $LOGFILE 2>&1
cp "$tmp_dir/universal.apk" "$apk_output" | tee -a $LOGFILE
Expand Down
20 changes: 20 additions & 0 deletions tools/gradle-functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

# This script defines some shared functions that are used by the app bundles scipts.

function get_gradle_property {
GRADLE_PROPERTIES=$1
PROP_KEY=$2
PROP_VALUE=`cat "$GRADLE_PROPERTIES" | grep "$PROP_KEY" | cut -d'=' -f2`
echo $PROP_VALUE
}

function gradle_version_name {
BUILDFILE=$1
grep -E 'versionName' $BUILDFILE | sed s/versionName// | grep -Eo "[a-zA-Z0-9.-]+"
}

function gradle_version_code {
BUILDFILE=$1
grep -E 'versionCode' $BUILDFILE | sed s/versionCode// | grep -Eo "[a-zA-Z0-9.-]+"
}
9 changes: 8 additions & 1 deletion tools/install-app-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ command -v bundletool > /dev/null || { echo "bundletool is required to build the
# Exit if any command fails
set -eu

# Load the Gradle helper functions
source "./tools/gradle-functions.sh"

APP_BUNDLE="$1"
TMP_DIR=$(mktemp -d)

echo "Generating APKs..."
bundletool build-apks --bundle="$APP_BUNDLE" \
--output="$TMP_DIR/output.apks"
--output="$TMP_DIR/output.apks" \
--ks="$(get_gradle_property gradle.properties storeFile)" \
--ks-pass="pass:$(get_gradle_property gradle.properties storePassword)" \
--ks-key-alias="$(get_gradle_property gradle.properties keyAlias)" \
--key-pass="pass:$(get_gradle_property gradle.properties keyPassword)"
echo "Installing..."
bundletool install-apks --apks="$TMP_DIR/output.apks"