|
| 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 | + |
| 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 | + |
| 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 }} |
0 commit comments