diff options
| author | Selene ToyKeeper | 2023-12-05 16:49:24 -0700 |
|---|---|---|
| committer | Selene ToyKeeper | 2023-12-05 16:49:24 -0700 |
| commit | 50ae5684534ec9333a648794d4f371b882e53075 (patch) | |
| tree | e666fea7d540632dc99643468184b519e647c12d /bin/version-string.sh | |
| parent | d3aa: made it easy to switch between vddio2 and external voltage divider (diff) | |
| parent | moved version string calculation to bin/version-string.sh (diff) | |
| download | anduril-50ae5684534ec9333a648794d4f371b882e53075.tar.gz anduril-50ae5684534ec9333a648794d4f371b882e53075.tar.bz2 anduril-50ae5684534ec9333a648794d4f371b882e53075.zip | |
Merge branch 'trunk' into emisar-d3aa
* trunk:
moved version string calculation to bin/version-string.sh
forgot one item in the ChangeLog
ChangeLog: added 2023-12-03 release notes, converted @modelname to &modelname
docs: expanded / reorganized info on Version Check formats
updated MODELS, bin/models.py, and hw/BRANDS...
fw3x: document how it ships with the wrong fuse values, and how to fix it
github CI: fetch history too, to allow detection of version tags
build-all: handle the case where "git describe" can't get any tags
run CI on all branches, not just on trunk
fetch tags on CI checkout, so 'git describe' can work
added docs/battery-rainbow.png from old repo, since it's still relevant
added bin/make-release.sh to generate a .zip file ready for release
build-all.sh: re-indented, started organizing code into functions
changed version number to use the latest release tag instead of build date
Diffstat (limited to 'bin/version-string.sh')
| -rwxr-xr-x | bin/version-string.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/bin/version-string.sh b/bin/version-string.sh new file mode 100755 index 0000000..c1c5155 --- /dev/null +++ b/bin/version-string.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# Print a version string for the currently-checked-out code. +# Copyright (C) 2023 Selene ToyKeeper +# SPDX-License-Identifier: GPL-3.0-or-later + +# Usage: version-string.sh [c|git|both] +# Prints in C or Git format. Defaults to both. + +function main { + # eat first arg if invoked via 'make' + [[ "version" = "$1" ]] && shift + + # default to showing both formats + ARGS="$*" + [[ -z "$ARGS" ]] && ARGS="both" + + for arg in $ARGS ; do + case "$arg" in + git|g) + git-describe + ;; + c|C) + c-version-string + ;; + *) + echo -n 'C: ' ; c-version-string + echo -n 'git: ' ; git-describe + ;; + esac + done +} + +function git-describe { + git describe --tags --dirty --match='r2*' +} + +function c-version-string { + # version = git tag + revs since + dirty flag + REV=$(git-describe) + # convert "r2020-01-01-158-g0abcdef-dirty" to "2020-01-01+158#1" + REV=$(echo "$REV" | + sed -E 's/^r//; + s/-dirty/#1/; + s/-g[0-9a-f]+//; + s/^([0-9]{4}-[0-9]{2}-[0-9]{2})-/\1+/; + ' + ) + # handle an empty name (can happen during github action runs) + if [[ -z "$REV" ]]; then + HASH=$(git describe --always) + REV="0.$HASH" + fi + # print the version string + echo "$REV" +} + +main "$@" + |
