Skip to content

Commit 9305da8

Browse files
committed
CI: Build and release binaries
Closes #625
1 parent e5f94fa commit 9305da8

File tree

6 files changed

+189
-2
lines changed

6 files changed

+189
-2
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Build esptool
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build-esptool-binaries:
7+
name: Build esptool binaries for ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [macos-latest, ubuntu-latest, windows-latest]
12+
include:
13+
- os: macos-latest
14+
TARGET: macos
15+
- os: ubuntu-latest
16+
TARGET: linux-amd64
17+
- os: windows-latest
18+
TARGET: win64
19+
EXTEN: .exe
20+
env:
21+
DISTPATH: esptool-${{ matrix.TARGET }}
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v1
25+
- name: Set up Python 3.8
26+
uses: actions/setup-python@v1
27+
with:
28+
python-version: 3.8
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install pyinstaller
33+
pip install --user -e .
34+
- name: Build with PyInstaller
35+
run: |
36+
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=build_tools/espressif.ico esptool.py
37+
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=build_tools/espressif.ico espefuse.py
38+
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=build_tools/espressif.ico espsecure.py
39+
pyinstaller --distpath ./${{ env.DISTPATH }} -F --icon=build_tools/espressif.ico esp_rfc2217_server.py
40+
- name: Sign binaries
41+
if: matrix.os == 'windows-latest'
42+
env:
43+
CERTIFICATE: ${{ secrets.CERTIFICATE }}
44+
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
45+
shell: pwsh
46+
run: |
47+
./build_tools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esptool.exe
48+
./build_tools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espefuse.exe
49+
./build_tools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/espsecure.exe
50+
./build_tools/Sign-File.ps1 -Path ./${{ env.DISTPATH }}/esp_rfc2217_server.exe
51+
- name: Test binaries
52+
shell: bash
53+
run: |
54+
./${{ env.DISTPATH }}/esptool${{ matrix.EXTEN }} -h
55+
./${{ env.DISTPATH }}/espefuse${{ matrix.EXTEN }} -h
56+
./${{ env.DISTPATH }}/espsecure${{ matrix.EXTEN }} -h
57+
./${{ env.DISTPATH }}/esp_rfc2217_server${{ matrix.EXTEN }} -h
58+
- name: Add license and readme
59+
shell: bash
60+
run: mv LICENSE README.md ./${{ env.DISTPATH }}
61+
- name: Archive artifact
62+
uses: actions/upload-artifact@v2
63+
with:
64+
name: ${{ env.DISTPATH }}
65+
path: ${{ env.DISTPATH }}
66+
67+
create_release:
68+
name: Create GitHub release
69+
if: startsWith(github.ref, 'refs/tags/')
70+
needs: build-esptool-binaries
71+
runs-on: ubuntu-latest
72+
outputs:
73+
upload_url: ${{ steps.create_release.outputs.upload_url }}
74+
VERSION: ${{ steps.get_version.outputs.VERSION }}
75+
steps:
76+
- name: Create release
77+
id: create_release
78+
uses: actions/create-release@v1
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
with:
82+
tag_name: ${{ github.ref }}
83+
release_name: Version ${{ github.ref }}
84+
draft: true
85+
prerelease: false
86+
- name: Get version
87+
id: get_version
88+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
89+
shell: bash
90+
91+
upload_assets:
92+
name: Upload release assets
93+
if: startsWith(github.ref, 'refs/tags/')
94+
needs: create_release
95+
runs-on: ubuntu-latest
96+
strategy:
97+
matrix:
98+
TARGET: [macos, linux-amd64, win64]
99+
env:
100+
DISTPATH: esptool-${{ needs.create_release.outputs.VERSION }}-${{ matrix.TARGET }}
101+
steps:
102+
- name: Download built binaries
103+
uses: actions/download-artifact@v2
104+
- name: Rename and package binaries
105+
run: |
106+
mv esptool-${{ matrix.TARGET }} ${{ env.DISTPATH }}
107+
zip -r ${{ env.DISTPATH }}.zip ./${{ env.DISTPATH }}/*
108+
- name: Upload release assets
109+
id: upload-release-asset
110+
uses: actions/upload-release-asset@v1
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
with:
114+
upload_url: ${{ needs.create_release.outputs.upload_url }}
115+
asset_path: "${{ env.DISTPATH }}.zip"
116+
asset_name: "${{ env.DISTPATH }}.zip"
117+
asset_content_type: application/zip

.github/workflows/publish_release.yml renamed to .github/workflows/release_esptool_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This workflow will upload an esptool Python package when a release is created
22

3-
name: Upload release to PyPI
3+
name: PyPI release
44

55
on:
66
release:
File renamed without changes.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ esptool.py was started by Fredrik Ahlberg (@[themadinventor](https://github.com/
66

77
esptool.py is Free Software under a GPLv2 license.
88

9-
[![Test esptool](https://github.com/espressif/esptool/workflows/Test%20esptool/badge.svg?branch=master)](https://github.com/espressif/esptool)
9+
[![Test esptool](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml)[![Build esptool](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml)
1010

1111
## Installation / dependencies
1212

build_tools/Sign-File.ps1

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[CmdletBinding()]
2+
param (
3+
[Parameter()]
4+
[String]
5+
$Path
6+
)
7+
8+
9+
function FindSignTool {
10+
$SignTool = "signtool.exe"
11+
if (Get-Command $SignTool -ErrorAction SilentlyContinue) {
12+
return $SignTool
13+
}
14+
$SignTool = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\x64\signtool.exe"
15+
if (Test-Path -Path $SignTool -PathType Leaf) {
16+
return $SignTool
17+
}
18+
$SignTool = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\x86\signtool.exe"
19+
if (Test-Path -Path $SignTool -PathType Leaf) {
20+
return $SignTool
21+
}
22+
"signtool.exe not found"
23+
Exit 1
24+
}
25+
26+
function SignInstaller {
27+
param(
28+
[Parameter()]
29+
[String]
30+
$Path
31+
)
32+
33+
$SignTool = FindSignTool
34+
"Using: $SignTool"
35+
$CertificateFile = [system.io.path]::GetTempPath() + "certificate.pfx"
36+
37+
if ($null -eq $env:CERTIFICATE) {
38+
"CERTIFICATE variable not set, unable to sign the file"
39+
Exit 1
40+
}
41+
42+
if ("" -eq $env:CERTIFICATE) {
43+
"CERTIFICATE variable is empty, unable to sign the file"
44+
Exit 1
45+
}
46+
47+
$SignParameters = @("sign", "/tr", 'http://timestamp.digicert.com', "/f", $CertificateFile)
48+
if ($env:CERTIFICATE_PASSWORD) {
49+
"CERTIFICATE_PASSWORD detected, using the password"
50+
$SignParameters += "/p"
51+
$SignParameters += $env:CERTIFICATE_PASSWORD
52+
}
53+
$SignParameters += $Path
54+
55+
[byte[]]$CertificateBytes = [convert]::FromBase64String($env:CERTIFICATE)
56+
[IO.File]::WriteAllBytes($CertificateFile, $CertificateBytes)
57+
58+
&$SignTool $SignParameters
59+
60+
if (0 -eq $LASTEXITCODE) {
61+
Remove-Item $CertificateFile
62+
} else {
63+
Remove-Item $CertificateFile
64+
"Signing failed"
65+
Exit 1
66+
}
67+
68+
}
69+
70+
SignInstaller ${Path}

build_tools/espressif.ico

115 KB
Binary file not shown.

0 commit comments

Comments
 (0)