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