2024-12-06 13:57:43 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Path to the version file
|
2024-12-06 14:19:48 -05:00
|
|
|
versionFile="src/fenrirscreenreader/fenrirVersion.py"
|
2024-12-06 13:57:43 -05:00
|
|
|
|
|
|
|
# Get current date components
|
|
|
|
YEAR=$(date +%Y)
|
|
|
|
MONTH=$(date +%m)
|
|
|
|
DAY=$(date +%d)
|
|
|
|
|
|
|
|
# Create new version string
|
2024-12-06 14:19:48 -05:00
|
|
|
newVersion="$YEAR.$MONTH.$DAY"
|
2024-12-06 13:57:43 -05:00
|
|
|
|
|
|
|
# Get current branch name
|
2024-12-06 14:19:48 -05:00
|
|
|
branchName=$(git rev-parse --abbrev-ref HEAD)
|
2024-12-06 13:57:43 -05:00
|
|
|
|
|
|
|
# Check if file exists
|
2024-12-06 14:19:48 -05:00
|
|
|
if [ ! -f "$versionFile" ]; then
|
|
|
|
echo "Error: Version file not found at $versionFile"
|
2024-12-06 13:57:43 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Update the version in the file
|
|
|
|
# This handles different possible formats of the version line
|
2024-12-06 14:19:48 -05:00
|
|
|
sed -i "s/version = [\"']\{0,1\}[0-9.]\+[\"']\{0,1\}/version = \"$newVersion\"/" "$versionFile"
|
2024-12-06 13:57:43 -05:00
|
|
|
|
|
|
|
# Check if codeName exists in the file
|
2024-12-06 14:19:48 -05:00
|
|
|
if grep -q "codeName" "$versionFile"; then
|
2024-12-06 13:57:43 -05:00
|
|
|
# Update existing codeName
|
2024-12-06 14:19:48 -05:00
|
|
|
sed -i "s/codeName = [\"']\{0,1\}[^\"']*[\"']\{0,1\}/codeName = \"$branchName\"/" "$versionFile"
|
2024-12-06 13:57:43 -05:00
|
|
|
else
|
|
|
|
# Add codeName after the version line
|
2024-12-06 14:19:48 -05:00
|
|
|
sed -i "/version = / a\codeName = \"$branchName\"" "$versionFile"
|
2024-12-06 13:57:43 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Add the changed file back to the commit
|
2024-12-06 14:19:48 -05:00
|
|
|
git add "$versionFile"
|
2024-12-06 13:57:43 -05:00
|
|
|
|
|
|
|
# Amend the last commit to include the version update
|
|
|
|
# Use the original commit message
|
2024-12-06 14:19:48 -05:00
|
|
|
commitMessage=$(git log -1 --pretty=%B)
|
|
|
|
git commit --amend -m "$commitMessage"
|