Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShapeShifter499/7775c5c6c5d295f65a7944c32706ddb2 to your computer and use it in GitHub Desktop.
Save ShapeShifter499/7775c5c6c5d295f65a7944c32706ddb2 to your computer and use it in GitHub Desktop.
stage('Upload to GitHub'){
steps {
withCredentials([string(credentialsId: '<ID_CODE>', variable: 'GIT_TOKEN')]) {
sh '''#!/bin/bash
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 --verbose -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 "Uploading $ARTIFACT to GitHub"
$file_artifact
done
'''
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment