@@ -0,0 +1,112 @@ |
| 1 | +#!/bin/bash |
| 2 | +# stamp-version.sh - Stamp version from VERSION file into source and config files |
| 3 | +# Run this before building to ensure version consistency across all files |
| 4 | + |
| 5 | +set -e |
| 6 | + |
| 7 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 8 | +cd "$SCRIPT_DIR" |
| 9 | + |
| 10 | +# Read version from VERSION file |
| 11 | +if [ ! -f VERSION ]; then |
| 12 | + echo "Error: VERSION file not found" >&2 |
| 13 | + exit 1 |
| 14 | +fi |
| 15 | + |
| 16 | +VERSION=$(cat VERSION | tr -d '[:space:]') |
| 17 | + |
| 18 | +if [ -z "$VERSION" ]; then |
| 19 | + echo "Error: VERSION file is empty" >&2 |
| 20 | + exit 1 |
| 21 | +fi |
| 22 | + |
| 23 | +echo "Stamping version: $VERSION" |
| 24 | + |
| 25 | +# Generate version module |
| 26 | +mkdir -p src/version |
| 27 | +cat > src/version/version.f90 << EOF |
| 28 | +! Auto-generated by stamp-version.sh - DO NOT EDIT MANUALLY |
| 29 | +module version_info |
| 30 | + implicit none |
| 31 | + private |
| 32 | + |
| 33 | + public :: FORTRESS_VERSION, print_version, print_help |
| 34 | + |
| 35 | + character(len=*), parameter :: FORTRESS_VERSION = '$VERSION' |
| 36 | + |
| 37 | +contains |
| 38 | + |
| 39 | + subroutine print_version() |
| 40 | + print '(A,A)', 'fortress v', FORTRESS_VERSION |
| 41 | + print '(A)', '' |
| 42 | + print '(A)', 'A command-line file explorer written in modern Fortran' |
| 43 | + print '(A)', 'https://github.com/FortranGoingOnForty/fortress' |
| 44 | + end subroutine print_version |
| 45 | + |
| 46 | + subroutine print_help() |
| 47 | + print '(A)', 'fortress - a dual-pane file explorer with fzf and git integration' |
| 48 | + print '(A)', '' |
| 49 | + print '(A)', 'USAGE:' |
| 50 | + print '(A)', ' fortress [OPTIONS]' |
| 51 | + print '(A)', '' |
| 52 | + print '(A)', 'OPTIONS:' |
| 53 | + print '(A)', ' -h, --help Show this help message' |
| 54 | + print '(A)', ' -v, --version Show version information' |
| 55 | + print '(A)', '' |
| 56 | + print '(A)', 'NAVIGATION:' |
| 57 | + print '(A)', ' up/down Navigate up/down' |
| 58 | + print '(A)', ' right Enter directory' |
| 59 | + print '(A)', ' left Go to parent directory' |
| 60 | + print '(A)', ' ~ Jump to home directory' |
| 61 | + print '(A)', ' / Jump to root directory' |
| 62 | + print '(A)', ' 8 Jump to favorites' |
| 63 | + print '(A)', ' * Toggle favorite' |
| 64 | + print '(A)', ' . Toggle hidden files' |
| 65 | + print '(A)', ' [type chars] Fuzzy jump to file' |
| 66 | + print '(A)', '' |
| 67 | + print '(A)', 'FILE OPERATIONS (Alt+key):' |
| 68 | + print '(A)', ' Alt+n Rename file/directory' |
| 69 | + print '(A)', ' Alt+v View/open file' |
| 70 | + print '(A)', ' Alt+m Move mode' |
| 71 | + print '(A)', ' Alt+y Yank (copy)' |
| 72 | + print '(A)', ' Alt+x Cut' |
| 73 | + print '(A)', ' Alt+p Paste' |
| 74 | + print '(A)', ' Alt+r Remove/delete' |
| 75 | + print '(A)', ' Alt+s Search with fzf' |
| 76 | + print '(A)', ' Alt+c CD on exit' |
| 77 | + print '(A)', '' |
| 78 | + print '(A)', 'SELECTION:' |
| 79 | + print '(A)', ' Space Toggle selection' |
| 80 | + print '(A)', ' Shift+up/down Block select' |
| 81 | + print '(A)', ' e Exit selection mode' |
| 82 | + print '(A)', '' |
| 83 | + print '(A)', 'GIT (Alt+g to toggle git mode):' |
| 84 | + print '(A)', ' a Stage file/directory' |
| 85 | + print '(A)', ' u Unstage' |
| 86 | + print '(A)', ' m Commit' |
| 87 | + print '(A)', ' d Show diff' |
| 88 | + print '(A)', ' f Fetch' |
| 89 | + print '(A)', ' l Pull' |
| 90 | + print '(A)', ' h Push' |
| 91 | + print '(A)', ' t Tag' |
| 92 | + print '(A)', '' |
| 93 | + print '(A)', 'Ctrl+q to quit' |
| 94 | + end subroutine print_help |
| 95 | + |
| 96 | +end module version_info |
| 97 | +EOF |
| 98 | +echo " -> src/version/version.f90" |
| 99 | + |
| 100 | +# Update fpm.toml |
| 101 | +if [ -f fpm.toml ]; then |
| 102 | + sed -i "s/^version = .*/version = \"$VERSION\"/" fpm.toml |
| 103 | + echo " -> fpm.toml" |
| 104 | +fi |
| 105 | + |
| 106 | +# Update fortress.spec |
| 107 | +if [ -f fortress.spec ]; then |
| 108 | + sed -i "s/^Version:.*/Version: $VERSION/" fortress.spec |
| 109 | + echo " -> fortress.spec" |
| 110 | +fi |
| 111 | + |
| 112 | +echo "Done!" |