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 stable sideload deployment to the workflow #14218

Closed
wants to merge 14 commits into from
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ on:
push:
branches:
- main
paths-ignore:
- 'specs/**'
- '*.md'
paths:
- '**'
- '!.github/**'
- '.github/workflows/ci.yml'
- '!specs/**'
- '!docs/**'
- '!*.md'
pull_request:
paths-ignore:
- 'specs/**'
- '*.md'
paths:
- '**'
- '!.github/**'
- '.github/workflows/ci.yml'
- '!specs/**'
- '!docs/**'
- '!*.md'

run-name: ${{ github.event_name == 'pull_request' && 'Files PR Validation' || 'Files CI Validation' }}

Expand Down
171 changes: 0 additions & 171 deletions .github/workflows/deploy-preview.yml
yaira2 marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

176 changes: 176 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Copyright (c) 2023 Files Community
# Licensed under the MIT License. See the LICENSE.

# Abstract:
# This workflow is triggered manually when the maintainer wants
# to deploy Preview or Stable to the Azure Blob Storage.

name: Files Deployment

on:
workflow_dispatch:
inputs:
branch:
description: 'Select a branch'
required: false
default: 'Preview'
0x5bfa marked this conversation as resolved.
Show resolved Hide resolved
type: choice
options:
- Preview
- Stable

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: 'Preview' # NOTE: This is just placeholder
PLATFORM: 'x64'
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
PACKAGE_DEPLOYMENT_BRANCH: 'Preview' # NOTE: This is just placeholder
PACKAGE_DEPLOYMENT_BRANCH_LOWERCASE: 'preview' # NOTE: This is just placeholder
0x5bfa marked this conversation as resolved.
Show resolved Hide resolved

run-name: Files Deployment

jobs:
deploy:
runs-on: windows-latest
environment: Deployments
strategy:
fail-fast: false

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'

- name: Set the correct value to PACKAGE_DEPLOYMENT_BRANCH
shel: pwsh
run: |
if [[ "$WORKFLOW_EVENT_NAME" == "workflow_call" ]]; then \
echo "${BRANCH_NAME_REQUESTED_BY_CALL}" >> ${PACKAGE_DEPLOYMENT_BRANCH} \
echo "${BRANCH_NAME_REQUESTED_BY_CALL,,}" >>${PACKAGE_DEPLOYMENT_BRANCH_LOWERCASE} \
echo "${BRANCH_NAME_REQUESTED_BY_CALL}" >> ${CONFIGURATION} \
if [[ "$WORKFLOW_EVENT_NAME" == "workflow_dispatch" ]]; then \
echo "${BRANCH_NAME_REQUESTED_BY_DISPATCH}" >> ${PACKAGE_DEPLOYMENT_BRANCH} \
echo "${BRANCH_NAME_REQUESTED_BY_DISPATCH,,}" >>${PACKAGE_DEPLOYMENT_BRANCH_LOWERCASE}
echo "${BRANCH_NAME_REQUESTED_BY_DISPATCH}" >> ${CONFIGURATION} \
env:
WORKFLOW_EVENT_NAME: ${{ github.event_name }}
BRANCH_NAME_REQUESTED_BY_CALL: ${{ workflow_call.inputs.branch }}
BRANCH_NAME_REQUESTED_BY_DISPATCH: ${{ workflow_dispatch.inputs.branch }}

- name: Configure the package manifest & logo sets
shell: pwsh
run: |
. './scripts/Configure-AppxManifest.ps1' `
-Branch "$env:PACKAGE_DEPLOYMENT_BRANCH" `
-PackageProjectDir "$env:PACKAGE_PROJECT_DIR" `
-Publisher "$env:SIDELOAD_PUBLISHER" `
-WorkingDir "$env:WORKING_DIR"
env:
SIDELOAD_PUBLISHER: ${{ secrets.SIDELOAD_PUBLISHER_SECRET }}

- name: Inject the Bing Maps API token
shell: pwsh
run: |
. './scripts/Replace-SpecialString.ps1' `
-WorkingDir "$env:WORKING_DIR" -Target "bingmapskey.secret" -New "$env:BING_MAPS_SECRET"
env:
BING_MAPS_SECRET: ${{ secrets.BING_MAPS_SECRET }}

- name: Inject the AppCenter token
shell: pwsh
run: |
. './scripts/Replace-SpecialString.ps1' `
-WorkingDir "$env:WORKING_DIR" -Target "appcenter.secret" -New "$env:APP_CENTER_SECRET"
env:
APP_CENTER_SECRET: ${{ secrets.APP_CENTER_SECRET }}

- name: Inject the GitHub OAuth client ID
run: |
. './scripts/Replace-SpecialString.ps1' `
-WorkingDir "$env:WORKING_DIR" -Target "githubclientid.secret" -New "$env:GH_OAUTH_CLIENT_ID"
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 Files.sln
shell: pwsh
run: |
msbuild $env:SOLUTION_NAME `
-t:Restore `
-p:Platform=$env:PLATFORM `
-p:Configuration=$env:CONFIGURATION `
-p:PublishReadyToRun=true

- name: Build & package Files
0x5bfa marked this conversation as resolved.
Show resolved Hide resolved
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/$env:PACKAGE_DEPLOYMENT_BRANCH_LOWERCASE/

- name: Sign files with Azure Code Signing
0x5bfa marked this conversation as resolved.
Show resolved Hide resolved
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

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

- name: Upload the package to the Azure Blob Storage
0x5bfa marked this conversation as resolved.
Show resolved Hide resolved
uses: azure/powershell@v1
with:
inlineScript: |
az storage blob upload-batch
--account-name "filescommunity"
--destination "files"
--destination-path "${{ env.PACKAGE_DEPLOYMENT_BRANCH_LOWERCASE }}"
--source ${{ env.APPX_PACKAGE_DIR }}
--overwrite true
azPSVersion: "latest"

- name: Logout from the Azure CLI
run: |
az logout
Loading