|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - "src/**" |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + paths: |
| 13 | + - "src/**" |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + build-exe: |
| 20 | + runs-on: windows-2022 |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Generate release version |
| 26 | + id: version |
| 27 | + env: |
| 28 | + GH_TOKEN: ${{ github.token }} |
| 29 | + shell: pwsh |
| 30 | + run: | |
| 31 | + $today = (Get-Date -Format 'yyyy.M.d') |
| 32 | + $defaultVersion = "${today}.0" |
| 33 | +
|
| 34 | + # fetch the latest release tag name |
| 35 | + try { |
| 36 | + $latestVersion = gh release list --limit 1 --json tagName | ConvertFrom-Json | Select-Object -ExpandProperty tagName |
| 37 | + } catch { |
| 38 | + $latestVersion = "" |
| 39 | + } |
| 40 | +
|
| 41 | + # check if we successfully got a latest version and if its date matches today's date |
| 42 | + if (-not [string]::IsNullOrEmpty($latestVersion) -and ($latestVersion -match '^v([0-9]{4}\.[0-9]{2}\.[0-9]{2})\.([0-9]+)$')) { |
| 43 | + $latestDate = $Matches[1] |
| 44 | + $latestIncrement = [int]$Matches[2] |
| 45 | +
|
| 46 | + if ($latestDate -eq $today) { |
| 47 | + # date matches; increment the number |
| 48 | + $newIncrement = $latestIncrement + 1 |
| 49 | + $newVersion = "${today}.${newIncrement}" |
| 50 | + } else { |
| 51 | + # date does not match; use the default version with .0 |
| 52 | + $newVersion = $defaultVersion |
| 53 | + } |
| 54 | + } else { |
| 55 | + # No latest release found or format is unexpected, use the default version with .0 |
| 56 | + $newVersion = $defaultVersion |
| 57 | + } |
| 58 | +
|
| 59 | + Write-Host "Using version $newVersion" |
| 60 | + echo "version=$newVersion" >> $env:GITHUB_OUTPUT |
| 61 | +
|
| 62 | + - name: Install signing certificate |
| 63 | + id: cert |
| 64 | + env: |
| 65 | + CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_BASE64 }} |
| 66 | + CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} |
| 67 | + shell: pwsh |
| 68 | + run: | |
| 69 | + $b64Path = "$env:TEMP\certificate.base64.txt" |
| 70 | + $certPath = "$env:TEMP\certificate.pfx" |
| 71 | + Remove-Item -Path $b64Path, $certPath -ErrorAction Ignore |
| 72 | +
|
| 73 | + Set-Content -Path $b64Path -Value $env:CERTIFICATE_BASE64 -Encoding ASCII |
| 74 | +
|
| 75 | + & certutil -decode $b64Path $certPath |
| 76 | +
|
| 77 | + $certPassword = ConvertTo-SecureString -String ${{ secrets.CERTIFICATE_PASSWORD }} -AsPlainText -Force |
| 78 | + Import-PfxCertificate -FilePath $certPath -CertStoreLocation Cert:\CurrentUser\My -Password $certPassword |
| 79 | +
|
| 80 | + # import the certificate and capture the output object |
| 81 | + $importedCert = Import-PfxCertificate -FilePath $certPath -CertStoreLocation Cert:\CurrentUser\My -Password $certPassword |
| 82 | +
|
| 83 | + # output the thumbprint |
| 84 | + if ($null -ne $importedCert) { |
| 85 | + # save thumbprint to github output |
| 86 | + $thumbprint = $importedCert.Thumbprint |
| 87 | + Write-Host "Certificate thumbprint: $thumbprint" |
| 88 | + echo "thumbprint=$thumbprint" >> $env:GITHUB_OUTPUT |
| 89 | +
|
| 90 | + } else { |
| 91 | + Write-Error "Failed to import certificate or retrieve the certificate object." |
| 92 | + } |
| 93 | +
|
| 94 | + # clean up |
| 95 | + Remove-Item -Path $b64Path, $certPath -Force |
| 96 | +
|
| 97 | + - name: Build app |
| 98 | + shell: pwsh |
| 99 | + run: | |
| 100 | + Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force |
| 101 | + .\build.ps1 -ForceVersion ${{ steps.version.outputs.version }} -ForcePublisher "Jack Buehner" |
| 102 | +
|
| 103 | + - name: Build for Microsoft Store |
| 104 | + shell: pwsh |
| 105 | + run: | |
| 106 | + Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force |
| 107 | + .\build.ps1 -ForStore |
| 108 | +
|
| 109 | + - name: Save store build output |
| 110 | + uses: actions/upload-artifact@v4 |
| 111 | + with: |
| 112 | + name: "msft-store-build" |
| 113 | + path: | |
| 114 | + dist/msft-store/ |
| 115 | +
|
| 116 | + - name: Add version number to file name |
| 117 | + shell: pwsh |
| 118 | + run: | |
| 119 | + $version = "${{ steps.version.outputs.version }}" |
| 120 | +
|
| 121 | + # make all names lowercase and use underscores instead of spaces |
| 122 | + $files = Get-ChildItem -Path "dist" -File |
| 123 | + foreach ($file in $files) { |
| 124 | + $baseName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name) |
| 125 | + $extension = [System.IO.Path]::GetExtension($file.Name) |
| 126 | + $newName = "$($baseName.ToLower())$extension" |
| 127 | + $newName = $newName -replace ' ', '_' |
| 128 | + Rename-Item -Path $file.FullName -NewName $newName |
| 129 | + } |
| 130 | +
|
| 131 | + # add version number to the msix file name |
| 132 | + $file = Get-ChildItem -Path "dist" -Filter "rdp_protocol_handler.msix" -File |
| 133 | + $baseName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name) |
| 134 | + $extension = [System.IO.Path]::GetExtension($file.Name) |
| 135 | + $newName = "${baseName}_v${version}$extension" |
| 136 | + Rename-Item -Path $file.FullName -NewName $newName |
| 137 | +
|
| 138 | + # echo all the file names |
| 139 | + $files = Get-ChildItem -Path "dist" -File |
| 140 | + foreach ($file in $files) { |
| 141 | + Write-Host "File: $($file.Name)" |
| 142 | + } |
| 143 | +
|
| 144 | + - name: Create draft release |
| 145 | + uses: ncipollo/release-action@v1 |
| 146 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') |
| 147 | + with: |
| 148 | + artifacts: "dist/rdp_protocol_handler_v${{ steps.version.outputs.version }}.msix,dist/rdp_protocol_handler.cer,dist/install_cert.bat" # comma-delimited list of artifact names |
| 149 | + tag: "v${{ steps.version.outputs.version }}" |
| 150 | + name: "Release v${{ steps.version.outputs.version }}" |
| 151 | + draft: true |
| 152 | + generateReleaseNotes: true |
| 153 | + skipIfReleaseExists: true |
| 154 | + body: | |
| 155 | + ## Get the latest published release |
| 156 | +
|
| 157 | + <a href="https://apps.microsoft.com/detail/9n1192wschv9" target="_blank"> |
| 158 | + <picture> |
| 159 | + <source media="(prefers-color-scheme: dark)" srcset="https://get.microsoft.com/images/en-us%20light.svg"> |
| 160 | + <source media="(prefers-color-scheme: light)" srcset="https://get.microsoft.com/images/en-us%20dark.svg"> |
| 161 | + <img src="frontend/lib/assets/favorites_light.png" alt="A screenshot of the favorites page in RAWeb"> |
| 162 | + </picture> |
| 163 | + </a> |
| 164 | +
|
| 165 | + ## Install this release |
| 166 | +
|
| 167 | + 1. **Install the certificate** |
| 168 | + Download `rdp_protocol_handler.ce` and `install_cert.bat`. Run `install_cert.bat`. |
| 169 | +
|
| 170 | + 2. **Install the app** |
| 171 | + Download `rdp_protocol_handler_v${{ steps.version.outputs.version }}.msix` and open it. Click **Install** to install the app. |
0 commit comments