-
-
Notifications
You must be signed in to change notification settings - Fork 41
193 lines (153 loc) · 6.35 KB
/
windows-codesigned-release.yaml
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Release Codesigned Converseen for Windows
on:
repository_dispatch:
types: [signature-response]
permissions:
contents: write
jobs:
prepare-codesigned-artifacts:
runs-on: windows-latest
outputs:
output_version: ${{ steps.converseen-version.outputs.version }}
steps:
- name: Install Cmdlets
shell: powershell
run: Install-Module -Name SignPath -Scope CurrentUser -Force
- name: Checkout Converseen
uses: actions/checkout@v4
with:
path: Converseen
- name: Get Converseen Version Number
id: converseen-version
shell: powershell
run: |
$versionNumber = Get-Content -Path "Converseen\package\Windows\version.txt" -TotalCount 1
$pattern = '^(\d+\.\d+\.\d+\.\d+)-(\d+)$'
if ($versionNumber -match $pattern) {
$versionNumber = $matches[1]
$buildNumber = $matches[2]
echo "version=$versionNumber" >> $env:GITHUB_OUTPUT
echo "build=$buildNumber" >> $env:GITHUB_OUTPUT
Write-Host "Version: $versionNumber"
Write-Host "Build Number: $buildNumber"
} else {
Write-Host "Warning: No match found."
}
- name: Download Signed Artifact
shell: powershell
run: |
$ORGANIZATION_ID="${{ github.event.client_payload.OrganizationId }}"
$signingRequestID="${{ github.event.client_payload.SigningRequestId }}"
$status="${{ github.event.client_payload.Status }}"
$SP_API_TOKEN="${{ secrets.SP_API_TOKEN }}"
if ($status -eq "Completed") {
Write-Output "The artifact has been signed correctly! ($status)"
Get-SignedArtifact `
-OrganizationId $ORGANIZATION_ID -ApiToken $SP_API_TOKEN `
-SigningRequestId $signingRequestID `
-OutputArtifactPath artifact.zip
} else {
Write-Output "The artifact was not signed correctly! ($status)"
exit 1
}
- name: Create Release Versions
shell: powershell
run: |
$env:versionNumber='${{ steps.converseen-version.outputs.version }}'
$env:buildNumber='${{ steps.converseen-version.outputs.build }}'
$env:installerName="Converseen-$env:versionNumber-$env:buildNumber-win32-setup"
$env:portableName="converseen-$env:versionNumber-$env:buildNumber-win32-portable"
Write-Output "--- Version: $env:versionNumber ---"
Write-Output "--- Installer Name: $env:installerName ---"
Write-Output "--- Portable Name: $env:portableName ---"
Expand-Archive -Path artifact.zip -DestinationPath . -Force
cd artifact
# Extract portable version
Expand-Archive -Path Converseen.zip -DestinationPath . -Force
Remove-Item -Path Converseen.zip
# Create settings directory for portable version
mkdir Converseen\settings
# Rename files
Rename-Item -Path "Converseen" -NewName "$env:portableName"
Rename-Item -Path "Converseen.msi" -NewName "$env:installerName.msi"
# Compress portable version
Compress-Archive -Path "$env:portableName" -DestinationPath "$env:portableName.zip"
# Prepare release artifact
cd ../
mkdir release
cp artifact\*.zip release
cp artifact\*.msi release
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: signed-artifacts
path: release
create_release:
name: 'Create release'
needs:
- prepare-codesigned-artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout Converseen
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: signed-artifacts
path: artifacts
- name: Read Version
run: |
echo "Version: v${{ needs.prepare-codesigned-artifacts.outputs.output_version }}"
- name: Get Previous tag
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: "v${{ needs.prepare-codesigned-artifacts.outputs.output_version }}"
- name: Publish Release
uses: softprops/action-gh-release@v1
with:
tag_name: "${{ steps.previoustag.outputs.tag }}"
files: |
artifacts/Converseen-*-win32-setup.msi
artifacts/converseen-*.zip
sf-release:
name: Sourceforge Release
needs:
- prepare-codesigned-artifacts
runs-on: ubuntu-latest
steps:
- name: Known Hosts
id: known-hosts
run: |
SF_HOSTS=$(ssh-keyscan -H frs.sourceforge.net)
echo "known-hosts=$SF_HOSTS" >> $GITHUB_OUTPUT
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: signed-artifacts
path: artifacts
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SF_SSH_KEY }}
known_hosts: ${{ steps.known-hosts.outputs.known-hosts }}
if_key_exists: fail # replace / ignore / fail; optional (defaults to fail)
- name: rsync over SSH
id: rsync
run: |
cd artifacts
c_ver=${{ needs.prepare-codesigned-artifacts.outputs.output_version }}
# v_dir is the SourceForge dest dir in the form X.Y
v_dir=$(echo "$c_ver" | grep -oE '^[0-9]+\.[0-9]+')
c_target=$(echo $(ls Converseen-*-win32-setup.msi))
echo "target-file=$c_target" >> $GITHUB_OUTPUT
rsync -r Converseen-*-win32-setup.msi converseen-*.zip ${{ secrets.SF_USERHOST }}:"${{ secrets.SF_PATH }}/Converseen $v_dir/"
- name: Set Platform
run: |
c_ver=${{ needs.prepare-codesigned-artifacts.outputs.output_version }}
c_target=${{ steps.rsync.outputs.target-file }}
# v_dir is the SourceForge dest dir in the form X.Y
v_dir=$(echo "$c_ver" | grep -oE '^[0-9]+\.[0-9]+')
c_url=https://sourceforge.net/projects/converseen/files/Converseen/Converseen%20${v_dir}/$c_target
echo "url: $c_url"
curl -H "Accept: application/json" -X PUT -d "default=windows" -d "api_key=${{ secrets.SF_API_KEY }}" $c_url