-
Notifications
You must be signed in to change notification settings - Fork 1
187 lines (155 loc) · 6.56 KB
/
build_fw.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Build firmware
on:
# Triggers the workflow on push or pull request events but only for the "SPACEDOS03A" branch
push:
#branches: [ "LABDOS01A" ]
paths:
- 'fw/**'
- '*/*.yml'
workflow_dispatch:
workflow_call:
inputs:
build_type:
required: false
type: string
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: AIRDOS04
type: AIRDOS04
channels: 0
fqbn: clock=8MHz_external
- name: AIRDOS04X
type: AIRDOS04X
channels: 0
fqbn: clock=8MHz_external
# - name: LABDOS_1024
# type: LABDOS
# channels: 1024
# fqbn: clock=8MHz_external
# - name: LABDOS_512_16Mhz
# type: LABDOS
# fqbn: clock=16MHz_external
# channels: 512
# - name: LABDOS_1024_16Mhz
# type: LABDOS
# fqbn: clock=16MHz_external
# channels: 1024
# - name: UAVDOS
# type: UAVDOS
# fqbn: clock=8MHz_external
# channels: 0
steps:
- name: Checkout
uses: actions/checkout@v3
continue-on-error: true
with:
submodules: False
- name: Update githash.h and compile
run: |
BUILD_TYPE="${{ inputs.build_type }}"
BT="CIBuild"
if [ "$BUILD_TYPE" = "B" ]; then
BT="Beta"
fi
if [ "$BUILD_TYPE" = "R" ]; then
BT="Release"
fi
PREVMAJOR=`cat fw/${{ matrix.type }}/nextversion|grep MAJOR|cut -d ' ' -f 2`
PREVMINOR=`cat fw/${{ matrix.type }}/nextversion|grep MINOR|cut -d ' ' -f 2`
NEXTRELEASE=`cat fw/${{ matrix.type }}/nextversion|grep RELEASE|cut -d ' ' -f 2`
NEXTBUILD=`cat fw/${{ matrix.type }}/nextversion|grep BUILD|cut -d ' ' -f 2`
CURMAJOR=`cat fw/${{ matrix.type }}/${{ matrix.type }}.ino|grep MAJOR|head -n 1|cut -d ' ' -f 3`
CURMINOR=`cat fw/${{ matrix.type }}/${{ matrix.type }}.ino|grep MINOR|head -n 1|cut -d ' ' -f 3`
if [ "$CURMAJOR" = "$PREVMAJOR" ] && [ "$CURMINOR" = "$PREVMINOR" ]; then
echo "Same version"
else
echo "New version, set release to 0"
NEXTRELEASE=0
fi
echo "// This file is overwritten by github actions, do not update it manually" > githash.h
echo "String githash = \"${{ github.sha }},${BT}\";" >> githash.h
echo "#define GHRELEASE ${NEXTRELEASE}" >> githash.h
echo "#define GHBUILD ${NEXTBUILD}" >> githash.h
echo "#define GHBUILDTYPE ${BT}" >> githash.h
mv githash.h fw/${{ matrix.type }}/
sudo snap install arduino-cli
arduino-cli core update-index --additional-urls https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json,https://mcudude.github.io/MightyCore/package_MCUdude_MightyCore_index.json > /dev/null
arduino-cli core install MightyCore:avr --additional-urls https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json,https://mcudude.github.io/MightyCore/package_MCUdude_MightyCore_index.json > /dev/null
arduino-cli lib install "SHT31"
arduino-cli lib install "MS5611"
PLATFORM=MightyCore:avr
arduino-cli compile --verbose --warnings all --fqbn MightyCore:avr:1284:BOD=disabled,LTO=Os,${{ matrix.fqbn }},variant=modelP --build-property compiler.cpp.extra_flags="-DCHANNELS=${{ matrix.channels }}" --build-path fw/${{ matrix.type }}/build/ fw/${{ matrix.type }}
cd fw/${{ matrix.type }}/build/
find -type f -name "*.hex" -exec bash -c 'mv $0 fw_${{ matrix.type }}_${{ matrix.name }}.'"${NEXTBUILD}-${BT}"'$(echo $0|sed -e "s/\.\///1"|sed -e "s/${{ matrix.type }}\.ino//g")' {} \;
cd ../../..
rm fw/build -r || true
mv fw/${{ matrix.type }}/build fw/build
NEXTBUILD=`echo $NEXTBUILD"+1"|bc`
if [ "$BUILD_TYPE" = "R" ]; then
NEXTRELEASE=`echo $NEXTRELEASE"+1"|bc`
fi
echo "#this file is maintained by github actions" > nextversion
echo "MAJOR ${CURMAJOR}" >> nextversion
echo "MINOR ${CURMINOR}" >> nextversion
echo "RELEASE ${NEXTRELEASE}" >> nextversion
echo "BUILD ${NEXTBUILD}" >> nextversion
echo "// This file is overwritten by github actions, do not update it manually" > githash.h
echo "String githash = \"${{ github.sha }},User\";" >> githash.h
echo "#define GHRELEASE ${NEXTRELEASE}" >> githash.h
echo "#define GHBUILD 0" >> githash.h
echo "#define GHBUILDTYPE User" >> githash.h
mv nextversion fw/${{ matrix.type }}/
mv githash.h fw/${{ matrix.type }}/
touch root
- name: Store data
uses: actions/upload-artifact@v3
with:
name: fw_${{ matrix.type }}_${{ matrix.name }}
path: |
fw/build/*.hex
fw/${{ matrix.type }}/nextversion
fw/${{ matrix.type }}/githash.h
root
retention-days: 1
commit:
if: github.event_name != 'release' #&& github.event.action == 'created'
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
continue-on-error: true
with:
submodules: True
- run: |
rm fw/build -r || true
mkdir fw/build
mkdir fw/artifacts
- name: Download a Build Artifact
uses: actions/[email protected]
with:
path: 'fw/artifacts/'
- name: Update git hash
run: |
for d in `ls fw/artifacts`;
do
cp -R fw/artifacts/$d/* ./ ||true
done
rm -rf fw/artifacts
rm -rf root
git status
- name: Get last commit message
id: last-commit-message
run: |
echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: ${{ steps.last-commit-message.outputs.msg }}, extended build
file_pattern: 'fw/build/* fw/AIRDOS04/githash.h fw/AIRDOS04/nextversion'
#commit_options: '--amend --no-edit'
#push_options: '--force'
skip_fetch: true