File tree Expand file tree Collapse file tree 2 files changed +57
-3
lines changed
Scripts/DownloadCargoBinaryFromGitHub Expand file tree Collapse file tree 2 files changed +57
-3
lines changed Original file line number Diff line number Diff line change 1+ # # @file
2+ # Azure Pipeline to download Cargo Binstall and save it as a pipeline artifact that
3+ # can be accessed by other pipelines.
4+ #
5+ # Copyright (c) Microsoft Corporation. All rights reserved.
6+ # SPDX-License-Identifier: BSD-2-Clause-Patent
7+ # #
8+
9+ schedules :
10+ # At 1:00 on Monday
11+ # https://crontab.guru/#0_1_*_*_1
12+ - cron : 0 1 * * 1
13+ branches :
14+ include :
15+ - main
16+ always : true
17+
18+ jobs :
19+ - job : Update_Cargo_Binstall
20+ displayName : Update Cargo Binstall
21+
22+ pool :
23+ vmImage : windows-latest
24+
25+ steps :
26+ - checkout : self
27+ clean : true
28+ fetchDepth : 1
29+ fetchTags : false
30+
31+ - script : pip install requests --upgrade
32+ displayName : Install and Upgrade pip Modules
33+ condition : succeeded()
34+
35+ - task : PythonScript@0
36+ displayName : Download and Stage Cargo Binstall
37+ env :
38+ BINARIES_DIR : " $(Build.BinariesDirectory)"
39+ BINARY_NAME : " cargo-binstall"
40+ DOWNLOAD_DIR : " $(Build.ArtifactStagingDirectory)"
41+ REPO_URL : " https://api.github.com/repos/cargo-bins/cargo-binstall/releases"
42+ inputs :
43+ scriptSource : filePath
44+ scriptPath : Scripts/DownloadCargoBinaryFromGitHub/DownloadCargoBinaryFromGitHub.py
45+ workingDirectory : $(Agent.BuildDirectory)
46+ condition : succeeded()
47+
48+ - task : PublishBuildArtifacts@1
49+ displayName : Publish Cargo Binstall
50+ retryCountOnTaskFailure : 3
51+ inputs :
52+ PathtoPublish : $(Build.BinariesDirectory)
53+ ArtifactName : Binaries
54+ condition : succeeded()
Original file line number Diff line number Diff line change 4444# Download assets
4545for asset in releases [0 ]['assets' ]:
4646 name = asset ['name' ].lower ()
47- if ("x86_64-pc-windows-msvc" in name or "x86_64-unknown-linux-gnu" in name
48- and asset ['name' ].endswith (('.zip' , '.tar.gz' ))):
47+ if (( "x86_64-pc-windows-msvc" in name or "x86_64-unknown-linux-gnu" in name )
48+ and asset ['name' ].endswith (('.zip' , '.tar.gz' , '.tgz' ))):
4949 filepath = DOWNLOAD_DIR / asset ['name' ]
5050 print (f"Downloading { asset ['name' ]} ..." )
5151 with requests .get (asset ['browser_download_url' ], stream = True ) as r :
6161 if filename .name .endswith ('.zip' ):
6262 with zipfile .ZipFile (filename , 'r' ) as zip_ref :
6363 zip_ref .extractall (extracted_dir )
64- elif filename .name .endswith ('.tar.gz' ):
64+ elif filename .name .endswith (( '.tar.gz' , '.tgz' ) ):
6565 with tarfile .open (filename , 'r:gz' ) as tar :
6666 tar .extractall (path = extracted_dir )
6767
You can’t perform that action at this time.
0 commit comments