Skip to content

Commit 6a99c9e

Browse files
committed
Init
1 parent edeba89 commit 6a99c9e

File tree

4 files changed

+355
-112
lines changed

4 files changed

+355
-112
lines changed

.github/scripts/Build-AppSolution.ps1

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Copyright (c) Files Community
2+
# Licensed under the MIT License.
3+
4+
param(
5+
[string]$ReleaseBranch = "Debug", # Debug, Release, SideloadPreview, SideloadStable, StorePreview, or StoreStable
6+
[string]$SolutionPath = "Files.slnx",
7+
[string]$StartupProjectPath = "",
8+
[string]$Platform = "x64",
9+
[string]$Configuration = "Debug",
10+
[string]$AppxBundlePlatforms = "x64|arm64",
11+
[string]$AppxPackageDir = "",
12+
[string]$AppInstallerUrl = "", # Sideload only
13+
[string]$AppxPackageCertKeyFile = "" # Debug only
14+
)
15+
16+
# Restore the solution
17+
msbuild $SolutionPath /t:Restore /p:Platform=$Platform /p:Configuration=$Configuration /p:PublishReadyToRun=true
18+
19+
if ($ReleaseBranch -eq "Debug")
20+
{
21+
msbuild $StartupProjectPath `
22+
/t:Build `
23+
/clp:ErrorsOnly `
24+
/p:Platform=$Platform `
25+
/p:Configuration=$Configuration `
26+
/p:AppxBundle=Never `
27+
/v:quiet
28+
}
29+
elseif ($ReleaseBranch -eq "Release")
30+
{
31+
if ($Platform -eq "x64")
32+
{
33+
msbuild $StartupProjectPath `
34+
/t:Build `
35+
/clp:ErrorsOnly `
36+
/p:Platform=$Platform `
37+
/p:Configuration=$Configuration `
38+
/p:AppxBundlePlatforms=$Platform `
39+
/p:AppxBundle=Always `
40+
/p:UapAppxPackageBuildMode=SideloadOnly `
41+
/p:AppxPackageDir=$AppxPackageDir `
42+
/p:AppxPackageSigningEnabled=true `
43+
/p:PackageCertificateKeyFile=$AppxPackageCertKeyFile `
44+
/p:PackageCertificatePassword="" `
45+
/p:PackageCertificateThumbprint="" `
46+
/v:quiet
47+
}
48+
else
49+
{
50+
msbuild $StartupProjectPath `
51+
/t:Build `
52+
/clp:ErrorsOnly `
53+
/p:Platform=$Platform `
54+
/p:Configuration=$Configuration `
55+
/p:AppxBundle=Never `
56+
/v:quiet
57+
}
58+
}
59+
elseif ($ReleaseBranch -contains "Sideload")
60+
{
61+
msbuild $StartupProjectPath `
62+
/t:Build `
63+
/t:_GenerateAppxPackage `
64+
/clp:ErrorsOnly `
65+
/p:Platform=$Platform `
66+
/p:Configuration=$Configuration `
67+
/p:AppxBundlePlatforms=$AppxBundlePlatforms `
68+
/p:AppxPackageDir=$AppxPackageDir `
69+
/p:AppxBundle=Always `
70+
/p:UapAppxPackageBuildMode=Sideload `
71+
/p:GenerateAppInstallerFile=True `
72+
/p:AppInstallerUri=$AppInstallerUrl `
73+
/v:quiet
74+
75+
$newSchema = 'http://schemas.microsoft.com/appx/appinstaller/2018'
76+
$localFilePath = '$AppxPackageDir/Files.Package.appinstaller'
77+
$fileContent = Get-Content $localFilePath
78+
$fileContent = $fileContent.Replace('http://schemas.microsoft.com/appx/appinstaller/2017/2', $newSchema)
79+
$fileContent | Set-Content $localFilePath
80+
}
81+
elseif ($ReleaseBranch -contains "Store")
82+
{
83+
msbuild $StartupProjectPath `
84+
/t:Build `
85+
/t:_GenerateAppxPackage `
86+
/clp:ErrorsOnly `
87+
/p:Platform=$Platform `
88+
/p:Configuration=$Configuration `
89+
/p:AppxBundlePlatforms=$AppxBundlePlatforms `
90+
/p:AppxPackageDir=$AppxPackageDir `
91+
/p:AppxBundle=Always `
92+
/p:UapAppxPackageBuildMode=StoreUpload `
93+
/v:quiet
94+
}

.github/scripts/Configure-AppxManifest.ps1

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# Licensed under the MIT License.
33

44
param(
5-
[string]$Branch = "", # This has to correspond with one of the AppEnvironment enum values
6-
[string]$PackageManifestPath = "",
7-
[string]$Publisher = "",
8-
[string]$WorkingDir = "",
9-
[string]$SecretBingMapsKey = "",
10-
[string]$SecretSentry = "",
5+
[string]$ReleaseBranch = "", # SideloadPreview, SideloadStable, StorePreview, or StoreStable
6+
[string]$PackageManifestPath = "",
7+
[string]$Publisher = "",
8+
[string]$WorkingDir = "",
9+
[string]$SecretBingMapsKey = "",
10+
[string]$SecretSentry = "",
1111
[string]$SecretGitHubOAuthClientId = ""
1212
)
1313

@@ -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 "SideloadPreview")
30+
if ($ReleaseBranch -eq "SideloadPreview")
3131
{
3232
# Set identities
3333
$xmlDoc.Package.Identity.Name="FilesPreview"
@@ -54,7 +54,7 @@ if ($Branch -eq "SideloadPreview")
5454
Set-Content $_ -NoNewline `
5555
}
5656
}
57-
elseif ($Branch -eq "StorePreview")
57+
elseif ($ReleaseBranch -eq "StorePreview")
5858
{
5959
# Set identities
6060
$xmlDoc.Package.Identity.Name="49306atecsolution.FilesPreview"
@@ -87,7 +87,7 @@ elseif ($Branch -eq "StorePreview")
8787
Set-Content $_ -NoNewline `
8888
}
8989
}
90-
elseif ($Branch -eq "SideloadStable")
90+
elseif ($ReleaseBranch -eq "SideloadStable")
9191
{
9292
# Set identities
9393
$xmlDoc.Package.Identity.Name="Files"
@@ -114,7 +114,7 @@ elseif ($Branch -eq "SideloadStable")
114114
Set-Content $_ -NoNewline `
115115
}
116116
}
117-
elseif ($Branch -eq "StoreStable")
117+
elseif ($ReleaseBranch -eq "StoreStable")
118118
{
119119
# Set identities
120120
$xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP"
@@ -148,7 +148,7 @@ elseif ($Branch -eq "StoreStable")
148148

149149
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
150150
{ `
151-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $Branch }) | `
151+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $ReleaseBranch }) | `
152152
Set-Content $_ -NoNewline `
153153
}
154154

.github/workflows/cd.yml

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# Copyright (c) Files Community
2+
# Licensed under the MIT License.
3+
4+
# Abstract:
5+
# Deploys Files to either Sideload or Store.
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 if sideloading
11+
# 4. Sign the package if sideloading
12+
# 5. Publish the package to either Azure or Microsoft Developer Center
13+
14+
name: Files CD
15+
16+
on:
17+
workflow_dispatch:
18+
inputs:
19+
build-branch:
20+
type: choice
21+
description: Build branch
22+
options:
23+
- 'Preview'
24+
- 'Stable'
25+
default: 'Preview'
26+
publish-to-store:
27+
type: boolean
28+
description: Publish to Store as well
29+
default: 'true'
30+
31+
env:
32+
CONFIGURATION: 'Release'
33+
PLATFORM: 'x64'
34+
APPX_BUNDLE_PLATFORMS: 'x64|arm64'
35+
WORKING_DIR: '${{ github.workspace }}' # D:\a\Files\Files\
36+
SOLUTION_PATH: '${{ github.workspace }}\Files.slnx'
37+
ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts'
38+
APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages'
39+
PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\Files.App (Package)'
40+
PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\Files.App (Package)\Files.Package.wapproj'
41+
PACKAGE_MANIFEST_PATH: '${{ github.workspace }}\src\Files.App (Package)\Package.appxmanifest'
42+
43+
jobs:
44+
sideload:
45+
runs-on: windows-latest
46+
environment: Deployments
47+
strategy:
48+
fail-fast: false
49+
env:
50+
# This is either SideloadPreview or SideloadStable
51+
RELEASE_BRANCH: 'Sideload${{ github.event.inputs.build-branch }}'
52+
53+
steps:
54+
- name: Checkout the repository
55+
uses: actions/checkout@v4
56+
- name: Setup MSBuild
57+
uses: microsoft/setup-msbuild@v2
58+
- name: Setup NuGet
59+
uses: NuGet/setup-nuget@v2
60+
- name: Setup .NET 8
61+
uses: actions/setup-dotnet@v4
62+
with:
63+
global-json-file: global.json
64+
65+
- name: Get sideload appinstaller URL
66+
id: tolowercase
67+
uses: ASzc/change-string-case-action@v6
68+
with:
69+
string: ${{ github.event.inputs.build-branch }}
70+
71+
- name: Build Files
72+
run: |
73+
. './.github/scripts/Configure-AppxManifest.ps1' `
74+
-ReleaseBranch "$env:RELEASE_BRANCH" `
75+
-PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" `
76+
-WorkingDir "$env:WORKING_DIR" `
77+
-Publisher "$env:SECRET_PUBLISHER_NAME" `
78+
-SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" `
79+
-SecretSentry "$env:SECRET_SENTRY" `
80+
-SecretGitHubOAuthClientId "$env:SECRET_GH_OAUTH_CLIENT_ID"
81+
. './.github/scripts/Build-AppSolution.ps1' `
82+
-ReleaseBranch "$env:RELEASE_BRANCH" `
83+
-SolutionPath "$env:SOLUTION_PATH" `
84+
-StartupProjectPath "$env:PACKAGE_PROJECT_PATH" `
85+
-Configuration "$env:CONFIGURATION" `
86+
-Platform "$env:PLATFORM" `
87+
-AppxPackageDir "$env:APPX_PACKAGE_DIR" `
88+
-AppInstallerUrl "$env:APP_INSTALLER_SIDELOAD_URL"
89+
env:
90+
SECRET_PUBLISHER_NAME: ${{ secrets.SIDELOAD_PUBLISHER_SECRET }}
91+
SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }}
92+
SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }}
93+
SECRET_GH_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }}
94+
APP_INSTALLER_SIDELOAD_URL: "https://cdn.files.community/files/${{ steps.tolowercase.outputs.lowercase }}/"
95+
96+
- name: Sign Files with Azure Trusted Signing
97+
uses: azure/[email protected]
98+
with:
99+
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
100+
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
101+
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
102+
endpoint: https://eus.codesigning.azure.net/
103+
trusted-signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }}
104+
certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }}
105+
files-folder: ${{ env.APPX_PACKAGE_DIR }}
106+
files-folder-filter: msixbundle
107+
files-folder-recurse: true
108+
files-folder-depth: 4
109+
file-digest: SHA256
110+
timestamp-rfc3161: http://timestamp.acs.microsoft.com
111+
timestamp-digest: SHA256
112+
113+
- name: Login to Azure
114+
uses: azure/login@v2
115+
with:
116+
creds: ${{ secrets.AZURE_CREDENTIALS }}
117+
118+
- name: Upload to Azure blob storage
119+
run: |
120+
az storage blob upload-batch `
121+
--account-name "filescommunity" `
122+
--destination "files" `
123+
--destination-path "${{ github.event.inputs.build-branch }}" `
124+
--source "${{ env.APPX_PACKAGE_DIR }}" `
125+
--overwrite true
126+
az logout
127+
128+
- name: Upload the packages to GitHub Actions
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: 'Appx Packages (${{ env.RELEASE_BRANCH }})'
132+
path: ${{ env.ARTIFACTS_STAGING_DIR }}
133+
134+
store:
135+
136+
if: ${{ github.event.inputs.publish-to-store }}
137+
138+
runs-on: windows-latest
139+
environment: Deployments
140+
strategy:
141+
fail-fast: false
142+
env:
143+
# This is either StorePreview or StoreStable
144+
RELEASE_BRANCH: 'Store${{ github.event.inputs.build-branch }}'
145+
146+
steps:
147+
- name: Checkout the repository
148+
uses: actions/checkout@v4
149+
- name: Setup MSBuild
150+
uses: microsoft/setup-msbuild@v2
151+
- name: Setup NuGet
152+
uses: NuGet/setup-nuget@v2
153+
- name: Setup .NET 8
154+
uses: actions/setup-dotnet@v4
155+
with:
156+
global-json-file: global.json
157+
158+
- name: Build Files
159+
run: |
160+
. './.github/scripts/Configure-AppxManifest.ps1' `
161+
-ReleaseBranch "$env:RELEASE_BRANCH" `
162+
-PackageManifestPath "$env:PACKAGE_MANIFEST_PATH" `
163+
-WorkingDir "$env:WORKING_DIR" `
164+
-Publisher "$env:SECRET_PUBLISHER_NAME" `
165+
-SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" `
166+
-SecretSentry "$env:SECRET_SENTRY" `
167+
-SecretGitHubOAuthClientId "$env:SECRET_GH_OAUTH_CLIENT_ID"
168+
. './.github/scripts/Build-AppSolution.ps1' `
169+
-ReleaseBranch "$env:RELEASE_BRANCH" `
170+
-SolutionPath "$env:SOLUTION_PATH" `
171+
-StartupProjectPath "$env:PACKAGE_PROJECT_PATH" `
172+
-Configuration "$env:CONFIGURATION" `
173+
-Platform "$env:PLATFORM" `
174+
-AppxPackageDir "$env:APPX_PACKAGE_DIR"
175+
env:
176+
SECRET_PUBLISHER_NAME: ${{ secrets.STORE_PUBLISHER_SECRET }}
177+
SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }}
178+
SECRET_SENTRY: ${{ secrets.SENTRY_SECRET }}
179+
SECRET_GH_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }}
180+
181+
- name: Publish the packages to Microsoft Store
182+
uses: isaacrlevin/windows-store-action@1
183+
with:
184+
app-id: '9NGHP3DX8HDX'
185+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
186+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
187+
client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
188+
package-path: '${{ env.ARTIFACTS_STAGING_DIR }}/**/*.msixupload'
189+
skip-polling: false
190+
packages-keep: 5
191+
192+
- name: Upload the packages to GitHub Actions
193+
uses: actions/upload-artifact@v4
194+
with:
195+
name: 'Appx Packages (${{ env.RELEASE_BRANCH }})'
196+
path: ${{ env.ARTIFACTS_STAGING_DIR }}

0 commit comments

Comments
 (0)