Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub: Added ps1 scripts to simplify CI/CD #15030

Merged
merged 27 commits into from Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
72 changes: 17 additions & 55 deletions .github/workflows/deploy-preview.yml
0x5bfa marked this conversation as resolved.
Show resolved Hide resolved
@@ -1,4 +1,7 @@
name: Deploy Preview Pipeline
# Copyright (c) 2024 Files Community
# Licensed under the MIT License. See the LICENSE.

name: Files Deployment (Preview)

on:
workflow_dispatch:
Expand Down Expand Up @@ -27,71 +30,30 @@ jobs:
steps:
- name: Checkout the repository
uses: actions/checkout@v4

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

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

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

# TODO: Move the command to PowerShell script instead
- name: Update Package.appxmanifest
- name: Configure the package manifest, logo sets, and secrets
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")
. './scripts/Configure-AppxManifest.ps1' `
-Branch "$env:CONFIGURATION" `
-PackageProjectDir "$env:PACKAGE_PROJECT_DIR" `
-Publisher "$env:SIDELOAD_PUBLISHER_SECRET" `
-WorkingDir "$env:WORKING_DIR"
-BING_MAPS_SECRET "$env:BING_MAPS_SECRET"
-APP_CENTER_SECRET "$env:APP_CENTER_SECRET"
-GH_OAUTH_CLIENT_ID "$env:GH_OAUTH_CLIENT_ID"
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
Expand Down Expand Up @@ -156,19 +118,19 @@ jobs:
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256

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

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

# Azure logout
- name: logout
- name: Logout from Azure
run: |
az logout

Expand Down
72 changes: 17 additions & 55 deletions .github/workflows/deploy-stable.yml
0x5bfa marked this conversation as resolved.
Show resolved Hide resolved
@@ -1,4 +1,7 @@
name: Deploy Stable Pipeline
# Copyright (c) 2024 Files Community
# Licensed under the MIT License. See the LICENSE.

name: Files Deployment (Stable)

on:
workflow_dispatch:
Expand Down Expand Up @@ -27,71 +30,30 @@ jobs:
steps:
- name: Checkout the repository
uses: actions/checkout@v4

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

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

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

# TODO: Move the command to PowerShell script instead
- name: Update Package.appxmanifest
- name: Configure the package manifest, logo sets, and secrets
shell: pwsh
run: |
[xml]$xmlDoc = Get-Content "$env:PACKAGE_PROJECT_DIR\Package.appxmanifest"
$xmlDoc.Package.Identity.Name="Files"
$xmlDoc.Package.Identity.Publisher="$env:SIDELOAD_PUBLISHER_SECRET"
$xmlDoc.Package.Properties.DisplayName="Files"
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files"
$xmlDoc.Save("$env:PACKAGE_PROJECT_DIR\Package.appxmanifest")
. './scripts/Configure-AppxManifest.ps1' `
-Branch "$env:CONFIGURATION" `
-PackageProjectDir "$env:PACKAGE_PROJECT_DIR" `
-Publisher "$env:SIDELOAD_PUBLISHER_SECRET" `
-WorkingDir "$env:WORKING_DIR"
-BING_MAPS_SECRET "$env:BING_MAPS_SECRET"
-APP_CENTER_SECRET "$env:APP_CENTER_SECRET"
-GH_OAUTH_CLIENT_ID "$env:GH_OAUTH_CLIENT_ID"
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\Release" }) | `
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
Expand Down Expand Up @@ -156,19 +118,19 @@ jobs:
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256

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

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

# Azure logout
- name: logout
- name: Logout from Azure
run: |
az logout

Expand Down
121 changes: 121 additions & 0 deletions .github/workflows/deploy-store.yml
@@ -0,0 +1,121 @@
# Copyright (c) 2024 Files Community
# Licensed under the MIT License. See the LICENSE.

name: Files Deployment (Store)

on:
workflow_dispatch:

jobs:
build:
runs-on: windows-latest
environment: Deployments
strategy:
fail-fast: false
matrix:
configuration: [Store]
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@v4

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

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

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

- name: Configure the package manifest, logo sets, and secrets
shell: pwsh
run: |
. './scripts/Configure-AppxManifest.ps1' `
-Branch "$env:CONFIGURATION" `
-PackageProjectDir "$env:PACKAGE_PROJECT_DIR" `
-Publisher "CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" `
-WorkingDir "$env:WORKING_DIR"
-BING_MAPS_SECRET "$env:BING_MAPS_SECRET"
-APP_CENTER_SECRET "$env:APP_CENTER_SECRET"
-GH_OAUTH_CLIENT_ID "$env:GH_OAUTH_CLIENT_ID"
env:
BING_MAPS_SECRET: ${{ secrets.BING_MAPS_SECRET }}
APP_CENTER_SECRET: ${{ secrets.APP_CENTER_SECRET }}
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:AppxBundle=Always `
-p:UapAppxPackageBuildMode=StoreUpload'

- name: Remove empty files from the packages
shell: bash
run: find $ARTIFACTS_STAGING_DIR -empty -delete

- name: Update appinstaller schema
run: |
$newSchema = "http://schemas.microsoft.com/appx/appinstaller/2018"
$localFilePath = "${{ env.APPX_PACKAGE_DIR }}/Files.Package.appinstaller"
$fileContent = Get-Content $localFilePath
$fileContent = $fileContent.Replace("http://schemas.microsoft.com/appx/appinstaller/2017/2", $newSchema)
$fileContent | Set-Content $localFilePath

- 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 }}

- name: Submit msixupload to Partner Center
shell: pwsh
run: |
$bundlePlatformsSafe = "${{ env.AppxBundlePlatforms }}".Replace("|", "_")
$uploadBundlePath = "${{ env.AppxPackageDirectory }}PackageProject_${{ steps.version-creator.outputs.APP_VERSION }}_" + $bundlePlatformsSafe + "_bundle.msixupload"
./.scripts/SubmitToMsftStore.ps1 $uploadBundlePath
env:
PartnerCenterClientId: ${{ secrets.AZURE_CLIENT_ID }}
PartnerCenterClientSecret: ${{ secrets.AZURE_CLIENT_SECRET }}
PartnerCenterStoreId: ${{ secrets.MSSTORE_PRODUCT_ID }}
PartnerCenterTenantId: ${{ secrets.AZURE_TENANT_ID }}