From dfd49de1cc412d4ae4a5c4348f0eff8e19c9df76 Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 3 Jul 2024 22:56:44 +0900 Subject: [PATCH 1/3] Init --- .github/workflows/cd-preview.yml | 44 ++++++++++++++++--------- .github/workflows/cd-stable.yml | 46 ++++++++++++++++---------- scripts/Configure-AppxManifest.ps1 | 52 +++++++++++++++--------------- 3 files changed, 83 insertions(+), 59 deletions(-) diff --git a/.github/workflows/cd-preview.yml b/.github/workflows/cd-preview.yml index 6b114f0a9653..f163500ad2b1 100644 --- a/.github/workflows/cd-preview.yml +++ b/.github/workflows/cd-preview.yml @@ -1,6 +1,16 @@ # Copyright (c) 2024 Files Community # Licensed under the MIT License. See the LICENSE. +# Abstract: +# Deploys Files Preview (Sideload). +# +# Workflow: +# 1. Configure manifest, logo and secrets +# 2. Restore, build and package Files +# 3. Publish the appinstaller to files.community +# 4. Sign the package +# 5. Publish the package to Azure + name: Files CD (Preview) on: @@ -16,16 +26,18 @@ jobs: configuration: [Preview] platform: [x64] env: - SOLUTION_NAME: 'Files.sln' - PACKAGE_PROJECT_DIR: 'src\Files.App (Package)' - PACKAGE_PROJECT_PATH: 'src\Files.App (Package)\Files.Package.wapproj' - TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj' - CONFIGURATION: ${{ matrix.configuration }} - PLATFORM: ${{ matrix.platform }} - APPX_BUNDLE_PLATFORMS: 'x64|arm64' - WORKING_DIR: ${{ github.workspace }} # Default: D:\a\Files\Files\ - ARTIFACTS_STAGING_DIR: ${{ github.workspace }}\artifacts - APPX_PACKAGE_DIR: ${{ github.workspace }}\artifacts\AppxPackages + SOLUTION_NAME: 'Files.sln' + CONFIGURATION: '${{ matrix.configuration }}' + PLATFORM: '${{ matrix.platform }}' + APPX_BUNDLE_PLATFORMS: 'x64|arm64' + WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\ + ARTIFACTS_STAGING_DIR: 'artifacts' # D:\a\Files\Files\artifacts\ + APPX_PACKAGE_DIR: 'artifacts\AppxPackages' + PACKAGE_PROJECT_DIR: 'src\Files.App (Package)' + PACKAGE_PROJECT_PATH: 'src\Files.App (Package)\Files.Package.wapproj' + PACKAGE_MANIFEST_PATH: 'src\Files.App (Package)\Package.appxmanifest' + TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj' + APP_INSTALLER_SIDELOAD_URL: 'https://cdn.files.community/files/preview/' steps: - name: Checkout the repository @@ -39,12 +51,12 @@ jobs: with: dotnet-version: '8.0.x' - - name: Configure the package manifest, logo sets, and secrets + - name: Configure the package manifest, logo, and secrets shell: pwsh run: | . './scripts/Configure-AppxManifest.ps1' ` -Branch "$env:CONFIGURATION" ` - -PackageProjectDir "$env:PACKAGE_PROJECT_DIR" ` + -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` -Publisher "$env:SIDELOAD_PUBLISHER_SECRET" ` -WorkingDir "$env:WORKING_DIR" ` -SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` @@ -65,7 +77,7 @@ jobs: shell: pwsh run: 'nuget restore $env:SOLUTION_NAME' - - name: Restore ${{ env.SOLUTION_NAME }} + - name: Restore Files shell: pwsh run: | msbuild $env:SOLUTION_NAME ` @@ -74,7 +86,7 @@ jobs: -p:Configuration=$env:CONFIGURATION ` -p:PublishReadyToRun=true - - name: Build ${{ env.SOLUTION_NAME }} + - name: Build Files shell: pwsh run: | msbuild "$env:PACKAGE_PROJECT_PATH" ` @@ -87,7 +99,7 @@ jobs: -p:AppxBundle=Always ` -p:UapAppxPackageBuildMode=Sideload ` -p:GenerateAppInstallerFile=True ` - -p:AppInstallerUri=https://cdn.files.community/files/preview/ + -p:AppInstallerUri=$env:APP_INSTALLER_SIDELOAD_URL - name: Remove empty files from the packages shell: bash @@ -101,7 +113,7 @@ jobs: $fileContent = $fileContent.Replace("http://schemas.microsoft.com/appx/appinstaller/2017/2", $newSchema) $fileContent | Set-Content $localFilePath - - name: Sign files with Azure Trusted Signing + - name: Sign Files with Azure Trusted Signing uses: azure/trusted-signing-action@v0.3.16 with: azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} diff --git a/.github/workflows/cd-stable.yml b/.github/workflows/cd-stable.yml index 2208d2ce9e6d..7ff9bdefb0af 100644 --- a/.github/workflows/cd-stable.yml +++ b/.github/workflows/cd-stable.yml @@ -1,6 +1,16 @@ # Copyright (c) 2024 Files Community # Licensed under the MIT License. See the LICENSE. +# Abstract: +# Deploys Files (Sideload). +# +# Workflow: +# 1. Configure manifest, logo and secrets +# 2. Restore, build and package Files +# 3. Publish the appinstaller to files.community +# 4. Sign the package +# 5. Publish the package to Azure + name: Files CD (Stable) on: @@ -16,16 +26,18 @@ jobs: configuration: [Stable] platform: [x64] env: - SOLUTION_NAME: 'Files.sln' - PACKAGE_PROJECT_DIR: 'src\Files.App (Package)' - PACKAGE_PROJECT_PATH: 'src\Files.App (Package)\Files.Package.wapproj' - TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj' - CONFIGURATION: ${{ matrix.configuration }} - PLATFORM: ${{ matrix.platform }} - APPX_BUNDLE_PLATFORMS: 'x64|arm64' - WORKING_DIR: ${{ github.workspace }} # Default: D:\a\Files\Files\ - ARTIFACTS_STAGING_DIR: ${{ github.workspace }}\artifacts - APPX_PACKAGE_DIR: ${{ github.workspace }}\artifacts\AppxPackages + SOLUTION_NAME: 'Files.sln' + CONFIGURATION: '${{ matrix.configuration }}' + PLATFORM: '${{ matrix.platform }}' + APPX_BUNDLE_PLATFORMS: 'x64|arm64' + WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\ + ARTIFACTS_STAGING_DIR: 'artifacts' # D:\a\Files\Files\artifacts\ + APPX_PACKAGE_DIR: 'artifacts\AppxPackages' + PACKAGE_PROJECT_DIR: 'src\Files.App (Package)' + PACKAGE_PROJECT_PATH: 'src\Files.App (Package)\Files.Package.wapproj' + PACKAGE_MANIFEST_PATH: 'src\Files.App (Package)\Package.appxmanifest' + TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj' + APP_INSTALLER_SIDELOAD_URL: 'https://cdn.files.community/files/stable/' steps: - name: Checkout the repository @@ -39,12 +51,12 @@ jobs: with: dotnet-version: '8.0.x' - - name: Configure the package manifest, logo sets, and secrets + - name: Configure the package manifest, logo, and secrets shell: pwsh run: | . './scripts/Configure-AppxManifest.ps1' ` -Branch "$env:CONFIGURATION" ` - -PackageProjectDir "$env:PACKAGE_PROJECT_DIR" ` + -PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" ` -Publisher "$env:SIDELOAD_PUBLISHER_SECRET" ` -WorkingDir "$env:WORKING_DIR" ` -SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` @@ -65,7 +77,7 @@ jobs: shell: pwsh run: 'nuget restore $env:SOLUTION_NAME' - - name: Restore ${{ env.SOLUTION_NAME }} + - name: Restore Files shell: pwsh run: | msbuild $env:SOLUTION_NAME ` @@ -74,7 +86,7 @@ jobs: -p:Configuration=$env:CONFIGURATION ` -p:PublishReadyToRun=true - - name: Build ${{ env.SOLUTION_NAME }} + - name: Build & oackage Files shell: pwsh run: | msbuild "$env:PACKAGE_PROJECT_PATH" ` @@ -87,7 +99,7 @@ jobs: -p:AppxBundle=Always ` -p:UapAppxPackageBuildMode=Sideload ` -p:GenerateAppInstallerFile=True ` - -p:AppInstallerUri=https://cdn.files.community/files/stable/ + -p:AppInstallerUri=$env:APP_INSTALLER_SIDELOAD_URL - name: Remove empty files from the packages shell: bash @@ -121,13 +133,13 @@ jobs: - name: Login to Azure uses: azure/login@v1 with: - creds: ${{ secrets.AZURE_CREDENTIALS }} + creds: ${{ secrets.AZURE_CREDENTIALS }} - name: Upload to Azure blob storage uses: azure/powershell@v1 with: inlineScript: | - az storage blob upload-batch --account-name "filescommunity" --destination "files" --destination-path "stable" --source ${{ env.APPX_PACKAGE_DIR }} --overwrite true + az storage blob upload-batch --account-name "filescommunity" --destination "files" --destination-path "stable" --source ${{ env.APPX_PACKAGE_DIR }} --overwrite true azPSVersion: "latest" - name: Logout from Azure diff --git a/scripts/Configure-AppxManifest.ps1 b/scripts/Configure-AppxManifest.ps1 index 8be687c00b42..a98eb00adca6 100644 --- a/scripts/Configure-AppxManifest.ps1 +++ b/scripts/Configure-AppxManifest.ps1 @@ -3,7 +3,7 @@ param( [string]$Branch = "", - [string]$PackageProjectDir = "", + [string]$PackageManifestPath = "", [string]$Publisher = "", [string]$WorkingDir = "", [string]$SecretBingMapsKey = "", @@ -11,7 +11,7 @@ param( [string]$SecretGitHubOAuthClientId = "" ) -[xml]$xmlDoc = Get-Content "$PackageProjectDir\Package.appxmanifest" +[xml]$xmlDoc = Get-Content "$PackageManifestPath" $xmlDoc.Package.Identity.Publisher="$Publisher" if ($Branch -eq "Preview") @@ -21,10 +21,10 @@ if ($Branch -eq "Preview") $xmlDoc.Package.Properties.DisplayName="Files - Preview" $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview" - Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process - { - (Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | - Set-Content $_ -NoNewline + Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process ` + { ` + (Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | ` + Set-Content $_ -NoNewline ` } } elseif ($Branch -eq "Stable") @@ -34,10 +34,10 @@ elseif ($Branch -eq "Stable") $xmlDoc.Package.Properties.DisplayName="Files" $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files" - Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process - { - (Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | - Set-Content $_ -NoNewline + Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process ` + { ` + (Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | ` + Set-Content $_ -NoNewline ` } } elseif ($Branch -eq "Store") @@ -54,29 +54,29 @@ elseif ($Branch -eq "Store") $pm = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']", $nsmgr) $xmlDoc.Package.Capabilities.RemoveChild($pm) - Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process - { - (Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | - Set-Content $_ -NoNewline + Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process ` + { ` + (Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | ` + Set-Content $_ -NoNewline ` } } -$xmlDoc.Save("$PackageProjectDir\Package.appxmanifest") +$xmlDoc.Save("$PackageManifestPath") -Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process -{ - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) | - Set-Content $_ -NoNewline +Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process ` +{ ` + (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) | ` + Set-Content $_ -NoNewline ` } -Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process +Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process ` { - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "sentry.secret", "$SecretSentry" }) | - Set-Content $_ -NoNewline + (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "sentry.secret", "$SecretSentry" }) | ` + Set-Content $_ -NoNewline ` } -Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process -{ - (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$SecretGitHubOAuthClientId" }) | - Set-Content $_ -NoNewline +Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process ` +{ ` + (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$SecretGitHubOAuthClientId" }) | ` + Set-Content $_ -NoNewline ` } From 2faea371605a3b50c3062fde2b748957233ef323 Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 3 Jul 2024 22:59:45 +0900 Subject: [PATCH 2/3] Update --- .github/workflows/cd-preview.yml | 2 +- .github/workflows/cd-stable.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd-preview.yml b/.github/workflows/cd-preview.yml index f163500ad2b1..dad88347378a 100644 --- a/.github/workflows/cd-preview.yml +++ b/.github/workflows/cd-preview.yml @@ -86,7 +86,7 @@ jobs: -p:Configuration=$env:CONFIGURATION ` -p:PublishReadyToRun=true - - name: Build Files + - name: Build & package Files shell: pwsh run: | msbuild "$env:PACKAGE_PROJECT_PATH" ` diff --git a/.github/workflows/cd-stable.yml b/.github/workflows/cd-stable.yml index 7ff9bdefb0af..57c545a26dd9 100644 --- a/.github/workflows/cd-stable.yml +++ b/.github/workflows/cd-stable.yml @@ -86,7 +86,7 @@ jobs: -p:Configuration=$env:CONFIGURATION ` -p:PublishReadyToRun=true - - name: Build & oackage Files + - name: Build & package Files shell: pwsh run: | msbuild "$env:PACKAGE_PROJECT_PATH" ` From d042001165e347ea4b4de66d5351d32a2111f03c Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 3 Jul 2024 23:03:15 +0900 Subject: [PATCH 3/3] Update --- .github/workflows/cd-stable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd-stable.yml b/.github/workflows/cd-stable.yml index 57c545a26dd9..b2cc57311864 100644 --- a/.github/workflows/cd-stable.yml +++ b/.github/workflows/cd-stable.yml @@ -113,7 +113,7 @@ jobs: $fileContent = $fileContent.Replace("http://schemas.microsoft.com/appx/appinstaller/2017/2", $newSchema) $fileContent | Set-Content $localFilePath - - name: Sign files with Azure Trusted Signing + - name: Sign Files with Azure Trusted Signing uses: azure/trusted-signing-action@v0.3.16 with: azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}