Skip to content

Commit

Permalink
Have firmware version be assigned by git + Create draft release from …
Browse files Browse the repository at this point in the history
…new tag build
  • Loading branch information
loucass003 committed Nov 8, 2024
1 parent 50fa801 commit c58f0e4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ name: Build

on:
push:
branches:
- main
pull_request:
workflow_dispatch:
create:

jobs:
build:
Expand Down Expand Up @@ -35,3 +39,12 @@ jobs:
with:
name: binaries
path: ./build/*.bin

- name: Upload to draft release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
generate_release_notes: true
files: |
./build/BOARD_SLIMEVR-firmware.bin
35 changes: 34 additions & 1 deletion scripts/get_git_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,37 @@
except Exception:
revision = "NOT_GIT"

print(f"'-DGIT_REV=\"{revision}\"'")
tag = ""
try:
tag = (
subprocess.check_output["git", "--no-pager", "tag", "--sort", "-taggerdate", "--points-at" , "HEAD"]
.split("\n")[0]
.strip()
.decode("utf-8")
)

if tag.startswith("v"):
tag = tag[1:]
except Exception:
tag = ""

branch = ""
try:
branch = (
subprocess.check_output["git", "symbolic-ref", "--short", "-q", "HEAD"]
.strip()
.decode("utf-8")
)
except Exception:
branch = ""

output = f'-DGIT_REV=\"{revision}\"'

if tag != "":
output += f' -DFIRMWARE_VERSION=\"{tag}\"'
if tag == "" and branch != "":
output += f' -DFIRMWARE_VERSION=\"{branch}\"'
else:
output += f' -DFIRMWARE_VERSION=\"git-{revision}\"'

print(output)
5 changes: 4 additions & 1 deletion src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
#define ENABLE_INSPECTION false

#define PROTOCOL_VERSION 18
#define FIRMWARE_VERSION "0.5.0"

#ifndef FIRMWARE_VERSION
#define FIRMWARE_VERSION "UNKNOWN"
#endif

#endif // SLIMEVR_DEBUG_H_

0 comments on commit c58f0e4

Please sign in to comment.