File: automation_sdk_update_version.ps1

package info (click to toggle)
python-azure 20251202%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 786,344 kB
  • sloc: python: 6,510,493; ansic: 804; javascript: 287; sh: 204; makefile: 198; xml: 109
file content (96 lines) | stat: -rw-r--r-- 2,506 bytes parent folder | download
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#Requires -Version 5
<#
.SYNOPSIS
    Update version for a given package.
.DESCRIPTION
    This script is a wrapper of python script `packaging_tools.sdk_update_version`.
    It calls `python -m packaging_tools.sdk_update_version` to update version.
.PARAMETER PackagePath
    Path to the package.
.PARAMETER ReleaseType
    Release type. Must be either "stable" or "beta".
.PARAMETER Version
    Version string to set.
.PARAMETER ReleaseDate
    Release date in YYYY-MM-DD format.
.PARAMETER SdkRepoPath
    Absolute path string where SDK code is. Optional.
#>
param(
    [Parameter(Mandatory=$true, HelpMessage="Path to the package")]
    [string]
    $PackagePath,

    [Parameter(Mandatory=$false, HelpMessage="Release type (stable or beta)")]
    [ValidateSet("stable", "beta")]
    [string]
    $ReleaseType,

    [Parameter(Mandatory=$false, HelpMessage="Version string")]
    [string]
    $Version,

    [Parameter(Mandatory=$false, HelpMessage="Release date in YYYY-MM-DD format")]
    [ValidatePattern('^\d{4}-\d{2}-\d{2}$')]
    [string]
    $ReleaseDate,

    [Parameter(Mandatory=$false, HelpMessage="Absolute path string where SDK code is")]
    [string]
    $SdkRepoPath
)

$scriptPath = $MyInvocation.MyCommand.Path
$scriptParent = Split-Path $scriptPath -Parent
$repoRoot = (Get-Location).Path

# Change to SDK repo path if provided
if ($SdkRepoPath) {
    if (-not (Test-Path $SdkRepoPath)) {
        Write-Error "SdkRepoPath: $SdkRepoPath does not exist"
        exit 1
    }
    Write-Host "Changing directory to: $SdkRepoPath"
    Set-Location -Path $SdkRepoPath
}

if (-not (Test-Path $PackagePath)) {
    Write-Error "PackagePath: $PackagePath does not exist"
    exit 1
}

$absolutePackagePath = Resolve-Path -Path $PackagePath
Write-Host "absolutePackagePath: $absolutePackagePath"

# Build the command with required parameter
$command = "python -m packaging_tools.sdk_update_version --package-path $absolutePackagePath"

# Add optional parameters if provided
if ($ReleaseType) {
    $command += " --release-type $ReleaseType"
}

if ($Version) {
    $command += " --version $Version"
}

if ($ReleaseDate) {
    $command += " --release-date $ReleaseDate"
}

Write-Host "running command: $command"

# Capture output first
$output = Invoke-Expression $command 2>&1

# Display the output
$output | ForEach-Object { Write-Host $_ }

# Convert to string and check for [ERROR]
$outputString = $output | Out-String

if ($outputString -match "\[ERROR\]") {
    exit 1
} else {
    exit 0
}