From d0519d0d90e26e6cde5219057daabf597852d88a Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Thu, 12 Dec 2024 14:28:51 +0700 Subject: [PATCH 1/6] sign all fw lite dlls with the correct information version rather than using ApplicationDisplayVersion which the build process further modifies --- .github/workflows/fw-lite.yaml | 6 ++---- .../FwLite/FwDataMiniLcmBridge/FwDataMiniLcmBridge.csproj | 3 +-- backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj | 2 -- backend/FwLite/FwLiteProjectSync/FwLiteProjectSync.csproj | 1 - backend/FwLite/LcmCrdt/LcmCrdt.csproj | 1 - backend/FwLite/LocalWebApp/LocalWebApp.csproj | 1 - backend/FwLite/MiniLcm/MiniLcm.csproj | 1 - 7 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/fw-lite.yaml b/.github/workflows/fw-lite.yaml index 5b3c2ccc9..28b3252d5 100644 --- a/.github/workflows/fw-lite.yaml +++ b/.github/workflows/fw-lite.yaml @@ -172,16 +172,14 @@ jobs: - name: Publish Windows MAUI portable app working-directory: backend/FwLite/FwLiteDesktop run: | - dotnet publish -r win-x64 --artifacts-path ../artifacts -p:WindowsPackageType=None -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} - dotnet publish -r win-arm64 --artifacts-path ../artifacts -p:WindowsPackageType=None -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} + dotnet publish -r win-x64 --artifacts-path ../artifacts -p:WindowsPackageType=None -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} -p:InformationalVersion=${{ needs.build-and-test.outputs.version }} mkdir -p ../artifacts/sign/portable cp -r ../artifacts/publish/FwLiteDesktop/* ../artifacts/sign/portable/ - name: Publish Windows MAUI msix app working-directory: backend/FwLite/FwLiteDesktop run: | - dotnet publish -r win-x64 --artifacts-path ../artifacts -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} - dotnet publish -r win-arm64 --artifacts-path ../artifacts -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} + dotnet publish -r win-x64 --artifacts-path ../artifacts -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} -p:InformationalVersion=${{ needs.build-and-test.outputs.version }} mkdir -p ../artifacts/msix cp ../artifacts/bin/FwLiteDesktop/*/AppPackages/*/*.msix ../artifacts/msix/ diff --git a/backend/FwLite/FwDataMiniLcmBridge/FwDataMiniLcmBridge.csproj b/backend/FwLite/FwDataMiniLcmBridge/FwDataMiniLcmBridge.csproj index dd6ae3743..cd3878b24 100644 --- a/backend/FwLite/FwDataMiniLcmBridge/FwDataMiniLcmBridge.csproj +++ b/backend/FwLite/FwDataMiniLcmBridge/FwDataMiniLcmBridge.csproj @@ -1,8 +1,7 @@  - $(ApplicationDisplayVersion) - $(ApplicationDisplayVersion) + $(ApplicationDisplayVersion) diff --git a/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj b/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj index d37d8b546..14017906e 100644 --- a/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj +++ b/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj @@ -33,8 +33,6 @@ 1.0 1 - - $(ApplicationDisplayVersion) 11.0 13.1 diff --git a/backend/FwLite/FwLiteProjectSync/FwLiteProjectSync.csproj b/backend/FwLite/FwLiteProjectSync/FwLiteProjectSync.csproj index 8cbde01b8..2b3a8d940 100644 --- a/backend/FwLite/FwLiteProjectSync/FwLiteProjectSync.csproj +++ b/backend/FwLite/FwLiteProjectSync/FwLiteProjectSync.csproj @@ -1,7 +1,6 @@  - $(ApplicationDisplayVersion) $(ApplicationDisplayVersion) diff --git a/backend/FwLite/LcmCrdt/LcmCrdt.csproj b/backend/FwLite/LcmCrdt/LcmCrdt.csproj index 66bd926ff..cbd1fa603 100644 --- a/backend/FwLite/LcmCrdt/LcmCrdt.csproj +++ b/backend/FwLite/LcmCrdt/LcmCrdt.csproj @@ -1,7 +1,6 @@  - $(ApplicationDisplayVersion) $(ApplicationDisplayVersion) diff --git a/backend/FwLite/LocalWebApp/LocalWebApp.csproj b/backend/FwLite/LocalWebApp/LocalWebApp.csproj index 6b480b782..14c3dbd0a 100644 --- a/backend/FwLite/LocalWebApp/LocalWebApp.csproj +++ b/backend/FwLite/LocalWebApp/LocalWebApp.csproj @@ -5,7 +5,6 @@ true false true - $(ApplicationDisplayVersion) $(ApplicationDisplayVersion) diff --git a/backend/FwLite/MiniLcm/MiniLcm.csproj b/backend/FwLite/MiniLcm/MiniLcm.csproj index e806ed4ff..3a89c7e9e 100644 --- a/backend/FwLite/MiniLcm/MiniLcm.csproj +++ b/backend/FwLite/MiniLcm/MiniLcm.csproj @@ -1,7 +1,6 @@  - $(ApplicationDisplayVersion) $(ApplicationDisplayVersion) From 407a3cc3997610943b7d2bc4dd680a0a234bc906 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Thu, 12 Dec 2024 14:37:24 +0700 Subject: [PATCH 2/6] use api which supports deferring the update while the app is in use --- .../FwLite/FwLiteDesktop/FwLiteDesktop.csproj | 4 ++-- .../Platforms/Windows/AppUpdateService.cs | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj b/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj index 14017906e..f3e46e10c 100644 --- a/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj +++ b/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj @@ -37,8 +37,8 @@ 11.0 13.1 21.0 - 10.0.17763.0 - 10.0.17763.0 + 10.0.19041.0 + 10.0.19041.0 6.5 diff --git a/backend/FwLite/FwLiteDesktop/Platforms/Windows/AppUpdateService.cs b/backend/FwLite/FwLiteDesktop/Platforms/Windows/AppUpdateService.cs index ca8b0ba2b..bf0e9721d 100644 --- a/backend/FwLite/FwLiteDesktop/Platforms/Windows/AppUpdateService.cs +++ b/backend/FwLite/FwLiteDesktop/Platforms/Windows/AppUpdateService.cs @@ -45,14 +45,24 @@ private async Task TryUpdate() private async Task ApplyUpdate(FwLiteRelease latestRelease) { - logger.LogInformation("New version available: {Version}", latestRelease.Version); + logger.LogInformation("New version available: {Version}, Current version: {CurrentVersion}", latestRelease.Version, AppVersion.Version); var packageManager = new PackageManager(); - var asyncOperation = packageManager.AddPackageAsync(new Uri(latestRelease.Url), [], DeploymentOptions.None); + var asyncOperation = packageManager.AddPackageByUriAsync(new Uri(latestRelease.Url), + new AddPackageOptions() + { + DeferRegistrationWhenPackagesAreInUse = true, + ForceUpdateFromAnyVersion = true + }); asyncOperation.Progress = (info, progressInfo) => { + if (progressInfo.state == DeploymentProgressState.Queued) + { + logger.LogInformation("Queued update"); + return; + } logger.LogInformation("Downloading update: {ProgressPercentage}%", progressInfo.percentage); }; - var result = await asyncOperation.AsTask(); + var result = await asyncOperation; if (!string.IsNullOrEmpty(result.ErrorText)) { logger.LogError(result.ExtendedErrorCode, "Failed to download update: {ErrorText}", result.ErrorText); From 6a6711edb25a1815485fe64373346539d51ecf18 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Thu, 12 Dec 2024 14:41:00 +0700 Subject: [PATCH 3/6] temp enable signing from this branch --- .github/workflows/fw-lite.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fw-lite.yaml b/.github/workflows/fw-lite.yaml index 28b3252d5..c369b46fe 100644 --- a/.github/workflows/fw-lite.yaml +++ b/.github/workflows/fw-lite.yaml @@ -195,7 +195,7 @@ jobs: MakeAppx.exe bundle /v /bv ${{ needs.build-and-test.outputs.semver-version }}.1 /d . /p ../sign/FwLiteDesktop.msixbundle - name: Sign with Trusted Signing - if: ${{ github.ref_name == 'develop' || github.ref_name == 'main' }} + if: ${{ github.ref_name == 'develop' || github.ref_name == 'main' || github.ref_name == 'chore/auto-update-package-in-use' }} uses: sillsdev/codesign/trusted-signing-action@v3 with: credentials: ${{ secrets.TRUSTED_SIGNING_CREDENTIALS }} From 71f618011d33c5f898c41609b3fde5b19cf4f599 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Thu, 12 Dec 2024 15:19:00 +0700 Subject: [PATCH 4/6] enable signing --- .github/workflows/fw-lite.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fw-lite.yaml b/.github/workflows/fw-lite.yaml index c369b46fe..3bb7f01bd 100644 --- a/.github/workflows/fw-lite.yaml +++ b/.github/workflows/fw-lite.yaml @@ -195,7 +195,7 @@ jobs: MakeAppx.exe bundle /v /bv ${{ needs.build-and-test.outputs.semver-version }}.1 /d . /p ../sign/FwLiteDesktop.msixbundle - name: Sign with Trusted Signing - if: ${{ github.ref_name == 'develop' || github.ref_name == 'main' || github.ref_name == 'chore/auto-update-package-in-use' }} +# if: ${{ github.ref_name == 'develop' || github.ref_name == 'main' || github.ref_name == 'chore/auto-update-package-in-use' }} uses: sillsdev/codesign/trusted-signing-action@v3 with: credentials: ${{ secrets.TRUSTED_SIGNING_CREDENTIALS }} From 9e0d4a5e8e8e3e4bb792fba42fe7efaa393d65c8 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Thu, 12 Dec 2024 16:17:11 +0700 Subject: [PATCH 5/6] trim info version to be exactly what we want instead of including the full commit hash --- backend/FwLite/FwLiteDesktop/AppVersion.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/FwLite/FwLiteDesktop/AppVersion.cs b/backend/FwLite/FwLiteDesktop/AppVersion.cs index 16f9f3421..b6ac0424c 100644 --- a/backend/FwLite/FwLiteDesktop/AppVersion.cs +++ b/backend/FwLite/FwLiteDesktop/AppVersion.cs @@ -4,6 +4,17 @@ namespace FwLiteDesktop; public class AppVersion { - public static readonly string Version = typeof(AppVersion).Assembly - .GetCustomAttribute()?.InformationalVersion ?? "dev"; + static AppVersion() + { + var infoVersion = typeof(AppVersion).Assembly + .GetCustomAttribute()?.InformationalVersion; + //info version may look like v2024-12-12-3073dd1c+3073dd1ce2ff5510f54a9411366f55c958b9ea45. We want to strip off everything after the +, so we can compare versions + if (infoVersion is not null && infoVersion.Contains('+')) + { + infoVersion = infoVersion[..infoVersion.IndexOf('+')]; + } + Version = infoVersion ?? "dev"; + } + + public static readonly string Version; } From 35e993661fab4ef140c7b002f42e9618aea52528 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Thu, 12 Dec 2024 16:17:36 +0700 Subject: [PATCH 6/6] put signing back to prod mode --- .github/workflows/fw-lite.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fw-lite.yaml b/.github/workflows/fw-lite.yaml index 3bb7f01bd..28b3252d5 100644 --- a/.github/workflows/fw-lite.yaml +++ b/.github/workflows/fw-lite.yaml @@ -195,7 +195,7 @@ jobs: MakeAppx.exe bundle /v /bv ${{ needs.build-and-test.outputs.semver-version }}.1 /d . /p ../sign/FwLiteDesktop.msixbundle - name: Sign with Trusted Signing -# if: ${{ github.ref_name == 'develop' || github.ref_name == 'main' || github.ref_name == 'chore/auto-update-package-in-use' }} + if: ${{ github.ref_name == 'develop' || github.ref_name == 'main' }} uses: sillsdev/codesign/trusted-signing-action@v3 with: credentials: ${{ secrets.TRUSTED_SIGNING_CREDENTIALS }}