-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (100 loc) · 4.03 KB
/
main.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
name: PlatformIO CI
on: [push]
jobs:
# generate workspace artifact that will be used by next job to build firmware
workspace_setup:
name: Generate workspace
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
env:
LIB_NAME: esp32-toolkit-lib
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v2
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Setup PlatformIO project
run: |
pio init --board esp32doit-devkit-v1
# cd lib/ && git clone [email protected]/GITHUB_REPOSITORY
- uses: actions/checkout@v3
with:
# fetch-depth: 0
path: lib/${{ env.LIB_NAME }}
- name: Configure workspace
env:
MKLITTLEFS_BIN_URL: "https://github.com/earlephilhower/mklittlefs/releases/download/3.0.0/x86_64-linux-gnu-mklittlefs-295fe9b.tar.gz"
DIGIPOT_LIB_URL: "https://electropeak.com/learn/wp-content/uploads/2021/02/DigiPotX9Cxxx.zip"
run: |
rm platformio.ini # remove default pio config to allow symlink to custom config later
# @todo check if sym link can be included in workspace artifact
# rm platformio.ini && ln -s lib/$LIB_NAME/.config/platformio.ini platformio.ini
# ln -s lib/$LIB_NAME/.config/.gitmodules .gitmodules
# ln -s lib/$LIB_NAME/.config/scripts/replace_fs.py replace_fs.py
# ln -s ../lib/$LIB_NAME/.config/main.cpp src/main.cpp
cd lib/$LIB_NAME && git remote set-url origin [email protected]:$GITHUB_REPOSITORY.git
cd /home/runner/work/
wget -O mklittlefs.tar.gz $MKLITTLEFS_BIN_URL && tar -xf mklittlefs.tar.gz && mv mklittlefs/mklittlefs $GITHUB_WORKSPACE
wget $DIGIPOT_LIB_URL && unzip DigiPotX9Cxxx.zip && mv DigiPotX9Cxxx/ $GITHUB_WORKSPACE/lib/
ls -laR $GITHUB_WORKSPACE
- name: Workspace artifact
uses: actions/upload-artifact@v2
with:
name: pio-workspace-artifact
path: |
./
# This job retrieve workspace artifact from previous job and builds firmware
build_firmware:
name: Build firmware
needs: workspace_setup
runs-on: ubuntu-latest
env:
LIB_NAME: esp32-toolkit-lib
PIO_ENV_CONF: esp32-latest
FIRMWARE_SRC: firmware-main.cpp # firmware source file to build
steps:
- name: Retrieve workspace artifact
uses: actions/download-artifact@v2
with:
name: pio-workspace-artifact
- name: Create symlinks
run: |
ln -s lib/esp32-toolkit-lib/.config/platformio.ini platformio.ini
ln -s lib/esp32-toolkit-lib/.config/.gitmodules .gitmodules
ln -s lib/esp32-toolkit-lib/.config/scripts/replace_fs.py replace_fs.py
mkdir src && ln -s ../lib/esp32-toolkit-lib/examples/firmware-main.cpp src/main.cpp
- name: Show final workspace structure
run: |
# cat platformio.ini
ls -laR
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Build project
run: |
# link to selected firmware source file
rm src/main.cpp && ln -s ../lib/$LIB_NAME/examples/$FIRMWARE_SRC src/main.cpp
pio run -e $PIO_ENV_CONF
- name: Firmware artifact
uses: actions/upload-artifact@v2
with:
name: firmware-release
path: |
.pio/build/${{ env.PIO_ENV_CONF }}/firmware.bin