-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to build executables from python scripts
- Loading branch information
Showing
4 changed files
with
163 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter()] | ||
[String] | ||
$Path | ||
) | ||
|
||
|
||
function FindSignTool { | ||
$SignTool = "signtool.exe" | ||
if (Get-Command $SignTool -ErrorAction SilentlyContinue) { | ||
return $SignTool | ||
} | ||
$SignTool = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\x64\signtool.exe" | ||
if (Test-Path -Path $SignTool -PathType Leaf) { | ||
return $SignTool | ||
} | ||
$SignTool = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\x86\signtool.exe" | ||
if (Test-Path -Path $SignTool -PathType Leaf) { | ||
return $SignTool | ||
} | ||
$sdkVers = "10.0.22000.0", "10.0.20348.0", "10.0.19041.0", "10.0.17763.0" | ||
Foreach ($ver in $sdkVers) | ||
{ | ||
$SignTool = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\${ver}\x64\signtool.exe" | ||
if (Test-Path -Path $SignTool -PathType Leaf) { | ||
return $SignTool | ||
} | ||
} | ||
"signtool.exe not found" | ||
Exit 1 | ||
} | ||
|
||
function SignEsptool { | ||
param( | ||
[Parameter()] | ||
[String] | ||
$Path | ||
) | ||
|
||
$SignTool = FindSignTool | ||
"Using: $SignTool" | ||
$CertificateFile = [system.io.path]::GetTempPath() + "certificate.pfx" | ||
|
||
if ($null -eq $env:CERTIFICATE) { | ||
"CERTIFICATE variable not set, unable to sign the file" | ||
Exit 1 | ||
} | ||
|
||
if ("" -eq $env:CERTIFICATE) { | ||
"CERTIFICATE variable is empty, unable to sign the file" | ||
Exit 1 | ||
} | ||
|
||
$SignParameters = @("sign", "/tr", 'http://timestamp.digicert.com', "/td", "SHA256", "/f", $CertificateFile, "/fd", "SHA256") | ||
if ($env:CERTIFICATE_PASSWORD) { | ||
"CERTIFICATE_PASSWORD detected, using the password" | ||
$SignParameters += "/p" | ||
$SignParameters += $env:CERTIFICATE_PASSWORD | ||
} | ||
$SignParameters += $Path | ||
|
||
[byte[]]$CertificateBytes = [convert]::FromBase64String($env:CERTIFICATE) | ||
[IO.File]::WriteAllBytes($CertificateFile, $CertificateBytes) | ||
|
||
&$SignTool $SignParameters | ||
|
||
if (0 -eq $LASTEXITCODE) { | ||
Remove-Item $CertificateFile | ||
} else { | ||
Remove-Item $CertificateFile | ||
"Signing failed" | ||
Exit 1 | ||
} | ||
|
||
} | ||
|
||
SignEsptool ${Path} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Build Python Tools | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'tools/get.py' | ||
|
||
jobs: | ||
build-pytools-binaries: | ||
name: Build python tools binaries for ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [windows-latest, macos-latest, ubuntu-20.04, ARM, ARM64] | ||
include: | ||
- os: windows-latest | ||
TARGET: win64 | ||
EXTEN: .exe | ||
SEPARATOR: ';' | ||
- os: macos-latest | ||
TARGET: macos | ||
SEPARATOR: ':' | ||
- os: ubuntu-20.04 | ||
TARGET: linux-amd64 | ||
SEPARATOR: ':' | ||
- os: ARM | ||
CONTAINER: python:3.8-bullseye | ||
TARGET: arm | ||
SEPARATOR: ':' | ||
- os: ARM64 | ||
CONTAINER: python:3.8-bullseye | ||
TARGET: arm64 | ||
SEPARATOR: ':' | ||
container: ${{ matrix.CONTAINER }} # use python container on ARM | ||
env: | ||
DISTPATH: pytools-${{ matrix.TARGET }} | ||
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@master | ||
- name: Set up Python 3.8 | ||
# Skip setting python on ARM because of missing compatibility: https://github.com/actions/setup-python/issues/108 | ||
if: matrix.os != 'ARM' && matrix.os != 'ARM64' | ||
uses: actions/setup-python@master | ||
with: | ||
python-version: 3.8 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pyinstaller requests | ||
- name: Build with PyInstaller | ||
run: | | ||
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=.github/pytools/espressif.ico tools/get.py | ||
# - name: Sign binaries | ||
# if: matrix.os == 'windows-latest' | ||
# env: | ||
# CERTIFICATE: ${{ secrets.CERTIFICATE }} | ||
# CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} | ||
# shell: pwsh | ||
# run: | | ||
# ./.github/pytools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/get.exe | ||
- name: Test binaries | ||
shell: bash | ||
run: | | ||
./${{ env.DISTPATH }}/get${{ matrix.EXTEN }} -h | ||
- name: Archive artifact | ||
uses: actions/upload-artifact@master | ||
with: | ||
name: ${{ env.DISTPATH }} | ||
path: ${{ env.DISTPATH }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters