forked from files-community/Files
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub: Added ps1 scripts to simplify CI/CD (files-community#15030)
- Loading branch information
1 parent
a2848b0
commit 94d8272
Showing
3 changed files
with
127 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
name: Deploy Preview Pipeline | ||
# Copyright (c) 2024 Files Community | ||
# Licensed under the MIT License. See the LICENSE. | ||
|
||
name: Files CD (Preview) | ||
|
||
on: | ||
workflow_dispatch: | ||
|
@@ -27,72 +30,31 @@ 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" ` | ||
-SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` | ||
-SecretAppCenter "$env:SECRET_APPCENTER" ` | ||
-SecretGitHubOAuthClientId "$env:SECRET_GITHUB_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 }} | ||
SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }} | ||
SECRET_APPCENTER: ${{ secrets.APP_CENTER_SECRET }} | ||
SECRET_GITHUB_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }} | ||
|
||
- name: Use Windows SDK Preview | ||
shell: cmd | ||
|
@@ -156,21 +118,20 @@ 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 }} | ||
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 | ||
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 | ||
run: | | ||
az logout | ||
- name: Logout from Azure | ||
run: 'az logout' | ||
|
||
- name: Upload the packages to GitHub Actions | ||
uses: actions/upload-artifact@v3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
name: Deploy Stable Pipeline | ||
# Copyright (c) 2024 Files Community | ||
# Licensed under the MIT License. See the LICENSE. | ||
|
||
name: Files CD (Stable) | ||
|
||
on: | ||
workflow_dispatch: | ||
|
@@ -27,73 +30,32 @@ 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" ` | ||
-SecretBingMapsKey "$env:SECRET_BINGMAPS_KEY" ` | ||
-SecretAppCenter "$env:SECRET_APPCENTER" ` | ||
-SecretGitHubOAuthClientId "$env:SECRET_GITHUB_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 }} | ||
|
||
SECRET_BINGMAPS_KEY: ${{ secrets.BING_MAPS_SECRET }} | ||
SECRET_APPCENTER: ${{ secrets.APP_CENTER_SECRET }} | ||
SECRET_GITHUB_OAUTH_CLIENT_ID: ${{ secrets.GH_OAUTH_CLIENT_ID }} | ||
|
||
- name: Use Windows SDK Preview | ||
shell: cmd | ||
run: | | ||
|
@@ -156,21 +118,20 @@ 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 | ||
run: | | ||
az logout | ||
- name: Logout from Azure | ||
run: 'az logout' | ||
|
||
- name: Upload the packages to GitHub Actions | ||
uses: actions/upload-artifact@v3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright (c) 2024 Files Community | ||
# Licensed under the MIT License. See the LICENSE. | ||
|
||
param( | ||
[string]$Branch = "", | ||
[string]$PackageProjectDir = "", | ||
[string]$Publisher = "", | ||
[string]$WorkingDir = "", | ||
[string]$SecretBingMapsKey = "", | ||
[string]$SecretAppCenter = "", | ||
[string]$SecretGitHubOAuthClientId = "" | ||
) | ||
|
||
[xml]$xmlDoc = Get-Content "$PackageProjectDir\Package.appxmanifest" | ||
$xmlDoc.Package.Identity.Publisher="$Publisher" | ||
|
||
if ($Branch -eq "Preview") | ||
{ | ||
# Set identities | ||
$xmlDoc.Package.Identity.Name="FilesPreview" | ||
$xmlDoc.Package.Properties.DisplayName="Files - Preview" | ||
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview" | ||
|
||
Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process | ||
{ | ||
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | | ||
Set-Content $_ -NoNewline | ||
} | ||
} | ||
elseif ($Branch -eq "Stable") | ||
{ | ||
# Set identities | ||
$xmlDoc.Package.Identity.Name="Files" | ||
$xmlDoc.Package.Properties.DisplayName="Files" | ||
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files" | ||
|
||
Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process | ||
{ | ||
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | | ||
Set-Content $_ -NoNewline | ||
} | ||
} | ||
elseif ($Branch -eq "Store") | ||
{ | ||
# Set identities | ||
$xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP" | ||
$xmlDoc.Package.Properties.DisplayName="Files" | ||
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files" | ||
|
||
# Remove an capability that is used for the sideload | ||
$nsmgr = New-Object System.Xml.XmlNamespaceManager($xmlDoc.NameTable) | ||
$nsmgr.AddNamespace("pkg", "http://schemas.microsoft.com/appx/manifest/foundation/windows10") | ||
$nsmgr.AddNamespace("rescap", "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities") | ||
$pm = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']", $nsmgr) | ||
$xmlDoc.Package.Capabilities.RemoveChild($pm) | ||
|
||
Get-ChildItem "$WorkingDir\src" -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach -Process | ||
{ | ||
(Get-Content $_ -Raw | ForEach -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | | ||
Set-Content $_ -NoNewline | ||
} | ||
} | ||
|
||
$xmlDoc.Save("$PackageProjectDir\Package.appxmanifest") | ||
|
||
Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process | ||
{ | ||
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) | | ||
Set-Content $_ -NoNewline | ||
} | ||
|
||
Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process | ||
{ | ||
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "appcenter.secret", "$SecretAppCenter" }) | | ||
Set-Content $_ -NoNewline | ||
} | ||
|
||
Get-ChildItem "$WorkingDir\src" -Include *.cs -recurse | ForEach-Object -Process | ||
{ | ||
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$SecretGitHubOAuthClientId" }) | | ||
Set-Content $_ -NoNewline | ||
} |