Skip to content

Commit 8eab5a2

Browse files
authored
Code Quality: Fixed the script to configure the manifest, logo and secrets (#15751)
1 parent 3aa85ee commit 8eab5a2

File tree

3 files changed

+84
-60
lines changed

3 files changed

+84
-60
lines changed

.github/workflows/cd-preview.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Copyright (c) 2024 Files Community
22
# Licensed under the MIT License. See the LICENSE.
33

4+
# Abstract:
5+
# Deploys Files Preview (Sideload).
6+
#
7+
# Workflow:
8+
# 1. Configure manifest, logo and secrets
9+
# 2. Restore, build and package Files
10+
# 3. Publish the appinstaller to files.community
11+
# 4. Sign the package
12+
# 5. Publish the package to Azure
13+
414
name: Files CD (Preview)
515

616
on:
@@ -16,16 +26,18 @@ jobs:
1626
configuration: [Preview]
1727
platform: [x64]
1828
env:
19-
SOLUTION_NAME: 'Files.sln'
20-
PACKAGE_PROJECT_DIR: 'src\Files.App (Package)'
21-
PACKAGE_PROJECT_PATH: 'src\Files.App (Package)\Files.Package.wapproj'
22-
TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj'
23-
CONFIGURATION: ${{ matrix.configuration }}
24-
PLATFORM: ${{ matrix.platform }}
25-
APPX_BUNDLE_PLATFORMS: 'x64|arm64'
26-
WORKING_DIR: ${{ github.workspace }} # Default: D:\a\Files\Files\
27-
ARTIFACTS_STAGING_DIR: ${{ github.workspace }}\artifacts
28-
APPX_PACKAGE_DIR: ${{ github.workspace }}\artifacts\AppxPackages
29+
SOLUTION_NAME: 'Files.sln'
30+
CONFIGURATION: '${{ matrix.configuration }}'
31+
PLATFORM: '${{ matrix.platform }}'
32+
APPX_BUNDLE_PLATFORMS: 'x64|arm64'
33+
WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\
34+
ARTIFACTS_STAGING_DIR: 'artifacts' # D:\a\Files\Files\artifacts\
35+
APPX_PACKAGE_DIR: 'artifacts\AppxPackages'
36+
PACKAGE_PROJECT_DIR: 'src\Files.App (Package)'
37+
PACKAGE_PROJECT_PATH: 'src\Files.App (Package)\Files.Package.wapproj'
38+
PACKAGE_MANIFEST_PATH: 'src\Files.App (Package)\Package.appxmanifest'
39+
TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj'
40+
APP_INSTALLER_SIDELOAD_URL: 'https://cdn.files.community/files/preview/'
2941

3042
steps:
3143
- name: Checkout the repository
@@ -39,12 +51,12 @@ jobs:
3951
with:
4052
dotnet-version: '8.0.x'
4153

42-
- name: Configure the package manifest, logo sets, and secrets
54+
- name: Configure the package manifest, logo, and secrets
4355
shell: pwsh
4456
run: |
4557
. './scripts/Configure-AppxManifest.ps1' `
4658
-Branch "$env:CONFIGURATION" `
47-
-PackageProjectDir "$env:PACKAGE_PROJECT_DIR" `
59+
-PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" `
4860
-Publisher "$env:SIDELOAD_PUBLISHER_SECRET" `
4961
-WorkingDir "$env:WORKING_DIR" `
5062
-SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" `
@@ -65,7 +77,7 @@ jobs:
6577
shell: pwsh
6678
run: 'nuget restore $env:SOLUTION_NAME'
6779

68-
- name: Restore ${{ env.SOLUTION_NAME }}
80+
- name: Restore Files
6981
shell: pwsh
7082
run: |
7183
msbuild $env:SOLUTION_NAME `
@@ -74,7 +86,7 @@ jobs:
7486
-p:Configuration=$env:CONFIGURATION `
7587
-p:PublishReadyToRun=true
7688
77-
- name: Build ${{ env.SOLUTION_NAME }}
89+
- name: Build & package Files
7890
shell: pwsh
7991
run: |
8092
msbuild "$env:PACKAGE_PROJECT_PATH" `
@@ -87,7 +99,7 @@ jobs:
8799
-p:AppxBundle=Always `
88100
-p:UapAppxPackageBuildMode=Sideload `
89101
-p:GenerateAppInstallerFile=True `
90-
-p:AppInstallerUri=https://cdn.files.community/files/preview/
102+
-p:AppInstallerUri=$env:APP_INSTALLER_SIDELOAD_URL
91103
92104
- name: Remove empty files from the packages
93105
shell: bash
@@ -101,7 +113,7 @@ jobs:
101113
$fileContent = $fileContent.Replace("http://schemas.microsoft.com/appx/appinstaller/2017/2", $newSchema)
102114
$fileContent | Set-Content $localFilePath
103115
104-
- name: Sign files with Azure Trusted Signing
116+
- name: Sign Files with Azure Trusted Signing
105117
uses: azure/trusted-signing-action@v0.3.16
106118
with:
107119
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}

.github/workflows/cd-stable.yml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Copyright (c) 2024 Files Community
22
# Licensed under the MIT License. See the LICENSE.
33

4+
# Abstract:
5+
# Deploys Files (Sideload).
6+
#
7+
# Workflow:
8+
# 1. Configure manifest, logo and secrets
9+
# 2. Restore, build and package Files
10+
# 3. Publish the appinstaller to files.community
11+
# 4. Sign the package
12+
# 5. Publish the package to Azure
13+
414
name: Files CD (Stable)
515

616
on:
@@ -16,16 +26,18 @@ jobs:
1626
configuration: [Stable]
1727
platform: [x64]
1828
env:
19-
SOLUTION_NAME: 'Files.sln'
20-
PACKAGE_PROJECT_DIR: 'src\Files.App (Package)'
21-
PACKAGE_PROJECT_PATH: 'src\Files.App (Package)\Files.Package.wapproj'
22-
TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj'
23-
CONFIGURATION: ${{ matrix.configuration }}
24-
PLATFORM: ${{ matrix.platform }}
25-
APPX_BUNDLE_PLATFORMS: 'x64|arm64'
26-
WORKING_DIR: ${{ github.workspace }} # Default: D:\a\Files\Files\
27-
ARTIFACTS_STAGING_DIR: ${{ github.workspace }}\artifacts
28-
APPX_PACKAGE_DIR: ${{ github.workspace }}\artifacts\AppxPackages
29+
SOLUTION_NAME: 'Files.sln'
30+
CONFIGURATION: '${{ matrix.configuration }}'
31+
PLATFORM: '${{ matrix.platform }}'
32+
APPX_BUNDLE_PLATFORMS: 'x64|arm64'
33+
WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\
34+
ARTIFACTS_STAGING_DIR: 'artifacts' # D:\a\Files\Files\artifacts\
35+
APPX_PACKAGE_DIR: 'artifacts\AppxPackages'
36+
PACKAGE_PROJECT_DIR: 'src\Files.App (Package)'
37+
PACKAGE_PROJECT_PATH: 'src\Files.App (Package)\Files.Package.wapproj'
38+
PACKAGE_MANIFEST_PATH: 'src\Files.App (Package)\Package.appxmanifest'
39+
TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj'
40+
APP_INSTALLER_SIDELOAD_URL: 'https://cdn.files.community/files/stable/'
2941

3042
steps:
3143
- name: Checkout the repository
@@ -39,12 +51,12 @@ jobs:
3951
with:
4052
dotnet-version: '8.0.x'
4153

42-
- name: Configure the package manifest, logo sets, and secrets
54+
- name: Configure the package manifest, logo, and secrets
4355
shell: pwsh
4456
run: |
4557
. './scripts/Configure-AppxManifest.ps1' `
4658
-Branch "$env:CONFIGURATION" `
47-
-PackageProjectDir "$env:PACKAGE_PROJECT_DIR" `
59+
-PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" `
4860
-Publisher "$env:SIDELOAD_PUBLISHER_SECRET" `
4961
-WorkingDir "$env:WORKING_DIR" `
5062
-SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" `
@@ -65,7 +77,7 @@ jobs:
6577
shell: pwsh
6678
run: 'nuget restore $env:SOLUTION_NAME'
6779

68-
- name: Restore ${{ env.SOLUTION_NAME }}
80+
- name: Restore Files
6981
shell: pwsh
7082
run: |
7183
msbuild $env:SOLUTION_NAME `
@@ -74,7 +86,7 @@ jobs:
7486
-p:Configuration=$env:CONFIGURATION `
7587
-p:PublishReadyToRun=true
7688
77-
- name: Build ${{ env.SOLUTION_NAME }}
89+
- name: Build & package Files
7890
shell: pwsh
7991
run: |
8092
msbuild "$env:PACKAGE_PROJECT_PATH" `
@@ -87,7 +99,7 @@ jobs:
8799
-p:AppxBundle=Always `
88100
-p:UapAppxPackageBuildMode=Sideload `
89101
-p:GenerateAppInstallerFile=True `
90-
-p:AppInstallerUri=https://cdn.files.community/files/stable/
102+
-p:AppInstallerUri=$env:APP_INSTALLER_SIDELOAD_URL
91103
92104
- name: Remove empty files from the packages
93105
shell: bash
@@ -101,7 +113,7 @@ jobs:
101113
$fileContent = $fileContent.Replace("http://schemas.microsoft.com/appx/appinstaller/2017/2", $newSchema)
102114
$fileContent | Set-Content $localFilePath
103115
104-
- name: Sign files with Azure Trusted Signing
116+
- name: Sign Files with Azure Trusted Signing
105117
uses: azure/trusted-signing-action@v0.3.16
106118
with:
107119
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
@@ -121,13 +133,13 @@ jobs:
121133
- name: Login to Azure
122134
uses: azure/login@v1
123135
with:
124-
creds: ${{ secrets.AZURE_CREDENTIALS }}
136+
creds: ${{ secrets.AZURE_CREDENTIALS }}
125137

126138
- name: Upload to Azure blob storage
127139
uses: azure/powershell@v1
128140
with:
129141
inlineScript: |
130-
az storage blob upload-batch --account-name "filescommunity" --destination "files" --destination-path "stable" --source ${{ env.APPX_PACKAGE_DIR }} --overwrite true
142+
az storage blob upload-batch --account-name "filescommunity" --destination "files" --destination-path "stable" --source ${{ env.APPX_PACKAGE_DIR }} --overwrite true
131143
azPSVersion: "latest"
132144

133145
- name: Logout from Azure

scripts/Configure-AppxManifest.ps1

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
param(
55
[string]$Branch = "",
6-
[string]$PackageProjectDir = "",
6+
[string]$PackageManifestPath = "",
77
[string]$Publisher = "",
88
[string]$WorkingDir = "",
99
[string]$SecretBingMapsKey = "",
1010
[string]$SecretSentry = "",
1111
[string]$SecretGitHubOAuthClientId = ""
1212
)
1313

14-
[xml]$xmlDoc = Get-Content "$PackageProjectDir\Package.appxmanifest"
14+
[xml]$xmlDoc = Get-Content "$PackageManifestPath"
1515
$xmlDoc.Package.Identity.Publisher="$Publisher"
1616

1717
if ($Branch -eq "Preview")
@@ -21,10 +21,10 @@ if ($Branch -eq "Preview")
2121
$xmlDoc.Package.Properties.DisplayName="Files - Preview"
2222
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview"
2323

24-
Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process
25-
{
26-
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) |
27-
Set-Content $_ -NoNewline
24+
Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process `
25+
{ `
26+
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | `
27+
Set-Content $_ -NoNewline `
2828
}
2929
}
3030
elseif ($Branch -eq "Stable")
@@ -34,10 +34,10 @@ elseif ($Branch -eq "Stable")
3434
$xmlDoc.Package.Properties.DisplayName="Files"
3535
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files"
3636

37-
Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process
38-
{
39-
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) |
40-
Set-Content $_ -NoNewline
37+
Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process `
38+
{ `
39+
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
40+
Set-Content $_ -NoNewline `
4141
}
4242
}
4343
elseif ($Branch -eq "Store")
@@ -54,29 +54,29 @@ elseif ($Branch -eq "Store")
5454
$pm = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']", $nsmgr)
5555
$xmlDoc.Package.Capabilities.RemoveChild($pm)
5656

57-
Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process
58-
{
59-
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) |
60-
Set-Content $_ -NoNewline
57+
Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process `
58+
{ `
59+
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
60+
Set-Content $_ -NoNewline `
6161
}
6262
}
6363

64-
$xmlDoc.Save("$PackageProjectDir\Package.appxmanifest")
64+
$xmlDoc.Save("$PackageManifestPath")
6565

66-
Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process
67-
{
68-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) |
69-
Set-Content $_ -NoNewline
66+
Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process `
67+
{ `
68+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) | `
69+
Set-Content $_ -NoNewline `
7070
}
7171

72-
Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process
72+
Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process `
7373
{
74-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "sentry.secret", "$SecretSentry" }) |
75-
Set-Content $_ -NoNewline
74+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "sentry.secret", "$SecretSentry" }) | `
75+
Set-Content $_ -NoNewline `
7676
}
7777

78-
Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process
79-
{
80-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$SecretGitHubOAuthClientId" }) |
81-
Set-Content $_ -NoNewline
78+
Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process `
79+
{ `
80+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$SecretGitHubOAuthClientId" }) | `
81+
Set-Content $_ -NoNewline `
8282
}

0 commit comments

Comments
 (0)