asdf/scripts/asdf-version
Trevor Brown 6d708b2807 feat(golang-rewrite): compile asdf version into Go binaries
* Create asdf-version script to print formatted version
* Update Makefile to set main.version variable during build
* Improve help output formatting
* Update release-build workflow to set asdf version in binaries
2024-12-18 11:32:03 -05:00

21 lines
563 B
Bash
Executable File

#!/usr/bin/env bash
# Unofficial Bash "strict mode"
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
#ORIGINAL_IFS=$IFS
IFS=$'\t\n' # Stricter IFS settings
# Simpler helper script to extract the current version out of the source in the
# asdf Git repository.
asdf_version() {
local version git_rev
root_dir="$(dirname "$(dirname "$(realpath "$0")")")"
version="v$(cat "${root_dir}/version.txt")"
git_rev="$(git --git-dir "${root_dir}/.git" rev-parse --short HEAD)"
printf "%s-%s\n" "$version" "$git_rev"
}
asdf_version