Fixes. #15
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
# Copyright (C) 2023 Toitware ApS. | |
# | |
# This library is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU Lesser General Public | |
# License as published by the Free Software Foundation; version | |
# 2.1 only. | |
# | |
# This library is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
# Lesser General Public License for more details. | |
name: Build esptool | |
on: | |
push: | |
pull_request: | |
release: | |
types: [published] | |
jobs: | |
build-esptool-binaries: | |
name: Build esptool binaries for ${{ matrix.arch }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [armv7, aarch64, riscv64, s390x, ppc64le] | |
env: | |
STUBS_DIR: ./esptool/targets/stub_flasher/ | |
EFUSE_DIR: ./espefuse/efuse_defs/ | |
steps: | |
- name: Set Swap Space | |
uses: pierotofy/set-swap-space@v1.0 | |
with: | |
swap-size-gb: 12 | |
- name: Workaround cargo issue | |
run: | | |
# Workaround for https://github.com/rust-lang/cargo/issues/8719 | |
sudo mkdir -p /var/lib/docker | |
sudo mount -t tmpfs -o size=12G none /var/lib/docker | |
sudo systemctl restart docker | |
- name: Checkout repository | |
uses: actions/checkout@master | |
- name: Patch esptool requirements | |
if: matrix.arch == 'riscv64' | |
# We don't want to use the cryptography package that uses rust. | |
# The rust that is installed on riscv64 is only 1.41.0, but the | |
# cryptography package requires 1.48.0. | |
# The latest version that can still be installed without rust is 3.4.8. | |
run: | | |
sed -i 's/cryptography/cryptography<=3.4.8/' setup.py | |
- name: Create directory for artifacts | |
run: mkdir -p ${{ matrix.arch }} | |
- uses: uraimo/run-on-arch-action@v2 | |
name: Build in ${{ matrix.arch }} | |
with: | |
arch: ${{ matrix.arch }} | |
distro: ubuntu20.04 | |
githubToken: ${{ github.token }} | |
dockerRunArgs: | | |
--volume "${PWD}:/sources" | |
install: | | |
apt-get update -q -y | |
apt-get install -q -y --no-install-recommends \ | |
python3 python3-pip python3-setuptools python3-wheel python3-dev \ | |
libffi-dev \ | |
libssl-dev \ | |
rustc cargo \ | |
build-essential \ | |
pkg-config \ | |
git \ | |
curl \ | |
wget \ | |
unzip \ | |
zip | |
apt install python-is-python3 | |
shell: /bin/bash | |
run: | | |
adduser --disabled-password --gecos "" builder | |
chmod -R a+rwx /sources | |
su builder <<EOF | |
# The following line really speeds up cargo in the docker container. | |
# Via https://github.com/rust-lang/cargo/issues/10781#issuecomment-1351670409 | |
export CARGO_NET_GIT_FETCH_WITH_CLI=true | |
set -e | |
export PATH=\$PATH:/home/builder/.local/bin | |
echo \$HOME | |
echo \$PATH | |
cd /sources | |
python -m pip install --upgrade pip | |
pip install pyinstaller | |
pip install --user -e . | |
pyinstaller --distpath ./${{ matrix.arch }} -F --icon=ci/espressif.ico --add-data="${{ env.STUBS_DIR }}*.json:${{ env.STUBS_DIR }}" esptool.py | |
pyinstaller --distpath ./${{ matrix.arch }} -F --icon=ci/espressif.ico --add-data="${{ env.EFUSE_DIR }}*.yaml:${{ env.EFUSE_DIR }}" espefuse.py | |
pyinstaller --distpath ./${{ matrix.arch }} -F --icon=ci/espressif.ico espsecure.py | |
pyinstaller --distpath ./${{ matrix.arch }} -F --icon=ci/espressif.ico esp_rfc2217_server.py | |
./${{ matrix.arch }}/esptool -h | |
./${{ matrix.arch }}/espefuse -h | |
./${{ matrix.arch }}/espsecure -h | |
./${{ matrix.arch }}/esp_rfc2217_server -h | |
find ./${{ matrix.arch }} | |
EOF | |
- name: Add license and readme | |
shell: bash | |
run: | | |
find ./${{ matrix.arch }} | |
mv LICENSE README.md ./${{ matrix.arch }} | |
- name: Set archive variables (release) | |
if: github.event_name == 'release' | |
run: | | |
echo "ARCHIVE_NAME=esptool-${{ github.event.release.tag_name }}-linux-${{ matrix.arch }}" >> $GITHUB_ENV | |
- name: Set archive variables | |
if: github.event_name != 'release' | |
run: | | |
echo "ARCHIVE_NAME=esptool-${{ matrix.arch }}" >> $GITHUB_ENV | |
- name: Create archive | |
run: | | |
mv ./${{ matrix.arch }} $ARCHIVE_NAME | |
# Zip files lose the permissions of binaries, but that's what Espressif uses... | |
zip -r $ARCHIVE_NAME.zip $ARCHIVE_NAME | |
- name: Archive artifact | |
uses: actions/upload-artifact@master | |
with: | |
name: ${{ env.ARCHIVE_NAME }} | |
path: ${{ env.ARCHIVE_NAME }}.zip | |
- name: Upload release artifact | |
if: github.event_name == 'release' | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.ARCHIVE_NAME }}.zip | |
tag: ${{ github.ref }} | |
overwrite: true |