forked from espressif/esptool
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (125 loc) · 4.93 KB
/
build.yml
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
# 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 cross
on:
push:
release:
types: [published]
jobs:
build-cross-esptool-binaries:
name: esptool - ${{ 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
run: |
export ARCHIVE_NAME=esptool-linux-${{ matrix.arch }}
echo "ARCHIVE_NAME=$ARCHIVE_NAME" >> $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