Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/azd/ci-build.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
param(
[string] $Version = (Get-Content "$PSScriptRoot/../version.txt"),
[string] $ExeVersion = (."$PSScriptRoot/../../eng/scripts/Get-MsiVersion.ps1" -CliVersion $Version),
[string] $SourceVersion = (git rev-parse HEAD),
[switch] $CodeCoverageEnabled,
[switch] $BuildRecordMode,
Expand Down Expand Up @@ -83,8 +84,7 @@ if ($IsWindows) {

$VERSION_INFO_PATH = "$PSScriptRoot/versioninfo.json"

$exeFileVersion = ."$PSScriptRoot/../../eng/scripts/Get-MsiVersion.ps1" -CliVersion $Version
$splitExeFileVersion = $exeFileVersion -split '\.'
$splitExeFileVersion = $ExeVersion -split '\.'
$versionInfo = Get-Content $VERSION_INFO_PATH | ConvertFrom-Json

$versionInfo.FixedFileInfo.FileVersion.Major = [int]$splitExeFileVersion[0]
Expand Down
2 changes: 1 addition & 1 deletion cli/installer/windows/azd.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Configuration Condition="'$(Configuration)'==''">Release</Configuration>
<Platform Condition="'$(Platform)' == ''">x64</Platform>
<ProductName Condition="'$(ProductName)' == ''">Azure Developer CLI (dev)</ProductName>
<ReleaseBuild Condition="'$(ProductVersion)' != ''">true</ReleaseBuild>
<ReleaseBuild Condition="'$(ReleaseBuild)' == 'true'">true</ReleaseBuild>
<ProductVersion Condition="'$(ProductVersion)' == ''">0.1.0</ProductVersion>
<!-- Windows Installer ProductVersion uses only major.minor.patch -->
<ProductVersion Condition="$(ProductVersion.IndexOf('-')) &gt; 0">$(ProductVersion.Substring(0, $(ProductVersion.IndexOf('-'))))</ProductVersion>
Expand Down
47 changes: 32 additions & 15 deletions cli/installer/windows/azd.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,34 @@
<?define BaseProductName = "Azure Developer CLI"?>
<?define ProductFolder = "Azure Dev CLI"?>

<!-- Define a unique UpgradeCode per platform -->
<!-- Define a unique UpgradeCode per platform and channel (release vs. dev) -->
<?if $(var.Platform) = "x64"?>
<?define UpgradeCode = "37533D38-361D-4CDB-939C-B05A9A17B2DA"?>
<?define ProgramFilesFolder = "ProgramFiles64Folder"?>
<?if $(var.ReleaseBuild) = "true"?>
<?define UpgradeCode = "37533D38-361D-4CDB-939C-B05A9A17B2DA"?>
<?define OtherUpgradeCode = "125C0BAB-607D-492F-AB91-271FF0DB2E47"?>
<?else?>
<?define UpgradeCode = "125C0BAB-607D-492F-AB91-271FF0DB2E47"?>
<?define OtherUpgradeCode = "37533D38-361D-4CDB-939C-B05A9A17B2DA"?>
<?endif?>
<?define ProgramFilesFolder = "ProgramFiles64Folder"?>
<?elseif $(var.Platform) = "x86"?>
<?define UpgradeCode = "FFE2BCD7-17E0-4C2D-A263-1FDE565F9A3F"?>
<?define ProgramFilesFolder = "ProgramFilesFolder"?>
<?if $(var.ReleaseBuild) = "true"?>
<?define UpgradeCode = "FFE2BCD7-17E0-4C2D-A263-1FDE565F9A3F"?>
<?define OtherUpgradeCode = "83470D49-59CF-4264-94A2-6E9ED7EC4E8C"?>
<?else?>
<?define UpgradeCode = "83470D49-59CF-4264-94A2-6E9ED7EC4E8C"?>
<?define OtherUpgradeCode = "FFE2BCD7-17E0-4C2D-A263-1FDE565F9A3F"?>
<?endif?>
<?define ProgramFilesFolder = "ProgramFilesFolder"?>
<?elseif $(var.Platform) = "arm64"?>
<?define UpgradeCode = "E5F7ECD9-D391-4278-80FA-820F81A5BCDD"?>
<?define ProgramFilesFolder = "ProgramFiles64Folder"?>
<?if $(var.ReleaseBuild) = "true"?>
<?define UpgradeCode = "E5F7ECD9-D391-4278-80FA-820F81A5BCDD"?>
<?define OtherUpgradeCode = "EDB4B882-3C2C-4DDC-BADB-5237BF6502EF"?>
<?else?>
<?define UpgradeCode = "EDB4B882-3C2C-4DDC-BADB-5237BF6502EF"?>
<?define OtherUpgradeCode = "E5F7ECD9-D391-4278-80FA-820F81A5BCDD"?>
<?endif?>
<?define ProgramFilesFolder = "ProgramFiles64Folder"?>
<?endif?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
Expand All @@ -36,14 +54,13 @@
<!-- Make sure any unversioned files including azd.exe (currently) are overwritten on install -->
<Property Id="REINSTALLMODE" Value="amus"/>

<!-- Remove older product(s) late but within the transaction to support removing ~\.azd\bin -->
<?if $(var.ReleaseBuild) = "true"?>
<!-- Release builds should still be linear to prevent installing older version. -->
<MajorUpgrade Schedule="afterInstallExecute" DowngradeErrorMessage="A newer version of $(var.BaseProductName) is already installed."/>
<?else?>
<!-- Dev builds should install over any other version installed for easy testing. -->
<MajorUpgrade Schedule="afterInstallExecute" AllowDowngrades="yes"/>
<?endif?>
<!-- Prevent downgrades -->
<MajorUpgrade DowngradeErrorMessage="A newer version of $(var.BaseProductName) is already installed."/>

<!-- Also detect and remove the other channel (release vs. dev) installation at any version -->
<Upgrade Id="$(var.OtherUpgradeCode)">
<UpgradeVersion Minimum="0.0.0" IncludeMinimum="yes" Property="OLDOTHERCHANNELFOUND"/>
</Upgrade>

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.ProgramFilesFolder)" Name="Program Files">
Expand Down
21 changes: 12 additions & 9 deletions eng/pipelines/templates/jobs/build-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ jobs:
filePath: eng/scripts/Set-CliVersionVariable.ps1
displayName: Set CLI_VERSION

- ${{ if eq(parameters.OS, 'windows') }}:
- template: /eng/pipelines/templates/steps/set-msi-version.yml
- ${{ else }}:
- pwsh: Write-Host "###vso[task.setvariable variable=MSI_VERSION]"
displayName: Set MSI_VERSION for non-windows build

- task: PowerShell@2
inputs:
pwsh: true
Expand All @@ -63,20 +69,16 @@ jobs:
targetType: filePath
filePath: cli/azd/ci-build.ps1
arguments: >-
-Version $(CLI_VERSION)
-SourceVersion $(Build.SourceVersion)
-Version "$(CLI_VERSION)"
-ExeVersion "$(MSI_VERSION)"
-SourceVersion "$(Build.SourceVersion)"
-CodeCoverageEnabled
-BuildRecordMode
-GitHubCopilotClientId "${{ parameters.ghCopilotClientId }}"
-GitHubCopilotIntegrationId "${{ parameters.ghCopilotIntegrationId }}"
workingDirectory: cli/azd
displayName: Build Go Binary (For tests)

- pwsh: |
eng/scripts/Get-MsiVersion.ps1 -DevOpsOutput
displayName: Set MSI_VERSION
condition: and(succeeded(), eq(variables['BuildTestMsi'], 'true'))
- template: /eng/pipelines/templates/steps/build-msi.yml
parameters:
Title: Build Test MSI
Expand Down Expand Up @@ -177,8 +179,9 @@ jobs:
targetType: filePath
filePath: cli/azd/ci-build.ps1
arguments: >-
-Version $(CLI_VERSION)
-SourceVersion $(Build.SourceVersion)
-Version "$(CLI_VERSION)"
-ExeVersion "$(MSI_VERSION)"
-SourceVersion "$(Build.SourceVersion)"
-GitHubCopilotClientId "${{ parameters.ghCopilotClientId }}"
-GitHubCopilotIntegrationId "${{ parameters.ghCopilotIntegrationId }}"
workingDirectory: cli/azd
Expand Down
11 changes: 9 additions & 2 deletions eng/pipelines/templates/jobs/cross-build-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,21 @@ jobs:
filePath: eng/scripts/Set-CliVersionVariable.ps1
displayName: Set CLI_VERSION

- ${{ if eq(parameters.OS, 'windows') }}:
- template: /eng/pipelines/templates/steps/set-msi-version.yml
- ${{ else }}:
- pwsh: Write-Host "###vso[task.setvariable variable=MSI_VERSION]"
displayName: Set MSI_VERSION for non-windows build

- task: PowerShell@2
inputs:
pwsh: true
targetType: filePath
filePath: cli/azd/ci-build.ps1
arguments: >-
-Version $(CLI_VERSION)
-SourceVersion $(Build.SourceVersion)
-Version "$(CLI_VERSION)"
-ExeVersion "$(MSI_VERSION)"
-SourceVersion "$(Build.SourceVersion)"
-GitHubCopilotClientId "${{ parameters.ghCopilotClientId }}"
-GitHubCopilotIntegrationId "${{ parameters.ghCopilotIntegrationId }}"
workingDirectory: cli/azd
Expand Down
4 changes: 3 additions & 1 deletion eng/pipelines/templates/stages/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ stages:
displayName: Show changelog content

# Create release metadata
- template: /eng/pipelines/templates/steps/set-msi-version.yml

- pwsh: |
New-Item -ItemType Directory -Path release-metadata -Force
# CLI Version may have been set by set-cli-version-cd.yml
Expand All @@ -247,7 +249,7 @@ stages:
$releaseMetadata = @{
cliVersion = $cliVersion;
msiVersion = (eng/scripts/Get-MsiVersion.ps1 -CliVersion $cliVersion);
msiVersion = "$(MSI_VERSION)";
isPublishingGa = $submitPackage;
submitChocoPackage = $submitPackage;
submitWingetPackage = $submitPackage;
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/templates/stages/sign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ stages:
parameters:
Title: Build Release MSI
# Only build for release in a manual (releasing) build. Otherwise
# the package version will be 0.1.0 with upgrade logic that allows
# it to be installed over any previously installed version.
# the package version will be based on the pipeline's build ID and
# the MSI will allow downgrades which is desirable for CI builds.
ShouldBuildForRelease: ${{ eq(variables['Build.Reason'], 'Manual') }}

- ${{ if and(in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual'), eq(variables['Build.Repository.Name'], 'Azure/azure-dev')) }}:
Expand Down
16 changes: 7 additions & 9 deletions eng/pipelines/templates/steps/build-msi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@ steps:
- ${{ if eq(parameters.ShouldBuildForRelease, 'true') }}:
- pwsh: |
Write-Host "##vso[task.setvariable variable=MSI_PRODUCT_NAME_PARAM]/p:ProductName=`"Azure Developer CLI`""
Write-Host "##vso[task.setvariable variable=MSI_VERSION_PARAM]/p:ProductVersion=$(MSI_VERSION)"
Write-Host "##vso[task.setvariable variable=RELEASE_BUILD_PARAM]/p:ReleaseBuild=true"
condition: ${{ parameters.Condition }}
displayName: Set MSI_PRODUCT_NAME_PARAM for release
displayName: Set MSI_PRODUCT_NAME_PARAM, and RELEASE_BUILD_PARAM for release

- ${{ else }}:
# Leave version and product name empty for dev build (allows dev version to)
# install over any previously installed version. These variables must be set
# or DevOps will substitute in the literal string
# (e.g. '$(MSI_PRODUCT_NAME_PARAM)') into the msbuild command arguments.
# Set daily dev release version
- pwsh: |
Write-Host "##vso[task.setvariable variable=MSI_PRODUCT_NAME_PARAM]"
Write-Host "##vso[task.setvariable variable=MSI_VERSION_PARAM]"
Write-Host "##vso[task.setvariable variable=RELEASE_BUILD_PARAM]"
condition: ${{ parameters.Condition }}
displayName: Set MSI_PRODUCT_NAME_PARAM and MSI_VERSION_PARAM for dev release
displayName: Set MSI_PRODUCT_NAME_PARAM, and RELEASE_BUILD_PARAM for dev release

- task: MSBuild@1
displayName: ${{ parameters.Title }}
Expand All @@ -41,5 +38,6 @@ steps:
msbuildArguments: >-
/p:RunWixToolsOutOfProc=true
/p:Configuration=Release
/p:ProductVersion=$(MSI_VERSION)
$(MSI_PRODUCT_NAME_PARAM)
$(MSI_VERSION_PARAM)
$(RELEASE_BUILD_PARAM)
27 changes: 27 additions & 0 deletions eng/pipelines/templates/steps/set-msi-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
steps:
# Deepen the commit history by 6 months to ensure that the
# minor-version-introducing tag is present.
- pwsh: |
$since = (Get-Date).AddMonths(-6).ToString("yyyy-MM-dd")
Write-Host "Deepening git history since: $since"
git fetch --shallow-since="$since" --tags

$msiVersion = & eng/scripts/Get-MsiDevVersion.ps1
Write-Host "Using MSI version: $msiVersion"
Write-Host "##vso[task.setvariable variable=MSI_VERSION]$msiVersion"
displayName: Set MSI_VERSION for CI build
condition: >-
or(
in(variables['BuildReasonOverride'], 'IndividualCI', 'BatchedCI'),
and(
eq('', variables['BuildReasonOverride']),
in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI')
)
)

- pwsh: |
$msiVersion = & eng/scripts/Get-MsiVersion.ps1 -CliVersion "$(CLI_VERSION)"
Write-Host "Using MSI version: $msiVersion"
Write-Host "##vso[task.setvariable variable=MSI_VERSION]$msiVersion"
displayName: Set MSI_VERSION
condition: eq('', variables['MSI_VERSION'])
75 changes: 75 additions & 0 deletions eng/scripts/Get-MsiDevVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This script returns a dev MSI version by finding the most recent release tag,
# then finding the first release tag that introduced the current minor version,
# and then calculating the "release distance" from that tag to the current
# commit.
#
# The MSI version is of the form: <major>.<minor>.<commit-distance-from-minor-intro-release>.
# This ensures a monotonically increasing version number for each build on the
# "main" branch.
#
# By default, the git history is assumed to be deepened by 6 months in the CI
# environment to ensure that a minor intro release is found.

. "$PSScriptRoot../../common/scripts/common.ps1"

Set-StrictMode -Version 4

$tagPrefix = 'azure-dev-cli_'

# Step 1: Most recent release tag
$mostRecentRelease = git describe --tags --match "${tagPrefix}*" --abbrev=0 HEAD
if ($LASTEXITCODE -ne 0 -or !$mostRecentRelease) {
throw "Could not find a release tag matching '${tagPrefix}*'"
}

$mostRecentVersion = $mostRecentRelease.Substring($tagPrefix.Length)
$parsedMostRecent = [AzureEngSemanticVersion]::ParseVersionString($mostRecentVersion)
if (!$parsedMostRecent) {
throw "Could not parse version from tag '$mostRecentRelease'"
}

Write-Host "Most recent release: $mostRecentRelease (minor=$($parsedMostRecent.Minor))"

# Step 2: First release tag that introduced the current minor version
$currentRef = "$mostRecentRelease^"
$minorVersionRevRelease = $mostRecentRelease
while ($true) {
$candidate = git describe --tags --match "${tagPrefix}*" --abbrev=0 $currentRef 2>$null
if ($LASTEXITCODE -ne 0 -or !$candidate) {
# The current tag introduces the minor version
break
}

$versionCandidate = $candidate.Substring($tagPrefix.Length)
$parsedCandidate = [AzureEngSemanticVersion]::ParseVersionString($versionCandidate)

if (!$parsedCandidate) {
throw "Could not parse version from tag '$candidate'"
}

if ($parsedCandidate.Minor -ne $parsedMostRecent.Minor) {
break
}

$minorVersionRevRelease = $candidate
$currentRef = "$candidate^"
}

Write-Host "Minor intro release: $minorVersionRevRelease"

# Step 3: MSI version for minor rev release + commit distance
$minorRevVersion = $minorVersionRevRelease.Substring($tagPrefix.Length)
$msiVersionBase = & "$PSScriptRoot/Get-MsiVersion.ps1" -CliVersion $minorRevVersion

$commitDistance = [int](git rev-list --count "$minorVersionRevRelease..HEAD")

$parts = $msiVersionBase -split '\.'
$patch = [int]$parts[2] + $commitDistance

$devVersion = "$($parts[0]).$($parts[1]).$patch"

Write-Host "MSI version (base): $msiVersionBase"
Write-Host "Commit distance: $commitDistance"
Write-Host "Computed dev version: $devVersion"

return $devVersion
Loading