Publish tar/deb/pkg files to the dotnet azure blob during CI.
This commit is contained in:
parent
d2f7624e00
commit
9751f83c99
4 changed files with 52 additions and 21 deletions
4
build.sh
4
build.sh
|
@ -10,6 +10,10 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
|
|||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
# UTC Timestamp of the last commit is used as the build number. This is for easy synchronization of build number between Windows, OSX and Linux builds.
|
||||
LAST_COMMIT_TIMESTAMP=$(git log -1 --format=%ct)
|
||||
export DOTNET_BUILD_VERSION=0.0.1-alpha-$(date -ud @$LAST_COMMIT_TIMESTAMP "+%Y%m%d-%H%M%S")
|
||||
|
||||
$DIR/scripts/bootstrap.sh
|
||||
|
||||
$DIR/scripts/package.sh $1
|
||||
|
|
|
@ -67,3 +67,6 @@ test_debian_package(){
|
|||
}
|
||||
|
||||
execute
|
||||
|
||||
DEBIAN_FILE=$(find $PACKAGE_OUTPUT_DIR -iname "*.deb")
|
||||
$DIR/publish.sh $DEBIAN_FILE
|
||||
|
|
|
@ -63,4 +63,6 @@ find . -type f ! -name "*.*" | xargs chmod 755
|
|||
# Tar up the stage2 artifacts
|
||||
tar -czf $PACKAGE_NAME *
|
||||
|
||||
echo "Packaged stage2 to $PACKAGE_NAME"
|
||||
echo "Packaged stage2 to $PACKAGE_NAME"
|
||||
|
||||
$DIR/publish.sh $PACKAGE_NAME
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
#!/bin/bash
|
||||
# This is a simple script to push the deb package to our private corpnet feed
|
||||
#
|
||||
# Usage: publish_package.sh [deb file]
|
||||
# Requires: Azure Cli installed (for uploading to blob storage)
|
||||
# Usage: publish.sh [file to be uploaded]
|
||||
#
|
||||
# Environment Dependencies:
|
||||
# $STORAGE_CONTAINER_NAME
|
||||
# $STORAGE_CONTAINER
|
||||
# $STORAGE_ACCOUNT
|
||||
# $STORAGE_KEY
|
||||
# $SASTOKEN
|
||||
# $REPO_ID
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
DEB_FILE=$1
|
||||
UPLOAD_FILE=$1
|
||||
UPLOAD_JSON_FILE="package_upload.json"
|
||||
|
||||
execute(){
|
||||
|
@ -20,19 +18,26 @@ execute(){
|
|||
exit 1
|
||||
fi
|
||||
|
||||
upload_deb_to_blob_storage
|
||||
generate_repoclient_json
|
||||
call_repo_client
|
||||
if ! upload_file_to_blob_storage; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# debain packages need to be uploaded to the PPA feed too
|
||||
if [[ $UPLOAD_FILE == *.deb ]]; then
|
||||
DEB_FILE=$UPLOAD_FILE
|
||||
generate_repoclient_json
|
||||
call_repo_client
|
||||
fi
|
||||
}
|
||||
|
||||
validate_inputs(){
|
||||
local ret=0
|
||||
if [[ ! -f "$DEB_FILE" ]]; then
|
||||
echo "Error: .deb file does not exist"
|
||||
if [[ ! -f "$UPLOAD_FILE" ]]; then
|
||||
echo "Error: \"$UPLOAD_FILE\" file does not exist"
|
||||
ret=1
|
||||
fi
|
||||
if [[ -z "$STORAGE_CONTAINER" ]]; then
|
||||
echo "Error: STORAGE_CONTAINER environment variable not set"
|
||||
if [[ -z "$SASTOKEN" ]]; then
|
||||
echo "Error: SASTOKEN environment variable not set"
|
||||
ret=1
|
||||
fi
|
||||
|
||||
|
@ -41,19 +46,36 @@ validate_inputs(){
|
|||
ret=1
|
||||
fi
|
||||
|
||||
if [[ -z "$STORAGE_KEY" ]]; then
|
||||
echo "Error: STORAGE_KEY environment variable not set"
|
||||
if [[ -z "$STORAGE_CONTAINER" ]]; then
|
||||
echo "Error: STORAGE_CONTAINER environment variable not set"
|
||||
ret=1
|
||||
fi
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
upload_deb_to_blob_storage(){
|
||||
local deb_filename=$(basename $DEB_FILE)
|
||||
azure storage blob upload $DEB_FILE $STORAGE_CONTAINER $deb_filename -a $STORAGE_ACCOUNT -k $STORAGE_KEY
|
||||
upload_file_to_blob_storage(){
|
||||
|
||||
UPLOAD_URL="http://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$deb_filename"
|
||||
local filename=$(basename $UPLOAD_FILE)
|
||||
|
||||
if [[ $filename == *.deb || $filename == *.pkg ]]; then
|
||||
FOLDER="Installers"
|
||||
elif [[ $filename == *.tar.gz ]]; then
|
||||
FOLDER="Binaries"
|
||||
fi
|
||||
|
||||
UPLOAD_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$STORAGE_CONTAINER/$FOLDER/$DOTNET_BUILD_VERSION/$filename$SASTOKEN"
|
||||
|
||||
curl -L -H "x-ms-blob-type: BlockBlob" -H "x-ms-date: 2015-10-21" -H "x-ms-version: 2013-08-15" $UPLOAD_URL -T $UPLOAD_FILE
|
||||
result=$?
|
||||
|
||||
if [ "$result" -gt "0" ]; then
|
||||
echo "Error: Uploading the $filename to blob storage - $result"
|
||||
else
|
||||
echo "Successfully uploaded $filename to blob storage."
|
||||
fi
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
generate_repoclient_json(){
|
||||
|
@ -89,4 +111,4 @@ _get_package_version(){
|
|||
echo $package_version
|
||||
}
|
||||
|
||||
execute
|
||||
execute
|
||||
|
|
Loading…
Reference in a new issue