Skip to content

Commit 299924d

Browse files
committed
feat: Migrate to espressif/release-sign action for signing Windows binaries
1 parent 8f20755 commit 299924d

File tree

3 files changed

+62
-106
lines changed

3 files changed

+62
-106
lines changed

README.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,11 @@ Building the project with default configuration will result in script name `__ma
166166

167167
### Signing Windows Binaries
168168

169-
If you would like to sign Windows binaries, you can set `certificate` and the action will also take care of signing all binaries.
170-
It is also recommended to use `certificate-password`.
169+
If you would like to sign Windows binaries, you can configure Azure Key Vault credentials and the action will automatically sign all binaries after building. Signing is only performed for `windows-amd64` platform builds.
171170

172-
The `certificate` should be a PFX (Personal Information Exchange) certificate file encoded in base64 format.
171+
The action uses the [espressif/release-sign](https://github.com/espressif/release-sign) action internally, which requires Azure credentials to access a certificate stored in Azure Key Vault. If the Azure client secret is not set, signing will be skipped with a warning message.
172+
173+
To enable signing, you must explicitly pass the Azure credentials as inputs from your workflow. Set the following secrets in your repository and pass them to the action:
173174

174175
```yaml
175176
- name: Build Python executable
@@ -178,8 +179,12 @@ The `certificate` should be a PFX (Personal Information Exchange) certificate fi
178179
scripts: 'app.py'
179180
output-dir: './dist'
180181
target-platform: 'windows-amd64'
181-
certificate: ${{ secrets.CERTIFICATE }}
182-
certificate-password: ${{ secrets.CERTIFICATE_PASSWORD }}
182+
# Azure credentials for signing (must be explicitly passed)
183+
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
184+
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
185+
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
186+
azure-keyvault-uri: ${{ secrets.AZURE_KEYVAULT_URI }}
187+
azure-keyvault-cert-name: ${{ secrets.AZURE_KEYVAULT_CERT_NAME }}
183188
```
184189

185190
### Complete Workflow
@@ -275,12 +280,24 @@ jobs:
275280
| `install-deps-command` | Command to install project dependencies | `"uv pip install -e ."` | `"uv pip install -r requirements.txt"` |
276281
| `additional-arm-packages` | ARMv7 ONLY: Additional system packages | `""` | `"openssl libffi-dev"` |
277282
| `test-command-args` | Command arguments to test executables | `"--help"` | `"--version"` |
278-
| `certificate` | Certificate to use for signing binaries | `""` | `${{ secrets.CERTIFICATE }}` |
279-
| `certificate-password` | Password for the certificate | `""` | `${{ secrets.CERTIFICATE_PASSWORD }}` |
280283

281284
> [!IMPORTANT]
282285
> Be careful when changing `pyinstaller-version` as it might lead to increased false positives with anti-virus software. It is recommended to check your executables with antivirus software such as [Virustotal](https://www.virustotal.com/gui/home/upload).
283286

287+
### Optional Inputs for Signing Binaries
288+
289+
For signing binaries on Windows, this action uses the [espressif/release-sign](https://github.com/espressif/release-sign) action. The following inputs are optional but required if you want to sign your Windows executables.
290+
291+
Signing is optional but strongly recommended. The action will produce a warning if a Windows executable was built but was not signed.
292+
293+
| Input | Description | Default | Example |
294+
|---------------------------|----------------------------------|----------|-------------------------------------------|
295+
| `azure-client-id` | Azure client ID for signing | `""` | `${{ secrets.AZURE_CLIENT_ID }}` |
296+
| `azure-client-secret` | Azure client secret for signing | `""` | `${{ secrets.AZURE_CLIENT_SECRET }}` |
297+
| `azure-tenant-id` | Azure tenant ID for signing | `""` | `${{ secrets.AZURE_TENANT_ID }}` |
298+
| `azure-keyvault-uri` | Azure key vault URI for signing | `""` | `${{ secrets.AZURE_KEYVAULT_URI }}` |
299+
| `azure-keyvault-cert-name`| Azure key vault certificate name | `""` | `${{ secrets.AZURE_KEYVAULT_CERT_NAME }}` |
300+
284301
## Outputs
285302

286303
| Output | Description |

Sign-File.ps1

Lines changed: 0 additions & 79 deletions
This file was deleted.

action.yml

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,24 @@ inputs:
6060
description: Command arguments to test binaries (e.g. "--help")
6161
required: false
6262
default: --help
63-
certificate:
64-
description: Certificate to use for signing binaries
63+
azure-client-id:
64+
description: Azure client ID for espressif/release-sign action
6565
required: false
6666
default: ''
67-
certificate-password:
68-
description: Password for the certificate
67+
azure-client-secret:
68+
description: Azure client secret for espressif/release-sign action
69+
required: false
70+
default: ''
71+
azure-tenant-id:
72+
description: Azure tenant ID for espressif/release-sign action
73+
required: false
74+
default: ''
75+
azure-keyvault-uri:
76+
description: Azure key vault URI for espressif/release-sign action
77+
required: false
78+
default: ''
79+
azure-keyvault-cert-name:
80+
description: Azure key vault certificate name for espressif/release-sign action
6981
required: false
7082
default: ''
7183

@@ -265,21 +277,27 @@ runs:
265277
"${{ steps.setup-platform.outputs.exe-extension }}" \
266278
"${{ inputs.test-command-args }}"
267279
268-
- name: Sign binaries
269-
if: inputs.target-platform == 'windows-amd64'
270-
env:
271-
CERTIFICATE: ${{ inputs.certificate }}
272-
CERTIFICATE_PASSWORD: ${{ inputs.certificate-password }}
280+
- name: Check signing certificate
281+
if: |
282+
inputs.target-platform == 'windows-amd64' && inputs.azure-client-secret == ''
273283
shell: pwsh
274-
run: |-
275-
if ([string]::IsNullOrEmpty($env:CERTIFICATE)) {
276-
Write-Host "::warning title=Signing::Certificate is not set, skipping signing"
277-
exit 0
278-
}
284+
run: |
285+
Write-Host "::warning title=Signing::Azure client secret is not set, skipping signing"
286+
287+
- name: Sign binaries
288+
if: |
289+
inputs.target-platform == 'windows-amd64' && inputs.azure-client-secret != ''
290+
uses: espressif/release-sign@master
291+
with:
292+
path: ${{ inputs.output-dir }}
293+
azure-client-id: ${{ inputs.azure-client-id }}
294+
azure-client-secret: ${{ inputs.azure-client-secret }}
295+
azure-tenant-id: ${{ inputs.azure-tenant-id }}
296+
azure-keyvault-uri: ${{ inputs.azure-keyvault-uri }}
297+
azure-keyvault-cert-name: ${{ inputs.azure-keyvault-cert-name }}
279298

280-
$pythonFiles = "${{ inputs.scripts }}".Split(' ')
281-
foreach ($file in $pythonFiles) {
282-
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($file)
283-
$executable = "./${{ inputs.output-dir }}/${baseName}${{ steps.setup-platform.outputs.exe-extension }}"
284-
& (Join-Path $env:GITHUB_ACTION_PATH "Sign-File.ps1") -Path $executable
285-
}
299+
- name: Remove leftover signature files
300+
if: |
301+
inputs.target-platform == 'windows-amd64' && inputs.azure-client-secret != ''
302+
shell: bash
303+
run: find ./${{ inputs.output-dir }} -name "*.sig" -type f -delete

0 commit comments

Comments
 (0)