-
Notifications
You must be signed in to change notification settings - Fork 15
143 lines (138 loc) · 5.86 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
name: NodeMCU Custom Build
on:
push:
branches:
- master
- builds
pull_request:
branches:
- master
- builds
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Log the build config
run: cat build.config
# When you run a script it gets its own shell and its own environment, which disappear again as soon as the
# script is finished. Besides, each step uses its own environment with no shared global space for dynamic env
# variables. Work-around: write "export FOO=bar" entries to a file and source it in every step that needs those.
# Idea: https://github.com/actions/starter-workflows/issues/68#issuecomment-642514933
- name: Prepare environment variables
run: ./export-env-vars.sh
- name: Upload artifact '.env-vars'
uses: actions/upload-artifact@v4
with:
name: env-vars
path: ./.env-vars
retention-days: 5
include-hidden-files: true
- name: Trigger sending the start-build email
run: |
source ./.env-vars
wget -d -v -O/dev/null --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused 'https://nodemcu-build.com/hook.php?event=start&recipient='${X_EMAIL//+/%2B}
- name: Determine Python version
run: |
source ./.env-vars
echo "python_version=3.8" >> $GITHUB_ENV
if [ "$X_BRANCH" = "1.5.4.1-final" ]; then echo "python_version=2.7" >> $GITHUB_ENV; fi
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.python_version }}
- name: Install Python dependencies
run: python -m pip install --upgrade pip
- name: Install APT dependencies
run: sudo apt install python3-serial srecord gperf
- name: Clone NodeMCU repo
run: |
source ./.env-vars
git clone --depth=1 --branch=$X_BRANCH --recursive https://github.com/nodemcu/nodemcu-firmware nodemcu-firmware
ls -alrt
cd nodemcu-firmware
ls -altr
- name: Cache the 'cache' dir
uses: actions/cache@v2
env:
cache-name: cache-artifacts
with:
path: ./nodemcu-firmware/cache
key: ${{ runner.os }}
- name: Run install.sh
run: |
source ./.env-vars
cd nodemcu-firmware
if [ "$X_BRANCH" = "dev-esp32-idf3-final" ]; then bash "$GITHUB_WORKSPACE"/ESP32/install.sh; else bash "$GITHUB_WORKSPACE"/ESP8266/install.sh; fi
- name: Run before-script.sh
run: |
source ./.env-vars
cd nodemcu-firmware
if [ "$X_BRANCH" = "dev-esp32-idf3-final" ]; then bash "$GITHUB_WORKSPACE"/ESP32/before-script.sh; else bash "$GITHUB_WORKSPACE"/ESP8266/before-script.sh; fi
- name: Run script.sh
run: |
source ./.env-vars
cd nodemcu-firmware
if [ "$X_BRANCH" = "dev-esp32-idf3-final" ]; then bash "$GITHUB_WORKSPACE"/ESP32/script.sh; else bash "$GITHUB_WORKSPACE"/ESP8266/script.sh; fi
- name: Upload artifacts in 'nodemcu-firmware/bin'
uses: actions/upload-artifact@v4
with:
name: bin-folder
path: nodemcu-firmware/bin
retention-days: 5
upload:
needs: build
runs-on: ubuntu-20.04
steps:
- name: Download artifacts 'nodemcu-firmware/bin' from build job
uses: actions/download-artifact@v4
with:
name: bin-folder
- name: Download artifact '.env-vars' from build job
uses: actions/download-artifact@v4
with:
name: env-vars
- name: Archive binaries on nodemcu-build.com
env:
TOKEN: ${{ secrets.ARCHIVER_TOKEN }}
run: |
ls -alrt
file_name_float=$(find . -name "nodemcu-*float*.bin" -type f -exec basename {} \;)
file_name_integer=$(find . -name "nodemcu-*integer*.bin" -type f -exec basename {} \;)
echo "export file_name_float=""$file_name_float""" >> ./.env-vars
echo "export file_name_integer=""$file_name_integer""" >> ./.env-vars
curl --connect-timeout 10 --max-time 120 --retry 5 --retry-delay 10 -F token=$TOKEN -F file=@$file_name_float https://nodemcu-build.com/archiver.php
curl --connect-timeout 10 --max-time 120 --retry 5 --retry-delay 10 -F token=$TOKEN -F file=@$file_name_integer https://nodemcu-build.com/archiver.php
- name: Upload artifact '.env-vars'
uses: actions/upload-artifact@v4
with:
name: env-vars
path: ./.env-vars
retention-days: 5
overwrite: true
include-hidden-files: true
notify:
needs: upload
runs-on: ubuntu-20.04
if: always()
steps:
# You can get conclusion via ${{ env.WORKFLOW_CONCLUSION }} # neutral, success, skipped, cancelled, timed_out, action_required, failure
- uses: technote-space/workflow-conclusion-action@v2
- name: Download artifact '.env-vars' from build and upload jobs
uses: actions/download-artifact@v4
with:
name: env-vars
- name: Trigger sending success email to author
if: env.WORKFLOW_CONCLUSION == 'success'
run: |
source ./.env-vars
wget -d -v -O/dev/null --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused 'https://nodemcu-build.com/hook.php?event=success&recipient='${X_EMAIL//+/%2B}'&branch='$X_BRANCH'&modules='$X_MODULES'&artifacts='${file_name_float},${file_name_integer}
- name: Trigger sending failure email to author
if: env.WORKFLOW_CONCLUSION == 'failure'
run: |
source ./.env-vars
wget -d -v -O/dev/null --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused 'https://nodemcu-build.com/hook.php?event=failure&recipient='${X_EMAIL//+/%2B}