Fixed a few things with version increment.

This commit is contained in:
Storm Dragon 2024-12-06 14:19:48 -05:00
parent 52861c89c8
commit 1f837964da

View File

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