feat: Set PROGRAM_VERSION in dotnet publish and msix

This commit is contained in:
ochenstarik-ui 2026-08-10 13:34:38 +07:00
parent 32ee96c039
commit dfab4f4a33
2 changed files with 61 additions and 17 deletions

View file

@ -70,14 +70,25 @@ jobs:
with: with:
dotnet-version: 10.0.x dotnet-version: 10.0.x
- name: Set Version
id: version
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="0.2.0-dev"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Publish agent - name: Publish agent
run: dotnet publish src/ServerMonitorManager.Agent/ServerMonitorManager.Agent.csproj --configuration Release --runtime ${{ matrix.runtime }} --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:RestoreLockedMode=true -o out/agent run: dotnet publish src/ServerMonitorManager.Agent/ServerMonitorManager.Agent.csproj --configuration Release --runtime ${{ matrix.runtime }} --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:RestoreLockedMode=true -p:Version=${{ steps.version.outputs.version }} -o out/agent
- name: Publish control - name: Publish control
run: dotnet publish src/ServerMonitorManager.Control/ServerMonitorManager.Control.csproj --configuration Release --runtime ${{ matrix.runtime }} --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:RestoreLockedMode=true -o out/control run: dotnet publish src/ServerMonitorManager.Control/ServerMonitorManager.Control.csproj --configuration Release --runtime ${{ matrix.runtime }} --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:RestoreLockedMode=true -p:Version=${{ steps.version.outputs.version }} -o out/control
- name: Publish provisioning helper - name: Publish provisioning helper
run: dotnet publish src/ServerMonitorManager.Provisioning.Helper/ServerMonitorManager.Provisioning.Helper.csproj --configuration Release --runtime ${{ matrix.runtime }} --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:RestoreLockedMode=true -o out/provisioning-helper run: dotnet publish src/ServerMonitorManager.Provisioning.Helper/ServerMonitorManager.Provisioning.Helper.csproj --configuration Release --runtime ${{ matrix.runtime }} --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:RestoreLockedMode=true -p:Version=${{ steps.version.outputs.version }} -o out/provisioning-helper
- name: Package - name: Package
shell: bash shell: bash
@ -146,9 +157,20 @@ jobs:
"test_certificate=true" >> $env:GITHUB_OUTPUT "test_certificate=true" >> $env:GITHUB_OUTPUT
} }
- name: Set Version
id: version
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="0.2.0-dev"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Build signed MSIX - name: Build signed MSIX
shell: pwsh shell: pwsh
run: ./build/windows/Build-Installer.ps1 -CertificatePath '${{ steps.signing.outputs.certificate }}' -CertificatePassword '${{ steps.signing.outputs.password }}' run: ./build/windows/Build-Installer.ps1 -CertificatePath '${{ steps.signing.outputs.certificate }}' -CertificatePassword '${{ steps.signing.outputs.password }}' -Version '${{ steps.version.outputs.version }}'
- name: Include test certificate - name: Include test certificate
if: steps.signing.outputs.test_certificate == 'true' if: steps.signing.outputs.test_certificate == 'true'

View file

@ -5,6 +5,9 @@ param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
[string]$CertificatePassword, [string]$CertificatePassword,
[Parameter(Mandatory = $false)]
[string]$Version,
[string]$OutputDirectory = 'artifacts/windows-installer' [string]$OutputDirectory = 'artifacts/windows-installer'
) )
@ -38,6 +41,24 @@ try {
dotnet restore $project -p:Platform=x64 -p:PublishReadyToRun=false -p:RestoreLockedMode=true dotnet restore $project -p:Platform=x64 -p:PublishReadyToRun=false -p:RestoreLockedMode=true
if ($LASTEXITCODE -ne 0) { throw 'dotnet restore failed' } if ($LASTEXITCODE -ne 0) { throw 'dotnet restore failed' }
if ($Version) {
$dotnetArgs += "-p:Version=$Version"
$dotnetArgs += "-p:AppxPackageVersion=$Version.0"
dotnet publish $project `
--configuration Release `
--runtime win-x64 `
--no-restore `
-p:Platform=x64 `
-p:PublishReadyToRun=false `
-p:GenerateAppxPackageOnBuild=true `
-p:AppxPackageSigningEnabled=true `
-p:PackageCertificateThumbprint=$($signingCertificate.Thumbprint) `
-p:AppxBundle=Never `
-p:AppxSymbolPackageEnabled=false `
-p:UapAppxPackageBuildMode=SideloadOnly `
-p:AppxPackageDir="$appPackages\" `
-p:Version=$Version
} else {
dotnet publish $project ` dotnet publish $project `
--configuration Release ` --configuration Release `
--runtime win-x64 ` --runtime win-x64 `
@ -51,6 +72,7 @@ try {
-p:AppxSymbolPackageEnabled=false ` -p:AppxSymbolPackageEnabled=false `
-p:UapAppxPackageBuildMode=SideloadOnly ` -p:UapAppxPackageBuildMode=SideloadOnly `
-p:AppxPackageDir="$appPackages\" -p:AppxPackageDir="$appPackages\"
}
if ($LASTEXITCODE -ne 0) { throw 'dotnet publish failed' } if ($LASTEXITCODE -ne 0) { throw 'dotnet publish failed' }
$package = Get-ChildItem -LiteralPath $appPackages -Recurse -File | $package = Get-ChildItem -LiteralPath $appPackages -Recurse -File |