Skip to content

Commit be44b46

Browse files
authored
Merge pull request #10131 from iNavFlight/mmosca-update-github-actions
Attempt at building master on sucessfull push
2 parents 6792407 + e2e37c7 commit be44b46

4 files changed

Lines changed: 244 additions & 4 deletions

File tree

.github/workflows/dev-builds.yml

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
name: Build pre-release
2+
# Don't enable CI on push, just on PR. If you
3+
# are working on the main repo and want to trigger
4+
# a CI build submit a draft PR.
5+
on:
6+
push:
7+
branches:
8+
- master
9+
mmosca-update-github-actions
10+
#pull_request:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
id: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Install dependencies
22+
run: sudo apt-get update && sudo apt-get -y install ninja-build
23+
- name: Setup environment
24+
env:
25+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
26+
run: |
27+
# This is the hash of the commit for the PR
28+
# when the action is triggered by PR, empty otherwise
29+
COMMIT_ID=${{ github.event.pull_request.head.sha }}
30+
# This is the hash of the commit when triggered by push
31+
# but the hash of refs/pull/<n>/merge, which is different
32+
# from the hash of the latest commit in the PR, that's
33+
# why we try github.event.pull_request.head.sha first
34+
COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
35+
BUILD_SUFFIX=dev-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
36+
VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/^[ \t]+|[ \t\)]+$/, "", $2); print $2 }')
37+
echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
38+
echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV
39+
- uses: actions/cache@v4
40+
with:
41+
path: downloads
42+
key: ${{ runner.os }}-downloads-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('**/cmake/*')}}
43+
- name: Build targets (${{ matrix.id }})
44+
run: mkdir -p build && cd build && cmake -DWARNINGS_AS_ERRORS=ON -DCI_JOB_INDEX=${{ matrix.id }} -DCI_JOB_COUNT=${{ strategy.job-total }} -DBUILD_SUFFIX=${{ env.BUILD_SUFFIX }} -DVERSION_TYPE=dev -G Ninja .. && ninja ci
45+
- name: Upload artifacts
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: ${{ env.BUILD_NAME }}.${{ matrix.id }}
49+
path: ./build/*.hex
50+
51+
build-SITL-Linux:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
- name: Install dependencies
56+
run: sudo apt-get update && sudo apt-get -y install ninja-build
57+
- name: Setup environment
58+
env:
59+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
60+
run: |
61+
# This is the hash of the commit for the PR
62+
# when the action is triggered by PR, empty otherwise
63+
COMMIT_ID=${{ github.event.pull_request.head.sha }}
64+
# This is the hash of the commit when triggered by push
65+
# but the hash of refs/pull/<n>/merge, which is different
66+
# from the hash of the latest commit in the PR, that's
67+
# why we try github.event.pull_request.head.sha first
68+
COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
69+
BUILD_SUFFIX=dev-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
70+
VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/[ \t\)]+/, "", $2); print $2 }')
71+
echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
72+
echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV
73+
- name: Build SITL
74+
run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -G Ninja -DVERSION_TYPE=dev .. && ninja
75+
- name: Upload artifacts
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: sitl-${{ env.BUILD_NAME }}-Linux
79+
path: ./build_SITL/*_SITL
80+
81+
build-SITL-Mac:
82+
runs-on: macos-latest
83+
steps:
84+
- uses: actions/checkout@v4
85+
- name: Install dependencies
86+
run: |
87+
brew install cmake ninja ruby
88+
89+
- name: Setup environment
90+
env:
91+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
92+
run: |
93+
# This is the hash of the commit for the PR
94+
# when the action is triggered by PR, empty otherwise
95+
COMMIT_ID=${{ github.event.pull_request.head.sha }}
96+
# This is the hash of the commit when triggered by push
97+
# but the hash of refs/pull/<n>/merge, which is different
98+
# from the hash of the latest commit in the PR, that's
99+
# why we try github.event.pull_request.head.sha first
100+
COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
101+
BUILD_SUFFIX=dev-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
102+
VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/[ \t\)]+/, "", $2); print $2 }')
103+
echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
104+
echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV
105+
- name: Build SITL
106+
run: |
107+
mkdir -p build_SITL && cd build_SITL
108+
cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DVERSION_TYPE=dev -G Ninja ..
109+
ninja
110+
111+
- name: Upload artifacts
112+
uses: actions/upload-artifact@v4
113+
with:
114+
name: sitl-${{ env.BUILD_NAME }}-MacOS
115+
path: ./build_SITL/*_SITL
116+
117+
build-SITL-Windows:
118+
runs-on: windows-latest
119+
defaults:
120+
run:
121+
shell: C:\tools\cygwin\bin\bash.exe -o igncr '{0}'
122+
steps:
123+
- uses: actions/checkout@v4
124+
- name: Setup Cygwin
125+
uses: egor-tensin/setup-cygwin@v4
126+
with:
127+
packages: cmake ruby ninja gcc-g++
128+
- name: Setup environment
129+
env:
130+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
131+
run: |
132+
# This is the hash of the commit for the PR
133+
# when the action is triggered by PR, empty otherwise
134+
COMMIT_ID=${{ github.event.pull_request.head.sha }}
135+
# This is the hash of the commit when triggered by push
136+
# but the hash of refs/pull/<n>/merge, which is different
137+
# from the hash of the latest commit in the PR, that's
138+
# why we try github.event.pull_request.head.sha first
139+
COMMIT_ID=${COMMIT_ID:-${{ github.sha }}}
140+
BUILD_SUFFIX=dev-$(date '+%Y%m%d')-$(git rev-parse --short ${COMMIT_ID})
141+
VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/[ \t\)]+/, "", $2); print $2 }')
142+
#echo "BUILD_SUFFIX=${BUILD_SUFFIX}" >> $GITHUB_ENV
143+
#echo "BUILD_NAME=inav-${VERSION}-${BUILD_SUFFIX}" >> $GITHUB_ENV
144+
#echo "VERSION_TAG=-$(date '+%Y%m%d')" >> $GITHUB_ENV
145+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
146+
- name: Build SITL
147+
run: mkdir -p build_SITL && cd build_SITL && cmake -DSITL=ON -DWARNINGS_AS_ERRORS=ON -DVERSION_TYPE=dev -G Ninja .. && ninja
148+
- name: Upload artifacts
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: sitl-${{ env.BUILD_NAME }}-WIN
152+
path: ./build_SITL/*.exe
153+
154+
155+
test:
156+
runs-on: ubuntu-latest
157+
steps:
158+
- uses: actions/checkout@v4
159+
- name: Install dependencies
160+
run: sudo apt-get update && sudo apt-get -y install ninja-build
161+
- name: Run Tests
162+
run: mkdir -p build && cd build && cmake -DTOOLCHAIN=none -G Ninja .. && ninja check
163+
164+
release:
165+
needs: [build, build-SITL-Linux, build-SITL-Mac, build-SITL-Windows, test]
166+
runs-on: ubuntu-latest
167+
steps:
168+
- uses: actions/checkout@v4
169+
- name: Get version
170+
id: version
171+
run: |
172+
VERSION=$(grep project CMakeLists.txt|awk -F VERSION '{ gsub(/[ \t\)]+/, "", $2); print $2 }')
173+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
174+
- name: Get current date
175+
id: date
176+
run: echo "today=$(date '+%Y%m%d')" >> $GITHUB_OUTPUT
177+
- name: download artifacts
178+
uses: actions/download-artifact@v4
179+
with:
180+
path: hexes
181+
pattern: inav-*
182+
merge-multiple: true
183+
- name: download sitl linux
184+
uses: actions/download-artifact@v4
185+
with:
186+
path: resources/sitl/linux
187+
pattern: sitl-*-Linux
188+
merge-multiple: true
189+
- name: download sitl windows
190+
uses: actions/download-artifact@v4
191+
with:
192+
path: resources/sitl/windows
193+
pattern: sitl-*-WIN
194+
merge-multiple: true
195+
- name: download sitl mac
196+
uses: actions/download-artifact@v4
197+
with:
198+
path: resources/sitl/macos
199+
pattern: sitl-*-MacOS
200+
merge-multiple: true
201+
- name: Consolidate sitl files
202+
run: |
203+
zip -r -9 sitl-resources.zip resources/
204+
- name: Upload release artifacts
205+
uses: softprops/action-gh-release@v2
206+
with:
207+
name: inav-${{ steps.version.outputs.version }}-dev-${{ steps.date.outputs.today }}-${{ github.run_number }}-${{ github.sha }}
208+
tag_name: v${{ steps.date.outputs.today }}.${{ github.run_number }}
209+
# To create release on a different repo, we need a token setup
210+
token: ${{ secrets.NIGHTLY_TOKEN }}
211+
repository: iNavFlight/inav-nightly
212+
prerelease: true
213+
draft: false
214+
#generate_release_notes: true
215+
make_latest: false
216+
files: |
217+
hexes/*.hex
218+
sitl-resources.zip
219+
body: |
220+
${{ steps.notes.outputs.notes }}
221+
222+
### Repository:
223+
${{ github.repository }} ([link](${{ github.event.repository.html_url }}))
224+
225+
### Branch:
226+
${{ github.ref_name }} ([link](${{ github.event.repository.html_url }}/tree/${{ github.ref_name }}))
227+
228+
### Latest changeset:
229+
${{ github.event.head_commit.id }} ([link](${{ github.event.head_commit.url }}))
230+
231+
### Changes:
232+
${{ github.event.head_commit.message }}
233+

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ set(COMMON_COMPILE_DEFINITIONS
7979
FC_VERSION_MAJOR=${CMAKE_PROJECT_VERSION_MAJOR}
8080
FC_VERSION_MINOR=${CMAKE_PROJECT_VERSION_MINOR}
8181
FC_VERSION_PATCH_LEVEL=${CMAKE_PROJECT_VERSION_PATCH}
82+
FC_VERSION_TYPE="${VERSION_TYPE}"
8283
)
8384

8485
if (NOT SITL)

src/main/build/version.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
#define STR_HELPER(x) #x
1919
#define STR(x) STR_HELPER(x)
2020
#define FC_VERSION_STRING STR(FC_VERSION_MAJOR) "." STR(FC_VERSION_MINOR) "." STR(FC_VERSION_PATCH_LEVEL)
21+
#ifndef FC_VERSION_TYPE
22+
#define FC_VERSION_TYPE ""
23+
#endif
2124
#define FC_FIRMWARE_NAME "INAV"
2225

26+
2327
#define MW_VERSION 231
2428

2529
extern const char* const compilerVersion;

src/main/fc/cli.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3662,13 +3662,14 @@ static void cliStatus(char *cmdline)
36623662
char buf[MAX(FORMATTED_DATE_TIME_BUFSIZE, SETTING_MAX_NAME_LENGTH)];
36633663
dateTime_t dt;
36643664

3665-
cliPrintLinef("%s/%s %s %s / %s (%s)",
3665+
cliPrintLinef("%s/%s %s %s / %s (%s) %s",
36663666
FC_FIRMWARE_NAME,
36673667
targetName,
36683668
FC_VERSION_STRING,
36693669
buildDate,
36703670
buildTime,
3671-
shortGitRevision
3671+
shortGitRevision,
3672+
FC_VERSION_TYPE
36723673
);
36733674
cliPrintLinef("GCC-%s",
36743675
compilerVersion
@@ -3906,13 +3907,14 @@ static void cliVersion(char *cmdline)
39063907
{
39073908
UNUSED(cmdline);
39083909

3909-
cliPrintLinef("# %s/%s %s %s / %s (%s)",
3910+
cliPrintLinef("# %s/%s %s %s / %s (%s) %s",
39103911
FC_FIRMWARE_NAME,
39113912
targetName,
39123913
FC_VERSION_STRING,
39133914
buildDate,
39143915
buildTime,
3915-
shortGitRevision
3916+
shortGitRevision,
3917+
FC_VERSION_TYPE
39163918
);
39173919
cliPrintLinef("# GCC-%s",
39183920
compilerVersion

0 commit comments

Comments
 (0)