Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ShapeShifter499/9617d5d39dbc06f446bde195049f89ed to your computer and use it in GitHub Desktop.
Save ShapeShifter499/9617d5d39dbc06f446bde195049f89ed to your computer and use it in GitHub Desktop.
#!/bin/bash
DEVICE="h932"
DEVICE_BLOBS="oreo-blobs"
DEVICE_MANIFEST="https://raw.githubusercontent.com/ShapeShifter499/LG_v30-LineageOS_Manifest/lineage-16.0/lg_v30-${DEVICE}.xml"
SOURCE_TREE="/media/shapeshifter499/compile-disk/jenkins/workspace/LineageOS/lineageos_code_sync"
export CCACHE_DIR=/media/shapeshifter499/compile-disk/.ccache
BRANCHNAME="lineage-16.0"
BUILDNAME="lineage-16.0"
BUILD_TYPE="userdebug"
REPO_BIN="/media/shapeshifter499/compile-disk/bin/repo"
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64/"
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
ANDROID_JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64/"
export ANDROID_JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
TMPDIR="$WORKSPACE/$DEVICE-tmp-dir"
GIT_user_name="ShapeShifter499"
GIT_user_email="[email protected]"
mkdir -p $WORKSPACE/$DEVICE-build
cd $WORKSPACE/$DEVICE-build
printenv
if [ -d .repo ]; then
echo "Inital sync already done";
echo "Making sure code is up to date before continuing";
wget $DEVICE_MANIFEST -O .repo/local_manifests/$DEVICE.xml;
$REPO_BIN forall -c "git reset --hard";
$REPO_BIN forall -c "git clean -f -d";
$REPO_BIN sync -d -c --force-sync;
else
echo "Making inital synchronization of LineageOS code";
$REPO_BIN init -u http://www.github.com/LineageOS/android -b $BRANCHNAME --reference=$SOURCE_TREE;
mkdir -p .repo/local_manifests;
wget $DEVICE_MANIFEST -O .repo/local_manifests/$DEVICE.xml;
$REPO_BIN sync;
fi;
git config --global user.name $GIT_user_name
git config --global user.email $GIT_user_email
PATH="$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH"
export $PATH
rm -rf $WORKSPACE/$DEVICE-output
rm -rf $TMPDIR
mkdir -p $TMPDIR
cd $WORKSPACE/$DEVICE-build
source build/envsetup.sh
make clean
mka clobber
export USE_CCACHE=1
ccache -M 1024G
export DATETIME=$(date -u +%Y%m%d_%H%M%S)
export LC_ALL=C
lunch lineage_$DEVICE-$BUILD_TYPE
mka bacon installed-file-list
mkdir -p $WORKSPACE/$DEVICE-output
cd $WORKSPACE
cp $DEVICE-build/out/target/product/$DEVICE/$BUILDNAME-* $DEVICE-output
cp $DEVICE-build/out/target/product/$DEVICE/installed-files.txt $DEVICE-output
cp $DEVICE-build/.repo/local_manifests/$DEVICE.xml $DEVICE-output/$DEVICE-manifest.xml
cd $DEVICE-output
GIT_release_repo_name="LG_v30-LineageOS_Manifest"
GIT_TAG="$(basename -s .zip.md5sum $BUILDNAME*.zip.md5sum | cut -d- -f 1-3,5)"
# Create a release
release=$(curl -XPOST -H "Authorization:token $GIT_TOKEN" --data "{\"tag_name\": \"${GIT_TAG}_${DEVICE_BLOBS}\", \"target_commitish\": \"$BRANCHNAME\", \"name\": \"${GIT_TAG}_${DEVICE_BLOBS}\", \"draft\": false, \"prerelease\": false}" https://api.github.com/repos/$GIT_user_name/$GIT_release_repo_name/releases)
# Extract the id of the release from the creation response
id=$(echo "$release" | sed -n -e 's/"id":\ \([0-9]\+\),/\1/p' | head -n 1 | sed 's/[[:blank:]]//g')
# Upload the artifact
for ARTIFACT in `find . -maxdepth 1 -type f -print | sed 's/^\.\///'`
do
file_artifact=$(curl --verbose -XPOST -H "Authorization:token $GIT_TOKEN" -H "Content-Type:application/octet-stream" --data-binary @$ARTIFACT https://uploads.github.com/repos/$GIT_user_name/$GIT_release_repo_name/releases/$id/assets?name=$ARTIFACT)
echo ''
echo "Uploading $ARTIFACT to GitHub"
echo ''
$file_artifact
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment