Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"version": 1,
"isRoot": true,
"tools": {
"gitversion.tool": {
"version": "6.0.5",
"nbgv": {
"version": "3.9.50",
"commands": [
"dotnet-gitversion"
"nbgv"
]
}
}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
Expand Down Expand Up @@ -52,6 +54,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
Expand Down
61 changes: 14 additions & 47 deletions .github/workflows/validate-and-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
# GitVersion needs full history to compute commit counts.
# Nerdbank.GitVersioning needs full history to walk back to the
# commit that last changed version.json (the baseline) so it can
# compute the patch as the git height since that commit.
fetch-depth: 0

- name: Setup .NET SDK
Expand All @@ -72,13 +74,13 @@ jobs:
Directory.Packages.props
**/*.csproj

- name: Restore GitVersion tool
- name: Restore .NET tools
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
dotnet tool restore
if ($LASTEXITCODE -ne 0) {
throw "Failed to restore the local GitVersion tool."
throw "Failed to restore .NET local tools (nbgv)."
}

- name: Compute version properties
Expand All @@ -87,43 +89,18 @@ jobs:
run: |
$ErrorActionPreference = 'Stop'

# Major.Minor come from GitVersion (`next-version` in
# GitVersion.yml). The patch is the number of commits since
# GitVersion.yml was last modified, computed directly from
# git so it is independent of any tags and so it resets to 0
# whenever next-version is bumped. GitVersion's
# CommitsSinceVersionSource is not used because, with the
# TaggedCommit strategy disabled, it falls back to counting
# all commits in the repository.
$gitVersionJson = dotnet tool run dotnet-gitversion /output json /nofetch /nonormalize
if ($LASTEXITCODE -ne 0) {
throw "Failed to compute version metadata with dotnet-gitversion."
}

$gv = $gitVersionJson | ConvertFrom-Json

$configPath = Join-Path $env:GITHUB_WORKSPACE 'GitVersion.yml'
$configCommit = (git log -n 1 --format=%H -- $configPath).Trim()
if ([string]::IsNullOrWhiteSpace($configCommit)) {
throw "Could not determine the commit that last changed GitVersion.yml."
# Nerdbank.GitVersioning is wired in via PackageReference in
# Directory.Build.props, so dotnet build/publish/pack already
# produce versions matching version.json. We only need NBGV's
# NuGetPackageVersion here to drive artifact naming and the
# workflow step summary.
$packageVersion = (dotnet tool run nbgv get-version -v NuGetPackageVersion).Trim()
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($packageVersion)) {
throw "Failed to compute version metadata with nbgv."
}

$commitsSinceConfig = [int](git rev-list --count "$configCommit..HEAD")
if ($commitsSinceConfig -gt 65535) {
throw "Commits since GitVersion.yml ($commitsSinceConfig) exceeds the maximum .NET assembly version segment value of 65535. Bump next-version in GitVersion.yml before generating assembly and file versions."
}

$assemblyVersion = "$($gv.Major).$($gv.Minor).$commitsSinceConfig"
$packageVersion = "$assemblyVersion-preview"
$fileVersion = "$assemblyVersion.0"
$infoVersion = "$packageVersion+${{ github.sha }}"

Write-Host "AssemblyVersion: $assemblyVersion"
Write-Host "PackageVersion: $packageVersion"
"assembly_version=$assemblyVersion" >> $env:GITHUB_OUTPUT
"package_version=$packageVersion" >> $env:GITHUB_OUTPUT
"file_version=$fileVersion" >> $env:GITHUB_OUTPUT
"informational_version=$infoVersion" >> $env:GITHUB_OUTPUT

$branchName = "${{ github.ref_name }}"
$branchLabel = $branchName.ToLowerInvariant()
Expand All @@ -150,9 +127,6 @@ jobs:
dotnet build CosmosDBShell.sln
--configuration $env:BUILD_CONFIGURATION
--no-restore
/p:Version=${{ steps.version.outputs.assembly_version }}
/p:FileVersion=${{ steps.version.outputs.file_version }}
/p:InformationalVersion=${{ steps.version.outputs.informational_version }}
shell: pwsh

- name: Test solution
Expand Down Expand Up @@ -213,10 +187,7 @@ jobs:
--configuration $env:BUILD_CONFIGURATION `
--no-restore `
-r $rid `
--output "out/$rid" `
/p:Version=${{ steps.version.outputs.assembly_version }} `
/p:FileVersion=${{ steps.version.outputs.file_version }} `
/p:InformationalVersion=${{ steps.version.outputs.informational_version }}
--output "out/$rid"

if ($LASTEXITCODE -ne 0) {
throw "RID publish failed for $rid with exit code $LASTEXITCODE."
Expand All @@ -235,10 +206,6 @@ jobs:
--configuration $env:BUILD_CONFIGURATION `
--no-restore `
--output out/nupkg `
/p:PackageVersion=${{ steps.version.outputs.package_version }} `
/p:Version=${{ steps.version.outputs.assembly_version }} `
/p:FileVersion=${{ steps.version.outputs.file_version }} `
/p:InformationalVersion=${{ steps.version.outputs.informational_version }} `
/p:ContinuousIntegrationBuild=true

- name: Validate NuGet package set
Expand Down
74 changes: 23 additions & 51 deletions .pipelines/CosmosDB-Shell-Official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ extends:
variables: # More settings at https://aka.ms/obpipelines/yaml/jobs
ob_outputDirectory: '$(Build.SourcesDirectory)\out' # this directory is uploaded to pipeline artifacts, reddog and cloudvault. More info at https://aka.ms/obpipelines/artifacts
ob_artifactBaseName: cosmos_shell_all # combined artifact with all RIDs for SDL scanning
# GitVersion needs full history to count commits. Using
# ob_git_fetchDepth lets OneBranch do the full clone in one shot
# instead of shallow-clone + --unshallow, which avoids a second
# fetch to github.com that the windows_build_container pool blocks.
# Nerdbank.GitVersioning needs full history to walk back to
# the commit that last changed version.json (the baseline) so
# it can compute the patch as the git height since that
# commit. Setting ob_git_fetchDepth: -1 makes OneBranch do the
# full clone in one shot instead of shallow-clone +
# --unshallow, avoiding a second fetch to github.com that the
# windows_build_container pool blocks.
ob_git_fetchDepth: -1
OneES_SbomNugetSDLPath: out\nupkg
# https://aka.ms/obpipelines/sdl
Expand All @@ -97,52 +100,25 @@ extends:
- script: dotnet tool restore --configfile "$(Build.SourcesDirectory)\\.pipelines\\nuget.config"
displayName: "Dotnet Tools Restore"

# Major.Minor come from GitVersion (`next-version` in
# GitVersion.yml). The patch is the number of commits since
# GitVersion.yml was last modified, computed directly from
# git so it is independent of any tags and so it resets to
# 0 whenever next-version is bumped. GitVersion's
# CommitsSinceVersionSource is not used because, with the
# TaggedCommit strategy disabled, it falls back to counting
# all commits in the repository.
# Nerdbank.GitVersioning is wired in via PackageReference in
# Directory.Build.props, so dotnet build/publish/pack already
# produce versions matching version.json. We only need NBGV's
# NuGetPackageVersion here to drive the OneBranch build
# number and the zip filenames.
- task: PowerShell@2
displayName: "Compute version with GitVersion"
displayName: "Compute version with nbgv"
inputs:
targetType: inline
pwsh: true
script: |
$ErrorActionPreference = 'Stop'
$gitVersionJson = dotnet tool run dotnet-gitversion /output json

if ($LASTEXITCODE -ne 0) {
throw "dotnet-gitversion failed with exit code $LASTEXITCODE."
}

$gv = $gitVersionJson | ConvertFrom-Json

$configPath = Join-Path '$(Build.SourcesDirectory)' 'GitVersion.yml'
$configCommit = (git log -n 1 --format=%H -- $configPath).Trim()
if ([string]::IsNullOrWhiteSpace($configCommit)) {
throw "Could not determine the commit that last changed GitVersion.yml."
$packageVersion = (dotnet tool run nbgv get-version -v NuGetPackageVersion).Trim()
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($packageVersion)) {
throw "Failed to compute version metadata with nbgv."
}

$commitsSinceConfig = [int](git rev-list --count "$configCommit..HEAD")
if ($commitsSinceConfig -gt 65535) {
throw "Commits since GitVersion.yml ($commitsSinceConfig) exceeds the maximum .NET assembly version segment value of 65535. Bump next-version in GitVersion.yml before generating assembly and file versions."
}

$assemblyVersion = "$($gv.Major).$($gv.Minor).$commitsSinceConfig"
$packageVersion = "$assemblyVersion-preview"
$fileVersion = "$assemblyVersion.0"
$infoVersion = "$packageVersion+$(Build.SourceVersion)"

Write-Host "AssemblyVersion: $assemblyVersion"
Write-Host "PackageVersion: $packageVersion"

Write-Host "##vso[task.setvariable variable=CosmosDBShell_Version]$assemblyVersion"
Write-Host "##vso[task.setvariable variable=CosmosDBShell_PackageVersion]$packageVersion"
Write-Host "##vso[task.setvariable variable=CosmosDBShell_FileVersion]$fileVersion"
Write-Host "##vso[task.setvariable variable=CosmosDBShell_InformationalVersion]$infoVersion"

- task: onebranch.pipeline.version@1
displayName: "Update build number"
Expand All @@ -166,7 +142,7 @@ extends:
displayName: "DotNetCore build with RoslynAnalyzers"
inputs:
userProvideBuildInfo: "msBuildInfo"
msBuildCommandline: "dotnet.exe build $(BuildSolution) --no-restore --configuration $(BuildConfiguration) /p:Version=$(CosmosDBShell_Version) /p:FileVersion=$(CosmosDBShell_FileVersion) /p:InformationalVersion=$(CosmosDBShell_InformationalVersion)"
msBuildCommandline: "dotnet.exe build $(BuildSolution) --no-restore --configuration $(BuildConfiguration)"

- task: DotNetCoreCLI@2
displayName: "DotNetCore test"
Expand All @@ -189,7 +165,7 @@ extends:
command: "publish"
publishWebProjects: false
projects: $(ReleaseProject)
arguments: '--configuration $(BuildConfiguration) -r win-x64 --output $(Build.SourcesDirectory)\out\win-x64 /p:Version=$(CosmosDBShell_Version) /p:FileVersion=$(CosmosDBShell_FileVersion) /p:InformationalVersion=$(CosmosDBShell_InformationalVersion) --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
arguments: '--configuration $(BuildConfiguration) -r win-x64 --output $(Build.SourcesDirectory)\out\win-x64 --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
zipAfterPublish: false

- task: DotNetCoreCLI@2
Expand All @@ -198,7 +174,7 @@ extends:
command: "publish"
publishWebProjects: false
projects: $(ReleaseProject)
arguments: '--configuration $(BuildConfiguration) -r win-arm64 --output $(Build.SourcesDirectory)\out\win-arm64 /p:Version=$(CosmosDBShell_Version) /p:FileVersion=$(CosmosDBShell_FileVersion) /p:InformationalVersion=$(CosmosDBShell_InformationalVersion) --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
arguments: '--configuration $(BuildConfiguration) -r win-arm64 --output $(Build.SourcesDirectory)\out\win-arm64 --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
zipAfterPublish: false

- task: DotNetCoreCLI@2
Expand All @@ -207,7 +183,7 @@ extends:
command: "publish"
publishWebProjects: false
projects: $(ReleaseProject)
arguments: '--configuration $(BuildConfiguration) -r osx-x64 --output $(Build.SourcesDirectory)\out\osx-x64 /p:Version=$(CosmosDBShell_Version) /p:FileVersion=$(CosmosDBShell_FileVersion) /p:InformationalVersion=$(CosmosDBShell_InformationalVersion) --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
arguments: '--configuration $(BuildConfiguration) -r osx-x64 --output $(Build.SourcesDirectory)\out\osx-x64 --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
zipAfterPublish: false

- task: DotNetCoreCLI@2
Expand All @@ -216,7 +192,7 @@ extends:
command: "publish"
publishWebProjects: false
projects: $(ReleaseProject)
arguments: '--configuration $(BuildConfiguration) -r linux-x64 --output $(Build.SourcesDirectory)\out\linux-x64 /p:Version=$(CosmosDBShell_Version) /p:FileVersion=$(CosmosDBShell_FileVersion) /p:InformationalVersion=$(CosmosDBShell_InformationalVersion) --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
arguments: '--configuration $(BuildConfiguration) -r linux-x64 --output $(Build.SourcesDirectory)\out\linux-x64 --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
zipAfterPublish: false

- task: DotNetCoreCLI@2
Expand All @@ -225,7 +201,7 @@ extends:
command: "publish"
publishWebProjects: false
projects: $(ReleaseProject)
arguments: '--configuration $(BuildConfiguration) -r linux-arm64 --output $(Build.SourcesDirectory)\out\linux-arm64 /p:Version=$(CosmosDBShell_Version) /p:FileVersion=$(CosmosDBShell_FileVersion) /p:InformationalVersion=$(CosmosDBShell_InformationalVersion) --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
arguments: '--configuration $(BuildConfiguration) -r linux-arm64 --output $(Build.SourcesDirectory)\out\linux-arm64 --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
zipAfterPublish: false

- task: DotNetCoreCLI@2
Expand All @@ -234,7 +210,7 @@ extends:
command: "publish"
publishWebProjects: false
projects: $(ReleaseProject)
arguments: '--configuration $(BuildConfiguration) -r osx-arm64 --output $(Build.SourcesDirectory)\out\osx-arm64 /p:Version=$(CosmosDBShell_Version) /p:FileVersion=$(CosmosDBShell_FileVersion) /p:InformationalVersion=$(CosmosDBShell_InformationalVersion) --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
arguments: '--configuration $(BuildConfiguration) -r osx-arm64 --output $(Build.SourcesDirectory)\out\osx-arm64 --configfile $(Build.SourcesDirectory)\.pipelines\nuget.config'
zipAfterPublish: false

# Kept for reference, intentionally disabled:
Expand Down Expand Up @@ -416,10 +392,6 @@ extends:
--no-build `
--no-restore `
--output $pkgDir `
/p:PackageVersion=$(CosmosDBShell_PackageVersion) `
/p:Version=$(CosmosDBShell_Version) `
/p:FileVersion=$(CosmosDBShell_FileVersion) `
/p:InformationalVersion=$(CosmosDBShell_InformationalVersion) `
/p:ContinuousIntegrationBuild=true

if ($LASTEXITCODE -ne 0) {
Expand Down
29 changes: 16 additions & 13 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<Project>
<!-- CI restores GitVersion.Tool from the repo tool manifest and computes
Version, FileVersion, InformationalVersion, and PackageVersion from
GitVersion.yml. See .github/workflows/validate-and-package.yml and
.pipelines/CosmosDB-Shell-Official.yml. -->

<!-- Default version suffix for the preview phase. CI overrides Version and
InformationalVersion explicitly (both already include "-preview"); this
only affects local/dev builds where no Version is passed in, so the
embedded executable still shows "<x.y.z>-preview". Remove this once the
preview phase is over. -->
<PropertyGroup>
<VersionSuffix Condition=" '$(VersionSuffix)' == '' ">preview</VersionSuffix>
</PropertyGroup>
<!-- Versioning is driven by Nerdbank.GitVersioning (NBGV). Major.Minor and
the prerelease label come from version.json at the repo root; the
patch is the git height (commits since version.json last changed) so
a Major.Minor bump cleanly resets the patch to 0. NBGV sets Version,
FileVersion, AssemblyVersion, AssemblyInformationalVersion, and
PackageVersion automatically for both local and CI builds. -->
<!-- Most projects use central package management; the version is sourced
from Directory.Packages.props. -->
<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' != 'false'">
<PackageReference Include="Nerdbank.GitVersioning" PrivateAssets="all" />
</ItemGroup>
<!-- CosmosDBShell.Fuzzer opts out of central package management, so the
version must be pinned directly on the PackageReference. -->
<ItemGroup Condition="'$(ManagePackageVersionsCentrally)' == 'false'">
<PackageReference Include="Nerdbank.GitVersioning" PrivateAssets="all" Version="3.9.50" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.9.50" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.5-beta1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="11.0.0-preview.2.26159.112" />
<PackageVersion Include="ModelContextProtocol" Version="1.1.0" />
Expand Down
21 changes: 0 additions & 21 deletions GitVersion.yml

This file was deleted.

Loading
Loading