Skip to content

Commit

Permalink
Merge pull request #43 from DXCanas/master
Browse files Browse the repository at this point in the history
Add independent buildkite pipeline
  • Loading branch information
DXCanas authored Dec 21, 2019
2 parents 1f3d57c + dd7b37d commit 4d3c6a0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
33 changes: 33 additions & 0 deletions .buildkite/build.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions .buildkite/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -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"
22 changes: 11 additions & 11 deletions scripts/rundocker.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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}

0 comments on commit 4d3c6a0

Please sign in to comment.