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
|
done
|
||||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
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/bootstrap.sh
|
||||||
|
|
||||||
$DIR/scripts/package.sh $1
|
$DIR/scripts/package.sh $1
|
||||||
|
|
|
@ -67,3 +67,6 @@ test_debian_package(){
|
||||||
}
|
}
|
||||||
|
|
||||||
execute
|
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 up the stage2 artifacts
|
||||||
tar -czf $PACKAGE_NAME *
|
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
|
#!/bin/bash
|
||||||
# This is a simple script to push the deb package to our private corpnet feed
|
|
||||||
#
|
#
|
||||||
# Usage: publish_package.sh [deb file]
|
# Usage: publish.sh [file to be uploaded]
|
||||||
# Requires: Azure Cli installed (for uploading to blob storage)
|
|
||||||
#
|
#
|
||||||
# Environment Dependencies:
|
# Environment Dependencies:
|
||||||
# $STORAGE_CONTAINER_NAME
|
# $STORAGE_CONTAINER
|
||||||
# $STORAGE_ACCOUNT
|
# $STORAGE_ACCOUNT
|
||||||
# $STORAGE_KEY
|
# $SASTOKEN
|
||||||
# $REPO_ID
|
# $REPO_ID
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
DEB_FILE=$1
|
UPLOAD_FILE=$1
|
||||||
UPLOAD_JSON_FILE="package_upload.json"
|
UPLOAD_JSON_FILE="package_upload.json"
|
||||||
|
|
||||||
execute(){
|
execute(){
|
||||||
|
@ -20,19 +18,26 @@ execute(){
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
upload_deb_to_blob_storage
|
if ! upload_file_to_blob_storage; then
|
||||||
generate_repoclient_json
|
exit 1
|
||||||
call_repo_client
|
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(){
|
validate_inputs(){
|
||||||
local ret=0
|
local ret=0
|
||||||
if [[ ! -f "$DEB_FILE" ]]; then
|
if [[ ! -f "$UPLOAD_FILE" ]]; then
|
||||||
echo "Error: .deb file does not exist"
|
echo "Error: \"$UPLOAD_FILE\" file does not exist"
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
if [[ -z "$STORAGE_CONTAINER" ]]; then
|
if [[ -z "$SASTOKEN" ]]; then
|
||||||
echo "Error: STORAGE_CONTAINER environment variable not set"
|
echo "Error: SASTOKEN environment variable not set"
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -41,19 +46,36 @@ validate_inputs(){
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$STORAGE_KEY" ]]; then
|
if [[ -z "$STORAGE_CONTAINER" ]]; then
|
||||||
echo "Error: STORAGE_KEY environment variable not set"
|
echo "Error: STORAGE_CONTAINER environment variable not set"
|
||||||
ret=1
|
ret=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
upload_deb_to_blob_storage(){
|
upload_file_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_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(){
|
generate_repoclient_json(){
|
||||||
|
@ -89,4 +111,4 @@ _get_package_version(){
|
||||||
echo $package_version
|
echo $package_version
|
||||||
}
|
}
|
||||||
|
|
||||||
execute
|
execute
|
||||||
|
|
Loading…
Reference in a new issue