Skip to content

Commit 07268dc

Browse files
authored
Code Quality: Added Store Preview configuration (#16566)
1 parent 6dbe887 commit 07268dc

File tree

24 files changed

+213
-391
lines changed

24 files changed

+213
-391
lines changed

.github/scripts/Configure-AppxManifest.ps1

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT License. See the LICENSE.
33

44
param(
5-
[string]$Branch = "",
5+
[string]$Branch = "", # This has to correspond with one of the AppEnvironment enum values
66
[string]$PackageManifestPath = "",
77
[string]$Publisher = "",
88
[string]$WorkingDir = "",
@@ -27,7 +27,7 @@ $ea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pk
2727
# Update the publisher
2828
$xmlDoc.Package.Identity.Publisher = $Publisher
2929

30-
if ($Branch -eq "Preview")
30+
if ($Branch -eq "SideloadPreview")
3131
{
3232
# Set identities
3333
$xmlDoc.Package.Identity.Name="FilesPreview"
@@ -54,7 +54,34 @@ if ($Branch -eq "Preview")
5454
Set-Content $_ -NoNewline `
5555
}
5656
}
57-
elseif ($Branch -eq "Stable")
57+
elseif ($Branch -eq "StorePreview")
58+
{
59+
# Set identities
60+
$xmlDoc.Package.Identity.Name="49306atecsolution.FilesPreview"
61+
$xmlDoc.Package.Properties.DisplayName="Files - Preview"
62+
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview"
63+
$xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="49306atecsolution.FilesPreview"
64+
65+
# Remove capability that is only used for the sideload package
66+
$nsmgr = New-Object System.Xml.XmlNamespaceManager($xmlDoc.NameTable)
67+
$nsmgr.AddNamespace("pkg", "http://schemas.microsoft.com/appx/manifest/foundation/windows10")
68+
$nsmgr.AddNamespace("rescap", "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities")
69+
$pm = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']", $nsmgr)
70+
$xmlDoc.Package.Capabilities.RemoveChild($pm)
71+
72+
# Update app protocol and execution alias
73+
$ap.SetAttribute("Name", "files-preview");
74+
$ea.SetAttribute("Alias", "files-preview.exe");
75+
76+
$xmlDoc.Save($PackageManifestPath)
77+
78+
Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
79+
{ `
80+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | `
81+
Set-Content $_ -NoNewline `
82+
}
83+
}
84+
elseif ($Branch -eq "SideloadStable")
5885
{
5986
# Set identities
6087
$xmlDoc.Package.Identity.Name="Files"
@@ -81,7 +108,7 @@ elseif ($Branch -eq "Stable")
81108
Set-Content $_ -NoNewline `
82109
}
83110
}
84-
elseif ($Branch -eq "Store")
111+
elseif ($Branch -eq "StoreStable")
85112
{
86113
# Set identities
87114
$xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP"
@@ -113,6 +140,12 @@ elseif ($Branch -eq "Store")
113140
}
114141
}
115142

143+
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
144+
{ `
145+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $Branch }) | `
146+
Set-Content $_ -NoNewline `
147+
}
148+
116149
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
117150
{ `
118151
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) | `

.github/workflows/cd-preview.yml renamed to .github/workflows/cd-sideload-preview.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# 4. Sign the package
1212
# 5. Publish the package to Azure
1313

14-
name: Files CD (Preview)
14+
name: Files CD (Sideload Preview)
1515

1616
on:
1717
workflow_dispatch:
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
configuration: [Preview]
26+
configuration: [Release]
2727
platform: [x64]
2828
env:
2929
SOLUTION_NAME: 'Files.sln'
@@ -55,7 +55,7 @@ jobs:
5555
shell: pwsh
5656
run: |
5757
. './.github/scripts/Configure-AppxManifest.ps1' `
58-
-Branch "$env:CONFIGURATION" `
58+
-Branch "SideloadPreview" `
5959
-PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" `
6060
-Publisher "$env:SIDELOAD_PUBLISHER_SECRET" `
6161
-WorkingDir "$env:WORKING_DIR" `

.github/workflows/cd-stable.yml renamed to .github/workflows/cd-sideload-stable.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# 4. Sign the package
1212
# 5. Publish the package to Azure
1313

14-
name: Files CD (Stable)
14+
name: Files CD (Sideload Stable)
1515

1616
on:
1717
workflow_dispatch:
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
configuration: [Stable]
26+
configuration: [Release]
2727
platform: [x64]
2828
env:
2929
SOLUTION_NAME: 'Files.sln'
@@ -55,7 +55,7 @@ jobs:
5555
shell: pwsh
5656
run: |
5757
. './.github/scripts/Configure-AppxManifest.ps1' `
58-
-Branch "$env:CONFIGURATION" `
58+
-Branch "SideloadStable" `
5959
-PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" `
6060
-Publisher "$env:SIDELOAD_PUBLISHER_SECRET" `
6161
-WorkingDir "$env:WORKING_DIR" `
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Copyright (c) 2024 Files Community
2+
# Licensed under the MIT License. See the LICENSE.
3+
4+
# Abstract:
5+
# Deploys Files Preview (Store).
6+
#
7+
# Workflow:
8+
# 1. Configure manifest, logo and secrets
9+
# 2. Restore, build and package Files
10+
# 3. Generate a msixupload file
11+
# 4. Publish the msixupload to GitHub Actions
12+
13+
name: Files CD (Store Preview)
14+
15+
on:
16+
workflow_dispatch:
17+
18+
jobs:
19+
build:
20+
runs-on: windows-latest
21+
environment: Deployments
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
configuration: [Release]
26+
platform: [x64]
27+
env:
28+
SOLUTION_NAME: 'Files.sln'
29+
CONFIGURATION: '${{ matrix.configuration }}'
30+
PLATFORM: '${{ matrix.platform }}'
31+
APPX_BUNDLE_PLATFORMS: 'x64|arm64'
32+
WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\
33+
ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts'
34+
APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages'
35+
PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\Files.App (Package)'
36+
PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\Files.App (Package)\Files.Package.wapproj'
37+
PACKAGE_MANIFEST_PATH: '${{ github.workspace }}\src\Files.App (Package)\Package.appxmanifest'
38+
39+
steps:
40+
- name: Checkout the repository
41+
uses: actions/checkout@v4
42+
- name: Setup MSBuild
43+
uses: microsoft/setup-msbuild@v2
44+
- name: Setup NuGet
45+
uses: NuGet/setup-nuget@v2
46+
- name: Setup .NET 8
47+
uses: actions/setup-dotnet@v4
48+
with:
49+
global-json-file: global.json
50+
51+
- name: Configure the package manifest, logo, and secrets
52+
shell: pwsh
53+
run: |
54+
. './.github/scripts/Configure-AppxManifest.ps1' `
55+
-Branch "StorePreview" `
56+
-PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" `
57+
-Publisher "$env:STORE_PUBLISHER_SECRET" `
58+
-WorkingDir "$env:WORKING_DIR" `
59+
-SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" `
60+
-SecretSentry "$env:SECRET_SENTRY" `
61+
-SecretGitHubOAuthClientId "$env:SECRET_GITHUB_OAUTH_CLIENT_ID"
62+
env:
63+
STORE_PUBLISHER_SECRET: ${{ secrets.STORE_PUBLISHER_SECRET }}
64+
SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }}
65+
SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }}
66+
SECRET_GITHUB_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }}
67+
68+
- name: Use Windows SDK Preview
69+
shell: cmd
70+
run: |
71+
for /f %%a in ('dir /b /a:d %localappdata%\Microsoft\VisualStudio\17*') do echo UsePreviews=True>%localappdata%\Microsoft\VisualStudio\%%a\sdk.txt
72+
73+
- name: Restore NuGet
74+
shell: pwsh
75+
run: 'nuget restore $env:SOLUTION_NAME'
76+
77+
- name: Restore Files
78+
shell: pwsh
79+
run: |
80+
msbuild $env:SOLUTION_NAME `
81+
-t:Restore `
82+
-p:Platform=$env:PLATFORM `
83+
-p:Configuration=$env:CONFIGURATION `
84+
-p:PublishReadyToRun=true
85+
86+
- name: Build & package Files
87+
shell: pwsh
88+
run: |
89+
msbuild "$env:PACKAGE_PROJECT_PATH" `
90+
-t:Build `
91+
-t:_GenerateAppxPackage `
92+
-p:Platform=$env:PLATFORM `
93+
-p:Configuration=$env:CONFIGURATION `
94+
-p:AppxBundlePlatforms=$env:APPX_BUNDLE_PLATFORMS `
95+
-p:AppxPackageDir="$env:APPX_PACKAGE_DIR" `
96+
-p:AppxBundle=Always `
97+
-p:UapAppxPackageBuildMode=StoreUpload
98+
99+
- name: Remove empty files from the packages
100+
shell: bash
101+
run: find $ARTIFACTS_STAGING_DIR -empty -delete
102+
103+
- name: Upload the packages to GitHub Actions
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})'
107+
path: ${{ env.ARTIFACTS_STAGING_DIR }}

.github/workflows/cd-store.yml renamed to .github/workflows/cd-store-stable.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# 3. Generate a msixupload file
1111
# 4. Publish the msixupload to GitHub Actions
1212

13-
name: Files CD (Store)
13+
name: Files CD (Store Stable)
1414

1515
on:
1616
workflow_dispatch:
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
configuration: [Store]
25+
configuration: [Release]
2626
platform: [x64]
2727
env:
2828
SOLUTION_NAME: 'Files.sln'
@@ -52,7 +52,7 @@ jobs:
5252
shell: pwsh
5353
run: |
5454
. './.github/scripts/Configure-AppxManifest.ps1' `
55-
-Branch "$env:CONFIGURATION" `
55+
-Branch "StoreStable" `
5656
-PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" `
5757
-Publisher "$env:STORE_PUBLISHER_SECRET" `
5858
-WorkingDir "$env:WORKING_DIR" `

0 commit comments

Comments
 (0)