Repository navigation
151 lines (131 loc) · 6.5 KB
/
Copy pathmain.yml
File metadata and controls
151 lines (131 loc) · 6.5 KB
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
147
148
149
150
151
name: Build binary
on:
push:
tags:
- '**' # but DO run on any tag (including tags on main)
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write # release builds open a PR adding the binaries to binaries/
env:
ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS: "http://arduino.esp8266.com/stable/package_esp8266com_index.json https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set version env var
run: echo "GIT_SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
shell: bash
- name: Set build type env var
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "BUILD_TYPE=Release" >> $GITHUB_ENV
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" = "schedule" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "BUILD_TYPE=Nightly" >> $GITHUB_ENV
echo "VERSION=Nightly-${{ env.GIT_SHORT_SHA }}" >> $GITHUB_ENV
else
echo "BUILD_TYPE=Alpha" >> $GITHUB_ENV
echo "VERSION=Alpha-${{ env.GIT_SHORT_SHA }}" >> $GITHUB_ENV
fi
shell: bash
- name: Update version.h
if: github.ref != 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
run: |
cd HeishaMon && sed -i 's/#define HEISHAMON_VERSION .*/#define HEISHAMON_VERSION "${{ env.VERSION }}"/' version.h && cat version.h
shell: bash
- name: Setup Arduino CLI
uses: arduino/setup-arduino-cli@v2
- name: Install platform
run: |
arduino-cli core update-index
arduino-cli core install esp8266:esp8266
arduino-cli core install esp32:esp32@3.3.11
- name: Install dependencies
run: arduino-cli lib install ringbuffer pubsubclient arduinojson dallastemperature onewire "Adafruit NeoPixel"
- name: Compile Sketch for ESP8266
run: cd HeishaMon && arduino-cli compile --output-dir . --fqbn=esp8266:esp8266:d1_mini:xtal=160,vt=flash,ssl=basic,mmu=3216,non32xfer=fast,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600 --warnings=none --verbose HeishaMon.ino
- name: Add MD5 checksum to ESP8266 binary
run: |
cd HeishaMon
MD5=`md5sum HeishaMon.ino.bin | cut -d\ -f1`
mv HeishaMon.ino.bin HeishaMon_ESP8266-${{ env.BUILD_TYPE }}-$MD5.bin
echo "MD5_ESP8266=$MD5" >> $GITHUB_ENV
shell: bash
- name: Compile Sketch for ESP32
run: cd HeishaMon && arduino-cli compile --output-dir . --fqbn=esp32:esp32:esp32s3:CDCOnBoot=cdc,PSRAM=enabled,PartitionScheme=min_spiffs --warnings=none --verbose HeishaMon.ino
- name: Add MD5 checksum to ESP32 binary
run: |
cd HeishaMon
MD5=`md5sum HeishaMon.ino.bin | cut -d\ -f1`
mv HeishaMon.ino.bin HeishaMon_ESP32-${{ env.BUILD_TYPE }}-$MD5.bin
echo "MD5_ESP32=$MD5" >> $GITHUB_ENV
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: Heishamon-firmware-${{ env.BUILD_TYPE }}-${{ env.GIT_SHORT_SHA }}
path: |
HeishaMon/HeishaMon_*.bin
HeishaMon/HeishaMon.ino.map
- name: Delete old nightly assets
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
run: |
gh release view nightly --json assets --jq '.assets[].name' | \
xargs -I{} gh release delete-asset nightly {} --yes || true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Publish nightly release
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
uses: softprops/action-gh-release@v3
with:
tag_name: nightly
name: "Nightly build (${{ env.GIT_SHORT_SHA }})"
body: |
Automated nightly build from `main` branch.
Commit: ${{ github.sha }}
Built: ${{ github.run_id }}
prerelease: true
files: HeishaMon/HeishaMon_*.bin
- name: Publish release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v3
with:
name: "Release ${{ github.ref_name }}"
body: |
Release ${{ github.ref_name }}
Commit: ${{ github.sha }}
prerelease: true
files: HeishaMon/HeishaMon_*.bin
- name: Open PR adding release binaries to binaries/
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
BRANCH="release-binaries-$TAG"
# Work on a clean checkout of main, the tag checkout has a modified version.h
git fetch --depth=1 origin +refs/heads/main:refs/remotes/origin/main
git worktree add -b "$BRANCH" ../release-binaries origin/main
cp "HeishaMon/HeishaMon_ESP32-Release-$MD5_ESP32.bin" "../release-binaries/binaries/model-type-large/HeishaMon.ino.esp32-$TAG.bin"
echo -n "$MD5_ESP32" > "../release-binaries/binaries/model-type-large/HeishaMon.ino.esp32-$TAG.md5"
cp "HeishaMon/HeishaMon_ESP8266-Release-$MD5_ESP8266.bin" "../release-binaries/binaries/model-type-small/HeishaMon.ino.d1-$TAG.bin"
echo -n "$MD5_ESP8266" > "../release-binaries/binaries/model-type-small/HeishaMon.ino.d1-$TAG.md5"
cd ../release-binaries
sed -i "s/^The latest production release is .*\./The latest production release is $TAG./" binaries/README.md
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add binaries/
git commit -m "release $TAG binaries"
git push origin "$BRANCH"
gh pr create --base main --head "$BRANCH" \
--title "Release $TAG binaries" \
--body "Adds the $TAG firmware built by release run ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} to binaries/ and updates binaries/README.md."
shell: bash