|  | 
|  | 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@v4 | 
|  | 30 | + | 
|  | 31 | +    - name: Setup MSBuild | 
|  | 32 | +      uses: microsoft/setup-msbuild@v1 | 
|  | 33 | + | 
|  | 34 | +    - name: Setup NuGet | 
|  | 35 | + | 
|  | 36 | + | 
|  | 37 | +    - name: Setup .NET 8 | 
|  | 38 | +      uses: actions/setup-dotnet@v3 | 
|  | 39 | +      with: | 
|  | 40 | +        dotnet-version: '8.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: Update appinstaller schema | 
|  | 135 | +      run: | | 
|  | 136 | +        $newSchema = "http://schemas.microsoft.com/appx/appinstaller/2018" | 
|  | 137 | +        $localFilePath = "${{ env.APPX_PACKAGE_DIR }}/Files.Package.appinstaller" | 
|  | 138 | +        $fileContent = Get-Content $localFilePath | 
|  | 139 | +        $fileContent = $fileContent.Replace("http://schemas.microsoft.com/appx/appinstaller/2017/2", $newSchema) | 
|  | 140 | +        $fileContent | Set-Content $localFilePath | 
|  | 141 | +
 | 
|  | 142 | +    - name: Sign files with Azure Trusted Signing | 
|  | 143 | + | 
|  | 144 | +      with: | 
|  | 145 | +        azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} | 
|  | 146 | +        azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} | 
|  | 147 | +        azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }} | 
|  | 148 | +        endpoint: https://eus.codesigning.azure.net/ | 
|  | 149 | +        code-signing-account-name: ${{ secrets.SIGNING_ACCOUNT_NAME }} | 
|  | 150 | +        certificate-profile-name: ${{ secrets.SIGNING_PROFILE_NAME }} | 
|  | 151 | +        files-folder: ${{ env.APPX_PACKAGE_DIR }} | 
|  | 152 | +        files-folder-filter: msixbundle | 
|  | 153 | +        files-folder-recurse: true | 
|  | 154 | +        files-folder-depth: 4 | 
|  | 155 | +        file-digest: SHA256 | 
|  | 156 | +        timestamp-rfc3161: http://timestamp.acs.microsoft.com | 
|  | 157 | +        timestamp-digest: SHA256 | 
|  | 158 | + | 
|  | 159 | +    - uses: azure/login@v1 | 
|  | 160 | +      with: | 
|  | 161 | +          creds: ${{ secrets.AZURE_CREDENTIALS }} | 
|  | 162 | + | 
|  | 163 | +    - name: Upload to blob storage | 
|  | 164 | +      uses: azure/powershell@v1 | 
|  | 165 | +      with: | 
|  | 166 | +        inlineScript: | | 
|  | 167 | +         az storage blob upload-batch --account-name "filescommunity" --destination "files" --destination-path "preview" --source ${{ env.APPX_PACKAGE_DIR }} --overwrite true | 
|  | 168 | +        azPSVersion: "latest" | 
|  | 169 | + | 
|  | 170 | +    # Azure logout | 
|  | 171 | +    - name: logout | 
|  | 172 | +      run: | | 
|  | 173 | +          az logout | 
|  | 174 | +
 | 
|  | 175 | +    - name: Upload the packages to GitHub Actions | 
|  | 176 | +      uses: actions/upload-artifact@v3 | 
|  | 177 | +      with: | 
|  | 178 | +        name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})' | 
|  | 179 | +        path: ${{ env.ARTIFACTS_STAGING_DIR }} | 
0 commit comments