From 6a99c9e37bb8bd928bf5993b4e1620cb92b54166 Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Fri, 14 Feb 2025 04:14:21 +0000 Subject: [PATCH 1/2] Init --- .github/scripts/Build-AppSolution.ps1 | 94 ++++++++++ .github/scripts/Configure-AppxManifest.ps1 | 22 +-- .github/workflows/cd.yml | 196 +++++++++++++++++++++ .github/workflows/ci.yml | 155 ++++++---------- 4 files changed, 355 insertions(+), 112 deletions(-) create mode 100644 .github/scripts/Build-AppSolution.ps1 create mode 100644 .github/workflows/cd.yml diff --git a/.github/scripts/Build-AppSolution.ps1 b/.github/scripts/Build-AppSolution.ps1 new file mode 100644 index 000000000000..b781c02bc234 --- /dev/null +++ b/.github/scripts/Build-AppSolution.ps1 @@ -0,0 +1,94 @@ +# Copyright (c) Files Community +# Licensed under the MIT License. + +param( + [string]$ReleaseBranch = "Debug", # Debug, Release, SideloadPreview, SideloadStable, StorePreview, or StoreStable + [string]$SolutionPath = "Files.slnx", + [string]$StartupProjectPath = "", + [string]$Platform = "x64", + [string]$Configuration = "Debug", + [string]$AppxBundlePlatforms = "x64|arm64", + [string]$AppxPackageDir = "", + [string]$AppInstallerUrl = "", # Sideload only + [string]$AppxPackageCertKeyFile = "" # Debug only +) + +# Restore the solution +msbuild $SolutionPath /t:Restore /p:Platform=$Platform /p:Configuration=$Configuration /p:PublishReadyToRun=true + +if ($ReleaseBranch -eq "Debug") +{ + msbuild $StartupProjectPath ` + /t:Build ` + /clp:ErrorsOnly ` + /p:Platform=$Platform ` + /p:Configuration=$Configuration ` + /p:AppxBundle=Never ` + /v:quiet +} +elseif ($ReleaseBranch -eq "Release") +{ + if ($Platform -eq "x64") + { + msbuild $StartupProjectPath ` + /t:Build ` + /clp:ErrorsOnly ` + /p:Platform=$Platform ` + /p:Configuration=$Configuration ` + /p:AppxBundlePlatforms=$Platform ` + /p:AppxBundle=Always ` + /p:UapAppxPackageBuildMode=SideloadOnly ` + /p:AppxPackageDir=$AppxPackageDir ` + /p:AppxPackageSigningEnabled=true ` + /p:PackageCertificateKeyFile=$AppxPackageCertKeyFile ` + /p:PackageCertificatePassword="" ` + /p:PackageCertificateThumbprint="" ` + /v:quiet + } + else + { + msbuild $StartupProjectPath ` + /t:Build ` + /clp:ErrorsOnly ` + /p:Platform=$Platform ` + /p:Configuration=$Configuration ` + /p:AppxBundle=Never ` + /v:quiet + } +} +elseif ($ReleaseBranch -contains "Sideload") +{ + msbuild $StartupProjectPath ` + /t:Build ` + /t:_GenerateAppxPackage ` + /clp:ErrorsOnly ` + /p:Platform=$Platform ` + /p:Configuration=$Configuration ` + /p:AppxBundlePlatforms=$AppxBundlePlatforms ` + /p:AppxPackageDir=$AppxPackageDir ` + /p:AppxBundle=Always ` + /p:UapAppxPackageBuildMode=Sideload ` + /p:GenerateAppInstallerFile=True ` + /p:AppInstallerUri=$AppInstallerUrl ` + /v:quiet + + $newSchema = 'http://schemas.microsoft.com/appx/appinstaller/2018' + $localFilePath = '$AppxPackageDir/Files.Package.appinstaller' + $fileContent = Get-Content $localFilePath + $fileContent = $fileContent.Replace('http://schemas.microsoft.com/appx/appinstaller/2017/2', $newSchema) + $fileContent | Set-Content $localFilePath +} +elseif ($ReleaseBranch -contains "Store") +{ + msbuild $StartupProjectPath ` + /t:Build ` + /t:_GenerateAppxPackage ` + /clp:ErrorsOnly ` + /p:Platform=$Platform ` + /p:Configuration=$Configuration ` + /p:AppxBundlePlatforms=$AppxBundlePlatforms ` + /p:AppxPackageDir=$AppxPackageDir ` + /p:AppxBundle=Always ` + /p:UapAppxPackageBuildMode=StoreUpload ` + /v:quiet +} diff --git a/.github/scripts/Configure-AppxManifest.ps1 b/.github/scripts/Configure-AppxManifest.ps1 index 4140bccc38df..797be48f169d 100644 --- a/.github/scripts/Configure-AppxManifest.ps1 +++ b/.github/scripts/Configure-AppxManifest.ps1 @@ -2,12 +2,12 @@ # Licensed under the MIT License. param( - [string]$Branch = "", # This has to correspond with one of the AppEnvironment enum values - [string]$PackageManifestPath = "", - [string]$Publisher = "", - [string]$WorkingDir = "", - [string]$SecretBingMapsKey = "", - [string]$SecretSentry = "", + [string]$ReleaseBranch = "", # SideloadPreview, SideloadStable, StorePreview, or StoreStable + [string]$PackageManifestPath = "", + [string]$Publisher = "", + [string]$WorkingDir = "", + [string]$SecretBingMapsKey = "", + [string]$SecretSentry = "", [string]$SecretGitHubOAuthClientId = "" ) @@ -27,7 +27,7 @@ $ea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pk # Update the publisher $xmlDoc.Package.Identity.Publisher = $Publisher -if ($Branch -eq "SideloadPreview") +if ($ReleaseBranch -eq "SideloadPreview") { # Set identities $xmlDoc.Package.Identity.Name="FilesPreview" @@ -54,7 +54,7 @@ if ($Branch -eq "SideloadPreview") Set-Content $_ -NoNewline ` } } -elseif ($Branch -eq "StorePreview") +elseif ($ReleaseBranch -eq "StorePreview") { # Set identities $xmlDoc.Package.Identity.Name="49306atecsolution.FilesPreview" @@ -87,7 +87,7 @@ elseif ($Branch -eq "StorePreview") Set-Content $_ -NoNewline ` } } -elseif ($Branch -eq "SideloadStable") +elseif ($ReleaseBranch -eq "SideloadStable") { # Set identities $xmlDoc.Package.Identity.Name="Files" @@ -114,7 +114,7 @@ elseif ($Branch -eq "SideloadStable") Set-Content $_ -NoNewline ` } } -elseif ($Branch -eq "StoreStable") +elseif ($ReleaseBranch -eq "StoreStable") { # Set identities $xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP" @@ -148,7 +148,7 @@ elseif ($Branch -eq "StoreStable") Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process ` { ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $Branch }) | ` + (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $ReleaseBranch }) | ` Set-Content $_ -NoNewline ` } diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 000000000000..d2ac7ec47340 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,196 @@ +# Copyright (c) Files Community +# Licensed under the MIT License. + +# Abstract: +# Deploys Files to either Sideload or Store. +# +# Workflow: +# 1. Configure manifest, logo and secrets +# 2. Restore, build and package Files +# 3. Publish the appinstaller to files.community if sideloading +# 4. Sign the package if sideloading +# 5. Publish the package to either Azure or Microsoft Developer Center + +name: Files CD + +on: + workflow_dispatch: + inputs: + build-branch: + type: choice + description: Build branch + options: + - 'Preview' + - 'Stable' + default: 'Preview' + publish-to-store: + type: boolean + description: Publish to Store as well + default: 'true' + +env: + CONFIGURATION: 'Release' + PLATFORM: 'x64' + APPX_BUNDLE_PLATFORMS: 'x64|arm64' + WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\ + SOLUTION_PATH: '${{ github.workspace }}\Files.slnx' + ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts' + APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages' + PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\Files.App (Package)' + PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\Files.App (Package)\Files.Package.wapproj' + PACKAGE_MANIFEST_PATH: '${{ github.workspace }}\src\Files.App (Package)\Package.appxmanifest' + +jobs: + sideload: + runs-on: windows-latest + environment: Deployments + strategy: + fail-fast: false + env: + # This is either SideloadPreview or SideloadStable + RELEASE_BRANCH: 'Sideload${{ github.event.inputs.build-branch }}' + + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 + - name: Setup NuGet + uses: NuGet/setup-nuget@v2 + - name: Setup .NET 8 + uses: actions/setup-dotnet@v4 + with: + global-json-file: global.json + + - name: Get sideload appinstaller URL + id: tolowercase + uses: ASzc/change-string-case-action@v6 + with: + string: ${{ github.event.inputs.build-branch }} + + - name: Build Files + run: | + . './.github/scripts/Configure-AppxManifest.ps1' ` + -ReleaseBranch "$env:RELEASE_BRANCH" ` + -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` + -WorkingDir "$env:WORKING_DIR" ` + -Publisher "$env:SECRET_PUBLISHER_NAME" ` + -SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` + -SecretSentry "$env:SECRET_SENTRY" ` + -SecretGitHubOAuthClientId "$env:SECRET_GH_OAUTH_CLIENT_ID" + . './.github/scripts/Build-AppSolution.ps1' ` + -ReleaseBranch "$env:RELEASE_BRANCH" ` + -SolutionPath "$env:SOLUTION_PATH" ` + -StartupProjectPath "$env:PACKAGE_PROJECT_PATH" ` + -Configuration "$env:CONFIGURATION" ` + -Platform "$env:PLATFORM" ` + -AppxPackageDir "$env:APPX_PACKAGE_DIR" ` + -AppInstallerUrl "$env:APP_INSTALLER_SIDELOAD_URL" + env: + SECRET_PUBLISHER_NAME: ${{ secrets.SIDELOAD_PUBLISHER_SECRET }} + SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }} + SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }} + SECRET_GH_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }} + APP_INSTALLER_SIDELOAD_URL: "https://cdn.files.community/files/${{ steps.tolowercase.outputs.lowercase }}/" + + - name: Sign Files with Azure Trusted Signing + uses: azure/trusted-signing-action@v0.4.0 + with: + azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} + azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} + azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} + endpoint: https://eus.codesigning.azure.net/ + trusted-signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }} + certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }} + files-folder: ${{ env.APPX_PACKAGE_DIR }} + files-folder-filter: msixbundle + files-folder-recurse: true + files-folder-depth: 4 + file-digest: SHA256 + timestamp-rfc3161: http://timestamp.acs.microsoft.com + timestamp-digest: SHA256 + + - name: Login to Azure + uses: azure/login@v2 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Upload to Azure blob storage + run: | + az storage blob upload-batch ` + --account-name "filescommunity" ` + --destination "files" ` + --destination-path "${{ github.event.inputs.build-branch }}" ` + --source "${{ env.APPX_PACKAGE_DIR }}" ` + --overwrite true + az logout + + - name: Upload the packages to GitHub Actions + uses: actions/upload-artifact@v4 + with: + name: 'Appx Packages (${{ env.RELEASE_BRANCH }})' + path: ${{ env.ARTIFACTS_STAGING_DIR }} + + store: + + if: ${{ github.event.inputs.publish-to-store }} + + runs-on: windows-latest + environment: Deployments + strategy: + fail-fast: false + env: + # This is either StorePreview or StoreStable + RELEASE_BRANCH: 'Store${{ github.event.inputs.build-branch }}' + + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 + - name: Setup NuGet + uses: NuGet/setup-nuget@v2 + - name: Setup .NET 8 + uses: actions/setup-dotnet@v4 + with: + global-json-file: global.json + + - name: Build Files + run: | + . './.github/scripts/Configure-AppxManifest.ps1' ` + -ReleaseBranch "$env:RELEASE_BRANCH" ` + -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` + -WorkingDir "$env:WORKING_DIR" ` + -Publisher "$env:SECRET_PUBLISHER_NAME" ` + -SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` + -SecretSentry "$env:SECRET_SENTRY" ` + -SecretGitHubOAuthClientId "$env:SECRET_GH_OAUTH_CLIENT_ID" + . './.github/scripts/Build-AppSolution.ps1' ` + -ReleaseBranch "$env:RELEASE_BRANCH" ` + -SolutionPath "$env:SOLUTION_PATH" ` + -StartupProjectPath "$env:PACKAGE_PROJECT_PATH" ` + -Configuration "$env:CONFIGURATION" ` + -Platform "$env:PLATFORM" ` + -AppxPackageDir "$env:APPX_PACKAGE_DIR" + env: + SECRET_PUBLISHER_NAME: ${{ secrets.STORE_PUBLISHER_SECRET }} + SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }} + SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }} + SECRET_GH_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }} + + - name: Publish the packages to Microsoft Store + uses: isaacrlevin/windows-store-action@1 + with: + app-id: '9NGHP3DX8HDX' + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + client-id: ${{ secrets.AZURE_CLIENT_ID }} + client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} + package-path: '${{ env.ARTIFACTS_STAGING_DIR }}/**/*.msixupload' + skip-polling: false + packages-keep: 5 + + - name: Upload the packages to GitHub Actions + uses: actions/upload-artifact@v4 + with: + name: 'Appx Packages (${{ env.RELEASE_BRANCH }})' + path: ${{ env.ARTIFACTS_STAGING_DIR }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9234b5c8ccf1..d0378d3e25da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,20 +28,20 @@ on: run-name: ${{ github.event_name == 'pull_request' && 'Files PR Validation' || 'Files CI Validation' }} env: - WORKING_DIR: ${{ github.workspace }} # Default: 'D:\a\Files\Files' - SOLUTION_PATH: '${{ github.workspace }}\Files.slnx' - PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\Files.App (Package)' - PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\Files.App (Package)\Files.Package.wapproj' - AUTOMATED_TESTS_ARCHITECTURE: 'x64' + WORKING_DIR: '${{ github.workspace }}' # Default: 'D:\a\Files\Files' + SOLUTION_PATH: '${{ github.workspace }}\Files.slnx' + PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\Files.App (Package)' + PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\Files.App (Package)\Files.Package.wapproj' + AUTOMATED_TESTS_PLATFORM: 'x64' AUTOMATED_TESTS_CONFIGURATION: 'Release' - AUTOMATED_TESTS_PROJECT_DIR: '${{ github.workspace }}\tests\Files.InteractionTests' - AUTOMATED_TESTS_PROJECT_PATH: '${{ github.workspace }}\tests\Files.InteractionTests\Files.InteractionTests.csproj' - AUTOMATED_TESTS_ASSEMBLY_DIR: '${{ github.workspace }}\artifacts\TestsAssembly' - ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts' - APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages' - APPX_SELFSIGNED_CERT_PATH: '${{ github.workspace }}\.github\workflows\FilesApp_SelfSigned.pfx' - WINAPPDRIVER_EXE86_PATH: 'C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe' - WINAPPDRIVER_EXE64_PATH: 'C:\Program Files\Windows Application Driver\WinAppDriver.exe' + AUTOMATED_TESTS_PROJECT_DIR: '${{ github.workspace }}\tests\Files.InteractionTests' + AUTOMATED_TESTS_PROJECT_PATH: '${{ github.workspace }}\tests\Files.InteractionTests\Files.InteractionTests.csproj' + AUTOMATED_TESTS_ASSEMBLY_DIR: '${{ github.workspace }}\artifacts\TestsAssembly' + ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts' + APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages' + APPX_SELFSIGNED_CERT_PATH: '${{ github.workspace }}\.github\workflows\FilesApp_SelfSigned.pfx' + WINAPPDRIVER_EXE86_PATH: 'C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe' + WINAPPDRIVER_EXE64_PATH: 'C:\Program Files\Windows Application Driver\WinAppDriver.exe' jobs: @@ -93,7 +93,7 @@ jobs: platform: [x64, arm64] env: CONFIGURATION: ${{ matrix.configuration }} - ARCHITECTURE: ${{ matrix.platform }} + PLATFORM: ${{ matrix.platform }} steps: @@ -108,72 +108,49 @@ jobs: with: global-json-file: global.json - - name: Restore Files - shell: pwsh - run: | - msbuild $env:SOLUTION_PATH ` - -t:Restore ` - -p:Platform=$env:ARCHITECTURE ` - -p:Configuration=$env:CONFIGURATION ` - -p:PublishReadyToRun=true ` - -v:quiet - - - if: env.CONFIGURATION != env.AUTOMATED_TESTS_CONFIGURATION || env.ARCHITECTURE != env.AUTOMATED_TESTS_ARCHITECTURE + - if: env.CONFIGURATION != env.AUTOMATED_TESTS_CONFIGURATION || env.PLATFORM != env.AUTOMATED_TESTS_PLATFORM name: Build Files run: | - msbuild ` - $env:PACKAGE_PROJECT_PATH ` - -t:Build ` - -p:Configuration=$env:CONFIGURATION ` - -p:Platform=$env:ARCHITECTURE ` - -p:AppxBundle=Never ` - -v:quiet - - - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE - name: Create self signed cert as a pfx file - run: ./.github/scripts/Generate-SelfCertPfx.ps1 -Destination "$env:APPX_SELFSIGNED_CERT_PATH" - - - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE - name: Build & package Files + . './.github/scripts/Build-AppSolution.ps1' ` + -ReleaseBranch "$env:CONFIGURATION" ` + -SolutionPath "$env:SOLUTION_PATH" ` + -StartupProjectPath "$env:PACKAGE_PROJECT_PATH" ` + -Configuration "$env:CONFIGURATION" ` + -Platform "$env:PLATFORM" + + - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.PLATFORM == env.AUTOMATED_TESTS_PLATFORM + name: Build and package Files run: | + # Generate self signing certificate + . './.github/scripts/Generate-SelfCertPfx.ps1' ` + -Destination "$env:APPX_SELFSIGNED_CERT_PATH" + # Restore and build + . './.github/scripts/Build-AppSolution.ps1' ` + -ReleaseBranch "$env:CONFIGURATION" ` + -SolutionPath "$env:SOLUTION_PATH" ` + -StartupProjectPath "$env:PACKAGE_PROJECT_PATH" ` + -Configuration "$env:CONFIGURATION" ` + -Platform "$env:PLATFORM" ` + -AppxBundlePlatforms "$env:PLATFORM" ` + -AppxPackageDir "$env:APPX_PACKAGE_DIR" ` + -AppxPackageCertKeyFile "$env:APPX_SELFSIGNED_CERT_PATH" + # Build test project msbuild ` - $env:PACKAGE_PROJECT_PATH ` - -t:Build ` - -t:_GenerateAppxPackage ` - -p:Configuration=$env:CONFIGURATION ` - -p:Platform=$env:ARCHITECTURE ` - -p:AppxBundlePlatforms=$env:AUTOMATED_TESTS_ARCHITECTURE ` - -p:AppxBundle=Always ` - -p:UapAppxPackageBuildMode=SideloadOnly ` - -p:AppxPackageDir=$env:APPX_PACKAGE_DIR ` - -p:AppxPackageSigningEnabled=true ` - -p:PackageCertificateKeyFile=$env:APPX_SELFSIGNED_CERT_PATH ` - -p:PackageCertificatePassword="" ` - -p:PackageCertificateThumbprint="" ` - -v:quiet - - - if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION - name: Build interaction tests - run: | - msbuild $env:AUTOMATED_TESTS_PROJECT_PATH ` - -t:Build ` - -p:Configuration=$env:CONFIGURATION ` - -p:Platform=$env:AUTOMATED_TESTS_ARCHITECTURE ` - -v:quiet - - - if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION - name: Copy tests bin to the artifacts dir - shell: pwsh - run: | + $env:AUTOMATED_TESTS_PROJECT_PATH ` + /t:Build ` + /clp:ErrorsOnly ` + /p:Configuration=$env:CONFIGURATION ` + /p:Platform=$env:PLATFORM Copy-Item ` - -Path "$env:AUTOMATED_TESTS_PROJECT_DIR\bin" ` - -Destination "$env:AUTOMATED_TESTS_ASSEMBLY_DIR" -Recurse + -Path "$env:AUTOMATED_TESTS_PROJECT_DIR\bin" ` + -Destination "$env:AUTOMATED_TESTS_ASSEMBLY_DIR" ` + -Recurse - - if: env.ARCHITECTURE == env.AUTOMATED_TESTS_ARCHITECTURE && env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION - name: Upload the packages to the Artifacts + - if: env.CONFIGURATION == env.AUTOMATED_TESTS_CONFIGURATION && env.PLATFORM == env.AUTOMATED_TESTS_PLATFORM + name: Upload the packages to GitHub Actions uses: actions/upload-artifact@v4 with: - name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.ARCHITECTURE }})' + name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})' path: ${{ env.ARTIFACTS_STAGING_DIR }} test: @@ -189,6 +166,7 @@ jobs: platform: [x64] env: CONFIGURATION: ${{ matrix.configuration }} + PLATFORM: ${{ matrix.platform }} permissions: contents: read pull-requests: write @@ -209,10 +187,10 @@ jobs: - name: Download the packages from the Artifacts uses: actions/download-artifact@v4 with: - name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.AUTOMATED_TESTS_ARCHITECTURE }})' + name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})' path: ${{ env.ARTIFACTS_STAGING_DIR }} - - name: Install Files + - name: Prepare for the tests shell: powershell run: | Set-Location "$env:APPX_PACKAGE_DIR" @@ -220,13 +198,8 @@ jobs: Set-Location $AppxPackageBundleDir ./Install.ps1 -Force Get-AppxPackage - - - name: Set full HD resolution - run: Set-DisplayResolution -Width 1920 -Height 1080 -Force - - - name: Start WinAppDriver process - shell: pwsh - run: Start-Process -FilePath "$env:WINAPPDRIVER_EXE86_PATH" + Set-DisplayResolution -Width 1920 -Height 1080 -Force + Start-Process -FilePath "$env:WINAPPDRIVER_EXE86_PATH" # Retry integration tests if first attempt fails - name: Run interaction tests @@ -244,23 +217,3 @@ jobs: uses: geekyeggo/delete-artifact@v5 with: name: '*' - - # - name: Generate markdown from the tests result - # shell: pwsh - # run: | - # . './scripts/Convert-TrxToMarkdown.ps1' ` - # -Source "$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.trx" ` - # -Destination "$env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.md" - # env: - # PULL_REQUEST_ID: ${{ github.event.pull_request_id }} - - # - name: Display the markdown on the output (temp) - # shell: pwsh - # run: | - # Get-Content $env:AUTOMATED_TESTS_ASSEMBLY_DIR\testResults.md - - # - name: Publish tests result - # uses: marocchino/sticky-pull-request-comment@v2 - # with: - # header: test-result - # path: '${{ env.AUTOMATED_TESTS_ASSEMBLY_DIR }}\testResults.md' From 0c8efc28abcafe41bc16d1ba8d13e15c437db409 Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 5 Mar 2025 15:45:21 +0000 Subject: [PATCH 2/2] Revert --- .github/scripts/Configure-AppxManifest.ps1 | 12 +- .github/workflows/cd.yml | 196 --------------------- 2 files changed, 6 insertions(+), 202 deletions(-) delete mode 100644 .github/workflows/cd.yml diff --git a/.github/scripts/Configure-AppxManifest.ps1 b/.github/scripts/Configure-AppxManifest.ps1 index 797be48f169d..23ec48ffa58c 100644 --- a/.github/scripts/Configure-AppxManifest.ps1 +++ b/.github/scripts/Configure-AppxManifest.ps1 @@ -2,7 +2,7 @@ # Licensed under the MIT License. param( - [string]$ReleaseBranch = "", # SideloadPreview, SideloadStable, StorePreview, or StoreStable + [string]$Branch = "", # SideloadPreview, SideloadStable, StorePreview, or StoreStable [string]$PackageManifestPath = "", [string]$Publisher = "", [string]$WorkingDir = "", @@ -27,7 +27,7 @@ $ea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pk # Update the publisher $xmlDoc.Package.Identity.Publisher = $Publisher -if ($ReleaseBranch -eq "SideloadPreview") +if ($Branch -eq "SideloadPreview") { # Set identities $xmlDoc.Package.Identity.Name="FilesPreview" @@ -54,7 +54,7 @@ if ($ReleaseBranch -eq "SideloadPreview") Set-Content $_ -NoNewline ` } } -elseif ($ReleaseBranch -eq "StorePreview") +elseif ($Branch -eq "StorePreview") { # Set identities $xmlDoc.Package.Identity.Name="49306atecsolution.FilesPreview" @@ -87,7 +87,7 @@ elseif ($ReleaseBranch -eq "StorePreview") Set-Content $_ -NoNewline ` } } -elseif ($ReleaseBranch -eq "SideloadStable") +elseif ($Branch -eq "SideloadStable") { # Set identities $xmlDoc.Package.Identity.Name="Files" @@ -114,7 +114,7 @@ elseif ($ReleaseBranch -eq "SideloadStable") Set-Content $_ -NoNewline ` } } -elseif ($ReleaseBranch -eq "StoreStable") +elseif ($Branch -eq "StoreStable") { # Set identities $xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP" @@ -148,7 +148,7 @@ elseif ($ReleaseBranch -eq "StoreStable") Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process ` { ` - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $ReleaseBranch }) | ` + (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $Branch }) | ` Set-Content $_ -NoNewline ` } diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index d2ac7ec47340..000000000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,196 +0,0 @@ -# Copyright (c) Files Community -# Licensed under the MIT License. - -# Abstract: -# Deploys Files to either Sideload or Store. -# -# Workflow: -# 1. Configure manifest, logo and secrets -# 2. Restore, build and package Files -# 3. Publish the appinstaller to files.community if sideloading -# 4. Sign the package if sideloading -# 5. Publish the package to either Azure or Microsoft Developer Center - -name: Files CD - -on: - workflow_dispatch: - inputs: - build-branch: - type: choice - description: Build branch - options: - - 'Preview' - - 'Stable' - default: 'Preview' - publish-to-store: - type: boolean - description: Publish to Store as well - default: 'true' - -env: - CONFIGURATION: 'Release' - PLATFORM: 'x64' - APPX_BUNDLE_PLATFORMS: 'x64|arm64' - WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\ - SOLUTION_PATH: '${{ github.workspace }}\Files.slnx' - ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts' - APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages' - PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\Files.App (Package)' - PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\Files.App (Package)\Files.Package.wapproj' - PACKAGE_MANIFEST_PATH: '${{ github.workspace }}\src\Files.App (Package)\Package.appxmanifest' - -jobs: - sideload: - runs-on: windows-latest - environment: Deployments - strategy: - fail-fast: false - env: - # This is either SideloadPreview or SideloadStable - RELEASE_BRANCH: 'Sideload${{ github.event.inputs.build-branch }}' - - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v2 - - name: Setup NuGet - uses: NuGet/setup-nuget@v2 - - name: Setup .NET 8 - uses: actions/setup-dotnet@v4 - with: - global-json-file: global.json - - - name: Get sideload appinstaller URL - id: tolowercase - uses: ASzc/change-string-case-action@v6 - with: - string: ${{ github.event.inputs.build-branch }} - - - name: Build Files - run: | - . './.github/scripts/Configure-AppxManifest.ps1' ` - -ReleaseBranch "$env:RELEASE_BRANCH" ` - -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` - -WorkingDir "$env:WORKING_DIR" ` - -Publisher "$env:SECRET_PUBLISHER_NAME" ` - -SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` - -SecretSentry "$env:SECRET_SENTRY" ` - -SecretGitHubOAuthClientId "$env:SECRET_GH_OAUTH_CLIENT_ID" - . './.github/scripts/Build-AppSolution.ps1' ` - -ReleaseBranch "$env:RELEASE_BRANCH" ` - -SolutionPath "$env:SOLUTION_PATH" ` - -StartupProjectPath "$env:PACKAGE_PROJECT_PATH" ` - -Configuration "$env:CONFIGURATION" ` - -Platform "$env:PLATFORM" ` - -AppxPackageDir "$env:APPX_PACKAGE_DIR" ` - -AppInstallerUrl "$env:APP_INSTALLER_SIDELOAD_URL" - env: - SECRET_PUBLISHER_NAME: ${{ secrets.SIDELOAD_PUBLISHER_SECRET }} - SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }} - SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }} - SECRET_GH_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }} - APP_INSTALLER_SIDELOAD_URL: "https://cdn.files.community/files/${{ steps.tolowercase.outputs.lowercase }}/" - - - name: Sign Files with Azure Trusted Signing - uses: azure/trusted-signing-action@v0.4.0 - with: - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} - endpoint: https://eus.codesigning.azure.net/ - trusted-signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }} - certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }} - files-folder: ${{ env.APPX_PACKAGE_DIR }} - files-folder-filter: msixbundle - files-folder-recurse: true - files-folder-depth: 4 - file-digest: SHA256 - timestamp-rfc3161: http://timestamp.acs.microsoft.com - timestamp-digest: SHA256 - - - name: Login to Azure - uses: azure/login@v2 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - - name: Upload to Azure blob storage - run: | - az storage blob upload-batch ` - --account-name "filescommunity" ` - --destination "files" ` - --destination-path "${{ github.event.inputs.build-branch }}" ` - --source "${{ env.APPX_PACKAGE_DIR }}" ` - --overwrite true - az logout - - - name: Upload the packages to GitHub Actions - uses: actions/upload-artifact@v4 - with: - name: 'Appx Packages (${{ env.RELEASE_BRANCH }})' - path: ${{ env.ARTIFACTS_STAGING_DIR }} - - store: - - if: ${{ github.event.inputs.publish-to-store }} - - runs-on: windows-latest - environment: Deployments - strategy: - fail-fast: false - env: - # This is either StorePreview or StoreStable - RELEASE_BRANCH: 'Store${{ github.event.inputs.build-branch }}' - - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v2 - - name: Setup NuGet - uses: NuGet/setup-nuget@v2 - - name: Setup .NET 8 - uses: actions/setup-dotnet@v4 - with: - global-json-file: global.json - - - name: Build Files - run: | - . './.github/scripts/Configure-AppxManifest.ps1' ` - -ReleaseBranch "$env:RELEASE_BRANCH" ` - -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` - -WorkingDir "$env:WORKING_DIR" ` - -Publisher "$env:SECRET_PUBLISHER_NAME" ` - -SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` - -SecretSentry "$env:SECRET_SENTRY" ` - -SecretGitHubOAuthClientId "$env:SECRET_GH_OAUTH_CLIENT_ID" - . './.github/scripts/Build-AppSolution.ps1' ` - -ReleaseBranch "$env:RELEASE_BRANCH" ` - -SolutionPath "$env:SOLUTION_PATH" ` - -StartupProjectPath "$env:PACKAGE_PROJECT_PATH" ` - -Configuration "$env:CONFIGURATION" ` - -Platform "$env:PLATFORM" ` - -AppxPackageDir "$env:APPX_PACKAGE_DIR" - env: - SECRET_PUBLISHER_NAME: ${{ secrets.STORE_PUBLISHER_SECRET }} - SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }} - SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }} - SECRET_GH_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }} - - - name: Publish the packages to Microsoft Store - uses: isaacrlevin/windows-store-action@1 - with: - app-id: '9NGHP3DX8HDX' - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - client-id: ${{ secrets.AZURE_CLIENT_ID }} - client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} - package-path: '${{ env.ARTIFACTS_STAGING_DIR }}/**/*.msixupload' - skip-polling: false - packages-keep: 5 - - - name: Upload the packages to GitHub Actions - uses: actions/upload-artifact@v4 - with: - name: 'Appx Packages (${{ env.RELEASE_BRANCH }})' - path: ${{ env.ARTIFACTS_STAGING_DIR }}