From 95f059697f66de68824b4979304b9cda5a1272e0 Mon Sep 17 00:00:00 2001 From: Zlatko Knezevic Date: Wed, 27 Jan 2016 22:00:58 -0800 Subject: [PATCH 1/5] Add version badges generation to build Add version badge generation using shields.io service. The badge is uploaded to a fixed Azure BLOB location which can be referenced from README.md. Since the badge creation is not crucial, do not fail the build if it cannot be created. Fix #1000 --- scripts/package/package.ps1 | 9 +++++++++ scripts/package/package.sh | 14 ++++++++++++++ scripts/publish/publish.ps1 | 5 +++++ scripts/publish/publish.sh | 3 +++ 4 files changed, 31 insertions(+) diff --git a/scripts/package/package.ps1 b/scripts/package/package.ps1 index a95b2bd45..f219f31a7 100644 --- a/scripts/package/package.ps1 +++ b/scripts/package/package.ps1 @@ -14,3 +14,12 @@ _ "$RepoRoot\packaging\windows\generatemsi.ps1" @("$Stage2Dir") header "Generating NuGet packages" _ "$RepoRoot\packaging\nuget\package.ps1" @("$Stage2Dir\bin", "$env:VersionSuffix") + +header "Downloading version badge" +$VersionBadge = "$RepoRoot\artifacts\version_badge.svg" +$r = Invoke-WebRequest -Uri "https://img.shields.io/badge/version-$env:DOTNET_CLI_VERSION-blue.svg" -OutFile $VersionBadge + +if ($r.StatusCode == 200) +{ + & "$RepoRoot\publish\publish.ps1" "$RepoRoot\artifacts\version_badge.svg" -file $VersionBadge +} diff --git a/scripts/package/package.sh b/scripts/package/package.sh index bda181895..0cf8e9a86 100755 --- a/scripts/package/package.sh +++ b/scripts/package/package.sh @@ -15,13 +15,27 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" source "$DIR/../common/_common.sh" source "$REPOROOT/scripts/build/generate-version.sh" + if [ -z "$DOTNET_CLI_VERSION" ]; then TIMESTAMP=$(date "+%Y%m%d%H%M%S") DOTNET_CLI_VERSION=0.0.1-dev-t$TIMESTAMP fi +$VERSION_BADGE="$REPOROOT/artifacts/version_badge.svg" + header "Generating tarball" $DIR/package-dnvm.sh header "Generating Native Installer" $DIR/package-native.sh + +header "Downloading version badge" +status_code=$(curl -w "%{http_code}" -s -o $VERSION_BADGE "https://img.shields.io/badge/version-$DOTNET_CLI_VERSION-blue.svg") + +if [ "$status_code" -eq "200"]; then + header "Publishing version badge" + $REPOROOT/scripts/publish/publish.sh $VERSION_BADGE +else + info "Downloading the badge failed - $status_code" +fi + diff --git a/scripts/publish/publish.ps1 b/scripts/publish/publish.ps1 index 6848356cd..eb93298ca 100644 --- a/scripts/publish/publish.ps1 +++ b/scripts/publish/publish.ps1 @@ -156,5 +156,10 @@ elseif([System.IO.Path]::GetExtension($file).ToLower() -eq ".msi") { $result = UploadInstallers $file } +elseif ([System.IO.Path]::GetExtension($file).ToLower() -eq ".svg") +{ + UploadFile "dev/Binaries/Latest/$([System.IO.Path]::GetFileName($file))" $file + $result = $true +} exit $result diff --git a/scripts/publish/publish.sh b/scripts/publish/publish.sh index 712904945..8ee87505b 100755 --- a/scripts/publish/publish.sh +++ b/scripts/publish/publish.sh @@ -46,6 +46,9 @@ execute(){ elif [[ $UPLOAD_FILE == *.tar.gz ]]; then upload_binaries_to_blob_storage $UPLOAD_FILE result=$? + elif [[ $UPLOAD_FILE == *.svg ]]; then + upload_file_to_blob_storage_azure_cli "dev/Binaries/Latest/$(basename $UPLOAD_FILE)" $UPLOAD_FILE + result=0 fi exit $result From 4f2a8aeaf9ceb525a9cf45e54ea21537c3df6d1d Mon Sep 17 00:00:00 2001 From: Zlatko Knezevic Date: Wed, 27 Jan 2016 22:35:38 -0800 Subject: [PATCH 2/5] Responding to PR feedback --- scripts/package/package.sh | 1 - scripts/publish/publish.ps1 | 13 ++++++++++++- scripts/publish/publish.sh | 13 ++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/scripts/package/package.sh b/scripts/package/package.sh index 0cf8e9a86..9e33eb593 100755 --- a/scripts/package/package.sh +++ b/scripts/package/package.sh @@ -15,7 +15,6 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" source "$DIR/../common/_common.sh" source "$REPOROOT/scripts/build/generate-version.sh" - if [ -z "$DOTNET_CLI_VERSION" ]; then TIMESTAMP=$(date "+%Y%m%d%H%M%S") DOTNET_CLI_VERSION=0.0.1-dev-t$TIMESTAMP diff --git a/scripts/publish/publish.ps1 b/scripts/publish/publish.ps1 index eb93298ca..a363b53c3 100644 --- a/scripts/publish/publish.ps1 +++ b/scripts/publish/publish.ps1 @@ -135,6 +135,17 @@ function UploadInstallers($msiFile) return 0 } +function UploadVersionBadge($badgeFile) +{ + $fileName = [System.IO.Path]::GetFileName($badgeFile) + + Write-Host "Uploading the version badge to Latest" + UploadFile "dev/Binaries/Latest/$filename" $badgeFile + + Write-Host "Uploading the version badge to $env:DOTNET_CLI_VERSION" + UploadFile "dev/Binaries/$env:DOTNET_CLI_VERSION/$filename" $badgeFile +} + if(!(CheckRequiredVariables)) { # fail silently if the required variables are not available for publishing the file @@ -158,7 +169,7 @@ elseif([System.IO.Path]::GetExtension($file).ToLower() -eq ".msi") } elseif ([System.IO.Path]::GetExtension($file).ToLower() -eq ".svg") { - UploadFile "dev/Binaries/Latest/$([System.IO.Path]::GetFileName($file))" $file + UploadVersionBadge $file $result = $true } diff --git a/scripts/publish/publish.sh b/scripts/publish/publish.sh index 8ee87505b..100bf9d42 100755 --- a/scripts/publish/publish.sh +++ b/scripts/publish/publish.sh @@ -47,7 +47,7 @@ execute(){ upload_binaries_to_blob_storage $UPLOAD_FILE result=$? elif [[ $UPLOAD_FILE == *.svg ]]; then - upload_file_to_blob_storage_azure_cli "dev/Binaries/Latest/$(basename $UPLOAD_FILE)" $UPLOAD_FILE + upload_version_badge $UPLOAD_FILE result=0 fi @@ -190,6 +190,17 @@ upload_installers_to_blob_storage(){ return 0 } +upload_version_badge(){ + local badgefile=$1 + local filename=$(basename $badgefile) + echo "Uploading the version badge to Latest" + upload_file_to_blob_storage_azure_cli "dev/Binaries/Latest/$filename" $badgefile + + echo "Uploading the version badge to $DOTNET_CLI_VERSION" + upload_file_to_blob_storage_azure_cli "dev/Binaries/$DOTNET_CLI_VERSION/$filename" $badgefile +} + + generate_repoclient_json(){ # Clean any existing json file rm -f $SCRIPT_DIR/$UPLOAD_JSON_FILE From ae780684811ce050dad8200c5f60ea2226db779b Mon Sep 17 00:00:00 2001 From: Zlatko Knezevic Date: Wed, 27 Jan 2016 23:14:13 -0800 Subject: [PATCH 3/5] Changing the implementation from using shields.io to using a local SVG file and doing replace. One less network hop. --- resources/images/.version_badge.svg.swp | Bin 0 -> 12288 bytes resources/images/version_badge.svg | 20 ++++++++++++++++++++ scripts/package/.package.ps1.swp | Bin 0 -> 12288 bytes scripts/package/package.ps1 | 11 ++++------- scripts/package/package.sh | 14 +++++--------- 5 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 resources/images/.version_badge.svg.swp create mode 100644 resources/images/version_badge.svg create mode 100644 scripts/package/.package.ps1.swp diff --git a/resources/images/.version_badge.svg.swp b/resources/images/.version_badge.svg.swp new file mode 100644 index 0000000000000000000000000000000000000000..b1b9e8fb68cada7415240c4de3a98a7aa0723113 GIT binary patch literal 12288 zcmeI2J#W)M7{{+HEEEv1u^bnWs8q)nr=h5_J0L`1sDwa7Y}MI5+eiEooi8uV0N;QC zi4k^o#!4_TA@PL};&JL!Nt9My7>XW8e_ihGdHwl3M6u7i&-UqdbBn-rosgrWFWp~1 z$XfQAkVz^`uju7+B8Mud3|3$JB6w63J?ptHRvXl-Zx;jFu`KLSWW|Xc zq{`N^ECxD|rL8g%!!VS(R7HN^i!heWau}bP2RD%b5?CTIFp>3eowS`6uXY;j4!wEf z)shiTkpL1v0!RP}AOR$R1dsp{_@4=w{u+4)4PL67yj72DOJhC70SO=hB!C2v01`j~ zNB{{S0VIF~kN^_6fCNNH2)jbadrwC*q(sWkOigSV>B@zg5%B2Wgx zHQVP3=PV?zUPwMQ^UU;|nU`a^@vPt|iWsfhvqT;wh4xsc!Z4N4LXjIQ5}8V&gU9lX z=nm*hk(ZlYsY8*A%{`gRq1Y^8%_^l<5NPUCs)+=IEw&1DUznuMJ<#d>hQGmR=&^lH zdD7y}(BV({gi(8r_MA(D^KBUbrpl$`fKP{4E*<9#pH2rT&2n^>Qvixgls%74%MlwV zRadKXRcIL)I#QuYpf~O?nn)EV#$yg=RKw9}pB#cI)4Bt<3PTm77blTZl}n-bv p^LtRR3(pH3XK7w~EHS3PW80(As5xpk3mw}I=e&BN*lA#P$zR%yGvWXM literal 0 HcmV?d00001 diff --git a/resources/images/version_badge.svg b/resources/images/version_badge.svg new file mode 100644 index 000000000..ae455b8c8 --- /dev/null +++ b/resources/images/version_badge.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + version + version + ver_number + ver_number + + diff --git a/scripts/package/.package.ps1.swp b/scripts/package/.package.ps1.swp new file mode 100644 index 0000000000000000000000000000000000000000..9fdec182d60eb1bbbc11d1ca804bca182eebcdfa GIT binary patch literal 12288 zcmeI2O=}ZD7{{k7o~(+3=W$as1+!_Zpa_DtO-rCjOST4ug|IKPn=!jH>+Ec*#h0Vs zL=n7u^b7cQ@mqM+qxkG*Q)1cb+42nhdC1JO|7Yg6lS9bkF7?|Tdegi?V4NqU^Wkm( z>qjydKOkg3a`Z@!1lwn0?&S&9qvLq1QjQusN>(S7voHQMY=&G9Gq>qRjyLl692GRe zVbhCvGxZctblOZ{!3o(knn}9+*8;eR1du>AflLRDTl3`l%JNd4P%|#mix=)!=i)39 zKmter2_OL^fCP{L5@*1ZheuwxNG|p?{Kmter2_OL^fCP{L5yFYqa6FybW2RCr#lUs^keTT?G-xB>5u*$JeC6M+ zv)NLt<~D@XL#7*^6q*TLI+bgSreX=SC$qW%r3WI5U8am{usJ5ix7W9KyRF^9+E#ne zZ}qJ9cGp;>&uDs-8=35~^rm-a&!|``Gv%?=<}tK9R~?lMnd37>jZG$)ax@nqErHMi zh(X9;)^pN64QaN>;D~nFPCem!w{9$08cMCKb7i|+92~1aDTS2<0e@mFR+a5$n@rQv zFFm^M9v8mcOYLy7V-}~pqIz`=UupqGI#&Czf7u>BJMEyn0pd#%;ATC}*mTog%(l8>0Dse&&B4Wyz$7Ddy?C>Jml!)uqqgd%G)d8&9g s)U@s`QWGvB-H=eQNT81JX?~*>cQY+jYSMdPRph4>?iy2L=7SCS4RpYI Date: Thu, 28 Jan 2016 07:03:41 -0800 Subject: [PATCH 4/5] Responding to PR feedback. Modified the .gitignore also to exclude vim swap files. --- .gitignore | 5 +++++ scripts/package/.package.ps1.swp | Bin 12288 -> 0 bytes scripts/package/package.ps1 | 5 +++-- scripts/package/package.sh | 5 +++-- scripts/publish/publish.ps1 | 5 +++-- scripts/publish/publish.sh | 4 +++- 6 files changed, 17 insertions(+), 7 deletions(-) delete mode 100644 scripts/package/.package.ps1.swp diff --git a/.gitignore b/.gitignore index 8deb70e27..b620a468b 100644 --- a/.gitignore +++ b/.gitignore @@ -269,3 +269,8 @@ _Pvt_Extensions # Exceptions # Build Scripts !scripts/build/ +test/PackagedCommands/Consumers/*/project.json + +# Vim swp files +*.swp +*.*~ diff --git a/scripts/package/.package.ps1.swp b/scripts/package/.package.ps1.swp deleted file mode 100644 index 9fdec182d60eb1bbbc11d1ca804bca182eebcdfa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2O=}ZD7{{k7o~(+3=W$as1+!_Zpa_DtO-rCjOST4ug|IKPn=!jH>+Ec*#h0Vs zL=n7u^b7cQ@mqM+qxkG*Q)1cb+42nhdC1JO|7Yg6lS9bkF7?|Tdegi?V4NqU^Wkm( z>qjydKOkg3a`Z@!1lwn0?&S&9qvLq1QjQusN>(S7voHQMY=&G9Gq>qRjyLl692GRe zVbhCvGxZctblOZ{!3o(knn}9+*8;eR1du>AflLRDTl3`l%JNd4P%|#mix=)!=i)39 zKmter2_OL^fCP{L5@*1ZheuwxNG|p?{Kmter2_OL^fCP{L5yFYqa6FybW2RCr#lUs^keTT?G-xB>5u*$JeC6M+ zv)NLt<~D@XL#7*^6q*TLI+bgSreX=SC$qW%r3WI5U8am{usJ5ix7W9KyRF^9+E#ne zZ}qJ9cGp;>&uDs-8=35~^rm-a&!|``Gv%?=<}tK9R~?lMnd37>jZG$)ax@nqErHMi zh(X9;)^pN64QaN>;D~nFPCem!w{9$08cMCKb7i|+92~1aDTS2<0e@mFR+a5$n@rQv zFFm^M9v8mcOYLy7V-}~pqIz`=UupqGI#&Czf7u>BJMEyn0pd#%;ATC}*mTog%(l8>0Dse&&B4Wyz$7Ddy?C>Jml!)uqqgd%G)d8&9g s)U@s`QWGvB-H=eQNT81JX?~*>cQY+jYSMdPRph4>?iy2L=7SCS4RpYI $BADGE_DESTINATION header "Publishing version badge" -$REPOROOT/scripts/publish/publish.sh $VERSION_BADGE +$REPOROOT/scripts/publish/publish.sh $BADGE_DESTINATION diff --git a/scripts/publish/publish.ps1 b/scripts/publish/publish.ps1 index a363b53c3..49b95ca14 100644 --- a/scripts/publish/publish.ps1 +++ b/scripts/publish/publish.ps1 @@ -144,6 +144,8 @@ function UploadVersionBadge($badgeFile) Write-Host "Uploading the version badge to $env:DOTNET_CLI_VERSION" UploadFile "dev/Binaries/$env:DOTNET_CLI_VERSION/$filename" $badgeFile + + return 0 } if(!(CheckRequiredVariables)) @@ -169,8 +171,7 @@ elseif([System.IO.Path]::GetExtension($file).ToLower() -eq ".msi") } elseif ([System.IO.Path]::GetExtension($file).ToLower() -eq ".svg") { - UploadVersionBadge $file - $result = $true + $result = UploadVersionBadge $file } exit $result diff --git a/scripts/publish/publish.sh b/scripts/publish/publish.sh index 100bf9d42..71d0e8c00 100755 --- a/scripts/publish/publish.sh +++ b/scripts/publish/publish.sh @@ -48,7 +48,7 @@ execute(){ result=$? elif [[ $UPLOAD_FILE == *.svg ]]; then upload_version_badge $UPLOAD_FILE - result=0 + result=$? fi exit $result @@ -198,6 +198,8 @@ upload_version_badge(){ echo "Uploading the version badge to $DOTNET_CLI_VERSION" upload_file_to_blob_storage_azure_cli "dev/Binaries/$DOTNET_CLI_VERSION/$filename" $badgefile + + return 0 } From c124b2d79a8861c9dc76b2e09c37a29a28afc7c0 Mon Sep 17 00:00:00 2001 From: Zlatko Knezevic Date: Fri, 29 Jan 2016 09:06:12 -0800 Subject: [PATCH 5/5] Responding to PR feedback, adding the OS names --- resources/images/.version_badge.svg.swp | Bin 12288 -> 0 bytes scripts/package/package.ps1 | 2 +- scripts/publish/publish.ps1 | 2 +- scripts/publish/publish.sh | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 resources/images/.version_badge.svg.swp diff --git a/resources/images/.version_badge.svg.swp b/resources/images/.version_badge.svg.swp deleted file mode 100644 index b1b9e8fb68cada7415240c4de3a98a7aa0723113..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2J#W)M7{{+HEEEv1u^bnWs8q)nr=h5_J0L`1sDwa7Y}MI5+eiEooi8uV0N;QC zi4k^o#!4_TA@PL};&JL!Nt9My7>XW8e_ihGdHwl3M6u7i&-UqdbBn-rosgrWFWp~1 z$XfQAkVz^`uju7+B8Mud3|3$JB6w63J?ptHRvXl-Zx;jFu`KLSWW|Xc zq{`N^ECxD|rL8g%!!VS(R7HN^i!heWau}bP2RD%b5?CTIFp>3eowS`6uXY;j4!wEf z)shiTkpL1v0!RP}AOR$R1dsp{_@4=w{u+4)4PL67yj72DOJhC70SO=hB!C2v01`j~ zNB{{S0VIF~kN^_6fCNNH2)jbadrwC*q(sWkOigSV>B@zg5%B2Wgx zHQVP3=PV?zUPwMQ^UU;|nU`a^@vPt|iWsfhvqT;wh4xsc!Z4N4LXjIQ5}8V&gU9lX z=nm*hk(ZlYsY8*A%{`gRq1Y^8%_^l<5NPUCs)+=IEw&1DUznuMJ<#d>hQGmR=&^lH zdD7y}(BV({gi(8r_MA(D^KBUbrpl$`fKP{4E*<9#pH2rT&2n^>Qvixgls%74%MlwV zRadKXRcIL)I#QuYpf~O?nn)EV#$yg=RKw9}pB#cI)4Bt<3PTm77blTZl}n-bv p^LtRR3(pH3XK7w~EHS3PW80(As5xpk3mw}I=e&BN*lA#P$zR%yGvWXM diff --git a/scripts/package/package.ps1 b/scripts/package/package.ps1 index 242a76c0d..577a17380 100644 --- a/scripts/package/package.ps1 +++ b/scripts/package/package.ps1 @@ -20,4 +20,4 @@ $VersionBadge = "$RepoRoot\resources\images\version_badge.svg" $BadgeDestination = "$RepoRoot\artifacts\version_badge.svg" (get-content $VersionBadge).replace("ver_number", "$env:DOTNET_CLI_VERSION") | set-content $BadgeDestination -& "$RepoRoot\publish\publish.ps1" -file $BadgeDestination +& "$RepoRoot\scripts\publish\publish.ps1" -file $BadgeDestination diff --git a/scripts/publish/publish.ps1 b/scripts/publish/publish.ps1 index 49b95ca14..93aaea9c6 100644 --- a/scripts/publish/publish.ps1 +++ b/scripts/publish/publish.ps1 @@ -137,7 +137,7 @@ function UploadInstallers($msiFile) function UploadVersionBadge($badgeFile) { - $fileName = [System.IO.Path]::GetFileName($badgeFile) + $fileName = "windows_$Configuration_$([System.IO.Path]::GetFileName($badgeFile))" Write-Host "Uploading the version badge to Latest" UploadFile "dev/Binaries/Latest/$filename" $badgeFile diff --git a/scripts/publish/publish.sh b/scripts/publish/publish.sh index 71d0e8c00..caaae0036 100755 --- a/scripts/publish/publish.sh +++ b/scripts/publish/publish.sh @@ -192,7 +192,7 @@ upload_installers_to_blob_storage(){ upload_version_badge(){ local badgefile=$1 - local filename=$(basename $badgefile) + local filename="$OSNAME_$CONFIGURATION_$(basename $badgefile)" echo "Uploading the version badge to Latest" upload_file_to_blob_storage_azure_cli "dev/Binaries/Latest/$filename" $badgefile