Skip to content

Commit

Permalink
GitHub: Added GitHub action to deploy to preview
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 committed Nov 2, 2023
1 parent d8508d3 commit 20e04d0
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 8 deletions.
171 changes: 171 additions & 0 deletions .github/workflows/deploy-preview.yml
@@ -0,0 +1,171 @@
name: Deploy Preview Pipeline

on:
workflow_dispatch:

jobs:
build:
runs-on: windows-latest
environment: Deployments
strategy:
fail-fast: false
matrix:
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

steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1

- name: Setup NuGet
uses: NuGet/[email protected]

- name: Setup .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'

# TODO: Move the command to PowerShell script instead
- name: Update Package.appxmanifest
shell: pwsh
run: |
[xml]$xmlDoc = Get-Content "$env:PACKAGE_PROJECT_DIR\Package.appxmanifest"
$xmlDoc.Package.Identity.Name="FilesPreview"
$xmlDoc.Package.Identity.Publisher="$env:SIDELOAD_PUBLISHER_SECRET"
$xmlDoc.Package.Properties.DisplayName="Files - Preview"
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview"
$xmlDoc.Save("$env:PACKAGE_PROJECT_DIR\Package.appxmanifest")
env:
SIDELOAD_PUBLISHER_SECRET: ${{ secrets.SIDELOAD_PUBLISHER_SECRET }}

# TODO: Move the command to PowerShell script instead
- name: Use the ${{ env.CONFIGURATION }} logo sets
shell: pwsh
run: |
Get-ChildItem "$env:WORKING_DIR\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process `
{ `
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | `
Set-Content $_ -NoNewline `
}
- name: Inject the Bing Maps API token
shell: pwsh
run: |
Get-ChildItem "$env:WORKING_DIR\src" -Include *.cs -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$env:BING_MAPS_SECRET" }) | `
Set-Content $_ -NoNewline `
}
env:
BING_MAPS_SECRET: ${{ secrets.BING_MAPS_SECRET }}

- name: Inject the AppCenter token
shell: pwsh
run: |
Get-ChildItem "$env:WORKING_DIR\src" -Include *.cs -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "appcenter.secret", "$env:APP_CENTER_SECRET" }) | `
Set-Content $_ -NoNewline `
}
env:
APP_CENTER_SECRET: ${{ secrets.APP_CENTER_SECRET }}

- name: Inject the GitHub OAuth client ID
run: |
Get-ChildItem "$env:WORKING_DIR\src" -Include *.cs -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$env:GH_OAUTH_CLIENT_ID" }) | `
Set-Content $_ -NoNewline `
}
env:
GH_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }}

- name: Use Windows SDK Preview
shell: cmd
run: |
for /f %%a in ('dir /b /a:d %localappdata%\Microsoft\VisualStudio\17*') do echo UsePreviews=True>%localappdata%\Microsoft\VisualStudio\%%a\sdk.txt
- name: Restore NuGet
shell: pwsh
run: 'nuget restore $env:SOLUTION_NAME'

- name: Restore ${{ env.SOLUTION_NAME }}
shell: pwsh
run: |
msbuild $env:SOLUTION_NAME `
-t:Restore `
-p:Platform=$env:PLATFORM `
-p:Configuration=$env:CONFIGURATION `
-p:PublishReadyToRun=true
- name: Build ${{ env.SOLUTION_NAME }}
shell: pwsh
run: |
msbuild "$env:PACKAGE_PROJECT_PATH" `
-t:Build `
-t:_GenerateAppxPackage `
-p:Platform=$env:PLATFORM `
-p:Configuration=$env:CONFIGURATION `
-p:AppxBundlePlatforms=$env:APPX_BUNDLE_PLATFORMS `
-p:AppxPackageDir="$env:APPX_PACKAGE_DIR" `
-p:AppxBundle=Always `
-p:UapAppxPackageBuildMode=Sideload `
-p:GenerateAppInstallerFile=True `
-p:AppInstallerUri=https://cdn.files.community/files/preview/
- name: Remove empty files from the packages
shell: bash
run: find $ARTIFACTS_STAGING_DIR -empty -delete

- name: Sign files with Azure Code Signing
uses: azure/[email protected]
with:
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
endpoint: https://wus2.codesigning.azure.net/
code-signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }}
certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }}
files-folder: ${{ env.APPX_PACKAGE_DIR }}
files-folder-filter: msixbundle
files-folder-recurse: true
files-folder-depth: 4
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256

- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Upload to blob storage
uses: azure/powershell@v1
with:
inlineScript: |
az storage blob upload-batch --account-name "filescommunity" --destination "files" --destination-path "test" --source ${{ env.APPX_PACKAGE_DIR }} --overwrite true
azPSVersion: "latest"

# Azure logout
- name: logout
run: |
az logout
- name: Upload the packages to GitHub Actions
uses: actions/upload-artifact@v3
with:
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})'
path: ${{ env.ARTIFACTS_STAGING_DIR }}
5 changes: 5 additions & 0 deletions src/Files.App (Package)/Files.Package.wapproj
Expand Up @@ -85,24 +85,29 @@
<Platform>x86</Platform>
</ProjectConfiguration>
</ItemGroup>

<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
<PathToXAMLWinRTImplementations>Files.App\</PathToXAMLWinRTImplementations>
</PropertyGroup>

<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />

<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets\AppTiles\Dev\**" />
<Content Include="Package.appinstaller" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Files.App\Files.App.csproj">
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
</ProjectReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.231008000" IncludeAssets="build" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" IncludeAssets="build" />
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Files.App.csproj
Expand Up @@ -49,7 +49,6 @@
<Link>NOTICE.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\BingMapsKey.txt" />
<Content Include="Resources\PreviewPanePropertiesInformation.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
7 changes: 1 addition & 6 deletions src/Files.App/Helpers/LocationHelpers.cs
@@ -1,10 +1,8 @@
// Copyright(c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using System.Text.Json;
using Windows.Devices.Geolocation;
using Windows.Services.Maps;
using Windows.Storage;

namespace Files.App.Helpers
{
Expand All @@ -19,10 +17,7 @@ public static async Task<string> GetAddressFromCoordinatesAsync(double? Lat, dou
{
try
{
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///Resources/BingMapsKey.txt"));
var lines = await FileIO.ReadTextAsync(file);
using var obj = JsonDocument.Parse(lines);
MapService.ServiceToken = obj.RootElement.GetProperty("key").GetString();
MapService.ServiceToken = "bingmapskey.secret";
}
catch (Exception)
{
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Resources/BingMapsKey.txt

This file was deleted.

0 comments on commit 20e04d0

Please sign in to comment.