diff --git a/.buildkite/build.sh b/.buildkite/build.sh new file mode 100755 index 00000000..ef0f3c0d --- /dev/null +++ b/.buildkite/build.sh @@ -0,0 +1,33 @@ +#! /bin/bash +set -eo pipefail + +mkdir -p whl + +echo "--- Downloading whl file" + +# Allows for building directly from pipeline or trigger +if [[ $LE_TRIGGERED_FROM_BUILD_ID ]] +then + echo "Downloading from triggered build" + buildkite-agent artifact download 'dist/*.whl' . --build ${BUILDKITE_TRIGGERED_FROM_BUILD_ID} + mv dist/* whl/ + rm -r dist +else + echo "Downloading from pip" + pip download -d ./whl kolibri +fi + +echo "--- :android: Build APK" +make run_docker + +# Making folder structure match other installers (convention) +mv ./dist/android/*.apk ./dist + +if [[ $LE_TRIGGERED_FROM_JOB_ID && $BUILDKITE_TRIGGERED_FROM_BUILD_ID ]] +then + echo "--- Uploading artifact to parent job" + buildkite-agent artifact upload dist/*-release.apk --job $LE_TRIGGERED_FROM_JOB_ID +fi + +echo "--- Uploading artifact" +buildkite-agent artifact upload dist/*-release.apk \ No newline at end of file diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml new file mode 100644 index 00000000..b0a63bff --- /dev/null +++ b/.buildkite/pipeline.yaml @@ -0,0 +1,7 @@ +steps: + # - block: "Build :android:?" + # TODO make this independantly triggerable + # Only block when build is triggered by another build + # - if: build.source == "trigger_job" + - label: "Build Android App" + command: ".buildkite/build.sh" diff --git a/scripts/rundocker.sh b/scripts/rundocker.sh index e8f59238..7bc698bb 100755 --- a/scripts/rundocker.sh +++ b/scripts/rundocker.sh @@ -1,11 +1,9 @@ #!/bin/bash CONTAINER_HOME=/home/kivy -CONTAINER_NAME=android_container # create the container to be used throughout the script -echo -ne "Creating container ${CONTAINER_NAME} \n\t id: " -docker create -it --name ${CONTAINER_NAME} \ +CONTAINER_ID=$(docker create -it --name ${CONTAINER_ID} \ --mount type=bind,src=${PWD}/whl,dst=${CONTAINER_HOME}/whl \ --mount type=bind,src=${PWD}/src,dst=${CONTAINER_HOME}/src \ --mount type=bind,src=${PWD}/scripts,dst=${CONTAINER_HOME}/scripts \ @@ -16,26 +14,28 @@ docker create -it --name ${CONTAINER_NAME} \ --env P4A_RELEASE_KEYALIAS \ --env P4A_RELEASE_KEYSTORE_PASSWD \ --env P4A_RELEASE_KEYALIAS_PASSWD \ - android_kolibri + android_kolibri) + +echo -ne "Creating container ${CONTAINER_ID} \n\t id: " # make sure the environment variable is defined if [ "${P4A_RELEASE_KEYSTORE}" ]; then # make sure the directory is valid if [ -a ${P4A_RELEASE_KEYSTORE} ]; then - echo -e "Copying the signing key \n\t From ${P4A_RELEASE_KEYSTORE} to ${CONTAINER_NAME}:${CONTAINER_HOME}" + echo -e "Copying the signing key \n\t From ${P4A_RELEASE_KEYSTORE} to ${CONTAINER_ID}:${CONTAINER_HOME}" # copy keystore to same location on the container - docker cp ${P4A_RELEASE_KEYSTORE} ${CONTAINER_NAME}:${CONTAINER_HOME} + docker cp ${P4A_RELEASE_KEYSTORE} ${CONTAINER_ID}:${CONTAINER_HOME} fi fi # run the container, generating the apk -echo "Starting ${CONTAINER_NAME}" -docker start -i ${CONTAINER_NAME} +echo "Starting ${CONTAINER_ID}" +docker start -i ${CONTAINER_ID} # copy the apk to our host. Handles permissions. -echo -e "Coping APK \n\t From ${CONTAINER_NAME}:${CONTAINER_HOME}/dist/ to ${PWD}" -docker cp ${CONTAINER_NAME}:${CONTAINER_HOME}/dist/ . +echo -e "Coping APK \n\t From ${CONTAINER_ID}:${CONTAINER_HOME}/dist/ to ${PWD}" +docker cp ${CONTAINER_ID}:${CONTAINER_HOME}/dist/ . # manually remove the container afterward echo -n "Removing " -docker rm ${CONTAINER_NAME} +docker rm ${CONTAINER_ID}