#!/bin/bash # stamp-version.sh - Stamp version from VERSION file into source and config files # Run this before building to ensure version consistency across all files set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" # Read version from VERSION file if [ ! -f VERSION ]; then echo "Error: VERSION file not found" >&2 exit 1 fi VERSION=$(cat VERSION | tr -d '[:space:]') if [ -z "$VERSION" ]; then echo "Error: VERSION file is empty" >&2 exit 1 fi echo "Stamping version: $VERSION" # Generate version module mkdir -p src/version cat > src/version/version.f90 << EOF ! Auto-generated by stamp-version.sh - DO NOT EDIT MANUALLY module version_info implicit none private public :: FORTRESS_VERSION, print_version, print_help character(len=*), parameter :: FORTRESS_VERSION = '$VERSION' contains subroutine print_version() print '(A,A)', 'fortress v', FORTRESS_VERSION print '(A)', '' print '(A)', 'A command-line file explorer written in modern Fortran' print '(A)', 'https://github.com/FortranGoingOnForty/fortress' end subroutine print_version subroutine print_help() print '(A)', 'fortress - a dual-pane file explorer with fzf and git integration' print '(A)', '' print '(A)', 'USAGE:' print '(A)', ' fortress [OPTIONS]' print '(A)', '' print '(A)', 'OPTIONS:' print '(A)', ' -h, --help Show this help message' print '(A)', ' -v, --version Show version information' print '(A)', '' print '(A)', 'NAVIGATION:' print '(A)', ' up/down Navigate up/down' print '(A)', ' right Enter directory' print '(A)', ' left Go to parent directory' print '(A)', ' ~ Jump to home directory' print '(A)', ' / Jump to root directory' print '(A)', ' 8 Jump to favorites' print '(A)', ' * Toggle favorite' print '(A)', ' . Toggle hidden files' print '(A)', ' [type chars] Fuzzy jump to file' print '(A)', '' print '(A)', 'FILE OPERATIONS (Alt+key):' print '(A)', ' Alt+n Rename file/directory' print '(A)', ' Alt+v View/open file' print '(A)', ' Alt+m Move mode' print '(A)', ' Alt+y Yank (copy)' print '(A)', ' Alt+x Cut' print '(A)', ' Alt+p Paste' print '(A)', ' Alt+r Remove/delete' print '(A)', ' Alt+s Search with fzf' print '(A)', ' Alt+c CD on exit' print '(A)', '' print '(A)', 'SELECTION:' print '(A)', ' Space Toggle selection' print '(A)', ' Shift+up/down Block select' print '(A)', ' e Exit selection mode' print '(A)', '' print '(A)', 'GIT (Alt+g to toggle git mode):' print '(A)', ' a Stage file/directory' print '(A)', ' u Unstage' print '(A)', ' m Commit' print '(A)', ' d Show diff' print '(A)', ' f Fetch' print '(A)', ' l Pull' print '(A)', ' h Push' print '(A)', ' t Tag' print '(A)', '' print '(A)', 'Ctrl+q to quit' end subroutine print_help end module version_info EOF echo " -> src/version/version.f90" # Update fpm.toml if [ -f fpm.toml ]; then sed -i "s/^version = .*/version = \"$VERSION\"/" fpm.toml echo " -> fpm.toml" fi # Update fortress.spec if [ -f fortress.spec ]; then sed -i "s/^Version:.*/Version: $VERSION/" fortress.spec echo " -> fortress.spec" fi echo "Done!"