This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.ps1
59 lines (44 loc) · 1.55 KB
/
publish.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
param (
[Parameter(Mandatory=$true)]
[string]$ArtifactsDir,
[Parameter(Mandatory=$true)]
[string]$StagingDir,
[Parameter(Mandatory=$true)]
[string]$GitHubRef,
[Parameter(Mandatory=$true)]
[string]$AccountName,
[Parameter(Mandatory=$true)]
[string]$ContainerName
)
# Parse the desired version from the tag
$expectedPrefix = "refs/tags/c-v"
if (!$GitHubRef.StartsWith($expectedPrefix) || $GitHubRef.Length -le $expectedPrefix.Length) {
Write-Error "Unexpected GitHub ref '$GitHubRef' (expected prefix: '$expectedPrefix')"
exit 1
}
$version = $GitHubRef.Substring($expectedPrefix.Length)
Write-Output "Version: $version"
# Create the staging directory if it doesn't exist
if (!(Test-Path -PathType Container $StagingDir)) {
New-Item -ItemType Directory $StagingDir
}
# Pack each directory into a zip file
Get-ChildItem -Path $ArtifactsDir -Directory | ForEach-Object {
$target = ($_.Name).TrimStart("c-")
New-Item -ItemType Directory $StagingDir/$target
Compress-Archive -Path "$($_.FullName)/*" -DestinationPath "$StagingDir/$target/spotflow_device.zip"
}
# Upload the zip files to the storage account
az storage blob upload-batch `
--auth-mode login `
--account-name $AccountName `
--destination $ContainerName `
--destination-path "device-sdk/$version" `
--source $StagingDir
az storage blob upload-batch `
--auth-mode login `
--account-name $AccountName `
--destination $ContainerName `
--destination-path "device-sdk/latest" `
--source $StagingDir `
--overwrite