Skip to content

Commit 20e04d0

Browse files
committed
GitHub: Added GitHub action to deploy to preview
1 parent d8508d3 commit 20e04d0

File tree

5 files changed

+177
-8
lines changed

5 files changed

+177
-8
lines changed

.github/workflows/deploy-preview.yml

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Deploy Preview Pipeline
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
runs-on: windows-latest
9+
environment: Deployments
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
configuration: [Preview]
14+
platform: [x64]
15+
env:
16+
SOLUTION_NAME: 'Files.sln'
17+
PACKAGE_PROJECT_DIR: 'src\Files.App (Package)'
18+
PACKAGE_PROJECT_PATH: 'src\Files.App (Package)\Files.Package.wapproj'
19+
TEST_PROJECT_PATH: 'tests\Files.InteractionTests\Files.InteractionTests.csproj'
20+
CONFIGURATION: ${{ matrix.configuration }}
21+
PLATFORM: ${{ matrix.platform }}
22+
APPX_BUNDLE_PLATFORMS: 'x64|arm64'
23+
WORKING_DIR: ${{ github.workspace }} # Default: D:\a\Files\Files\
24+
ARTIFACTS_STAGING_DIR: ${{ github.workspace }}\artifacts
25+
APPX_PACKAGE_DIR: ${{ github.workspace }}\artifacts\AppxPackages
26+
27+
steps:
28+
- name: Checkout the repository
29+
uses: actions/checkout@v3
30+
31+
- name: Setup MSBuild
32+
uses: microsoft/setup-msbuild@v1
33+
34+
- name: Setup NuGet
35+
uses: NuGet/[email protected]
36+
37+
- name: Setup .NET 7
38+
uses: actions/setup-dotnet@v3
39+
with:
40+
dotnet-version: '7.0.x'
41+
42+
# TODO: Move the command to PowerShell script instead
43+
- name: Update Package.appxmanifest
44+
shell: pwsh
45+
run: |
46+
[xml]$xmlDoc = Get-Content "$env:PACKAGE_PROJECT_DIR\Package.appxmanifest"
47+
$xmlDoc.Package.Identity.Name="FilesPreview"
48+
$xmlDoc.Package.Identity.Publisher="$env:SIDELOAD_PUBLISHER_SECRET"
49+
$xmlDoc.Package.Properties.DisplayName="Files - Preview"
50+
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview"
51+
$xmlDoc.Save("$env:PACKAGE_PROJECT_DIR\Package.appxmanifest")
52+
env:
53+
SIDELOAD_PUBLISHER_SECRET: ${{ secrets.SIDELOAD_PUBLISHER_SECRET }}
54+
55+
# TODO: Move the command to PowerShell script instead
56+
- name: Use the ${{ env.CONFIGURATION }} logo sets
57+
shell: pwsh
58+
run: |
59+
Get-ChildItem "$env:WORKING_DIR\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process `
60+
{ `
61+
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | `
62+
Set-Content $_ -NoNewline `
63+
}
64+
65+
- name: Inject the Bing Maps API token
66+
shell: pwsh
67+
run: |
68+
Get-ChildItem "$env:WORKING_DIR\src" -Include *.cs -recurse | ForEach-Object -Process `
69+
{ `
70+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$env:BING_MAPS_SECRET" }) | `
71+
Set-Content $_ -NoNewline `
72+
}
73+
env:
74+
BING_MAPS_SECRET: ${{ secrets.BING_MAPS_SECRET }}
75+
76+
- name: Inject the AppCenter token
77+
shell: pwsh
78+
run: |
79+
Get-ChildItem "$env:WORKING_DIR\src" -Include *.cs -recurse | ForEach-Object -Process `
80+
{ `
81+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "appcenter.secret", "$env:APP_CENTER_SECRET" }) | `
82+
Set-Content $_ -NoNewline `
83+
}
84+
env:
85+
APP_CENTER_SECRET: ${{ secrets.APP_CENTER_SECRET }}
86+
87+
- name: Inject the GitHub OAuth client ID
88+
run: |
89+
Get-ChildItem "$env:WORKING_DIR\src" -Include *.cs -recurse | ForEach-Object -Process `
90+
{ `
91+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$env:GH_OAUTH_CLIENT_ID" }) | `
92+
Set-Content $_ -NoNewline `
93+
}
94+
env:
95+
GH_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }}
96+
97+
- name: Use Windows SDK Preview
98+
shell: cmd
99+
run: |
100+
for /f %%a in ('dir /b /a:d %localappdata%\Microsoft\VisualStudio\17*') do echo UsePreviews=True>%localappdata%\Microsoft\VisualStudio\%%a\sdk.txt
101+
102+
- name: Restore NuGet
103+
shell: pwsh
104+
run: 'nuget restore $env:SOLUTION_NAME'
105+
106+
- name: Restore ${{ env.SOLUTION_NAME }}
107+
shell: pwsh
108+
run: |
109+
msbuild $env:SOLUTION_NAME `
110+
-t:Restore `
111+
-p:Platform=$env:PLATFORM `
112+
-p:Configuration=$env:CONFIGURATION `
113+
-p:PublishReadyToRun=true
114+
115+
- name: Build ${{ env.SOLUTION_NAME }}
116+
shell: pwsh
117+
run: |
118+
msbuild "$env:PACKAGE_PROJECT_PATH" `
119+
-t:Build `
120+
-t:_GenerateAppxPackage `
121+
-p:Platform=$env:PLATFORM `
122+
-p:Configuration=$env:CONFIGURATION `
123+
-p:AppxBundlePlatforms=$env:APPX_BUNDLE_PLATFORMS `
124+
-p:AppxPackageDir="$env:APPX_PACKAGE_DIR" `
125+
-p:AppxBundle=Always `
126+
-p:UapAppxPackageBuildMode=Sideload `
127+
-p:GenerateAppInstallerFile=True `
128+
-p:AppInstallerUri=https://cdn.files.community/files/preview/
129+
130+
- name: Remove empty files from the packages
131+
shell: bash
132+
run: find $ARTIFACTS_STAGING_DIR -empty -delete
133+
134+
- name: Sign files with Azure Code Signing
135+
uses: azure/[email protected]
136+
with:
137+
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
138+
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
139+
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
140+
endpoint: https://wus2.codesigning.azure.net/
141+
code-signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }}
142+
certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }}
143+
files-folder: ${{ env.APPX_PACKAGE_DIR }}
144+
files-folder-filter: msixbundle
145+
files-folder-recurse: true
146+
files-folder-depth: 4
147+
file-digest: SHA256
148+
timestamp-rfc3161: http://timestamp.acs.microsoft.com
149+
timestamp-digest: SHA256
150+
151+
- uses: azure/login@v1
152+
with:
153+
creds: ${{ secrets.AZURE_CREDENTIALS }}
154+
155+
- name: Upload to blob storage
156+
uses: azure/powershell@v1
157+
with:
158+
inlineScript: |
159+
az storage blob upload-batch --account-name "filescommunity" --destination "files" --destination-path "test" --source ${{ env.APPX_PACKAGE_DIR }} --overwrite true
160+
azPSVersion: "latest"
161+
162+
# Azure logout
163+
- name: logout
164+
run: |
165+
az logout
166+
167+
- name: Upload the packages to GitHub Actions
168+
uses: actions/upload-artifact@v3
169+
with:
170+
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})'
171+
path: ${{ env.ARTIFACTS_STAGING_DIR }}

src/Files.App (Package)/Files.Package.wapproj

+5
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,29 @@
8585
<Platform>x86</Platform>
8686
</ProjectConfiguration>
8787
</ItemGroup>
88+
8889
<PropertyGroup>
8990
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
9091
<PathToXAMLWinRTImplementations>Files.App\</PathToXAMLWinRTImplementations>
9192
</PropertyGroup>
93+
9294
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
95+
9396
<ItemGroup>
9497
<AppxManifest Include="Package.appxmanifest">
9598
<SubType>Designer</SubType>
9699
</AppxManifest>
97100
<Content Include="Assets\AppTiles\Dev\**" />
98101
<Content Include="Package.appinstaller" />
99102
</ItemGroup>
103+
100104
<ItemGroup>
101105
<ProjectReference Include="..\Files.App\Files.App.csproj">
102106
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
103107
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
104108
</ProjectReference>
105109
</ItemGroup>
110+
106111
<ItemGroup>
107112
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.231008000" IncludeAssets="build" />
108113
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" IncludeAssets="build" />

src/Files.App/Files.App.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
<Link>NOTICE.md</Link>
5050
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
5151
</Content>
52-
<Content Include="Resources\BingMapsKey.txt" />
5352
<Content Include="Resources\PreviewPanePropertiesInformation.json">
5453
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
5554
</Content>

src/Files.App/Helpers/LocationHelpers.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// Copyright(c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using System.Text.Json;
54
using Windows.Devices.Geolocation;
65
using Windows.Services.Maps;
7-
using Windows.Storage;
86

97
namespace Files.App.Helpers
108
{
@@ -19,10 +17,7 @@ public static async Task<string> GetAddressFromCoordinatesAsync(double? Lat, dou
1917
{
2018
try
2119
{
22-
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///Resources/BingMapsKey.txt"));
23-
var lines = await FileIO.ReadTextAsync(file);
24-
using var obj = JsonDocument.Parse(lines);
25-
MapService.ServiceToken = obj.RootElement.GetProperty("key").GetString();
20+
MapService.ServiceToken = "bingmapskey.secret";
2621
}
2722
catch (Exception)
2823
{

src/Files.App/Resources/BingMapsKey.txt

-1
This file was deleted.

0 commit comments

Comments
 (0)