Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix verison validation #49

Merged
merged 3 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,12 @@ jobs:
git config user.name "GitHub Actions"
git config user.email "actions@github.com"

- name: Create Temporary Branch
run: |
TEMP_BRANCH="temp/version-bump-$(uuidgen)"
echo "TEMP_BRANCH=${TEMP_BRANCH}" >> "${GITHUB_ENV}"
git checkout -b "${TEMP_BRANCH}"

- name: Bump Version
run: |
chmod +x "./versioning/bump_version.sh"
"./versioning/bump_version.sh"

- name: Push Changes to Temporary Branch
- name: Push Changes and Tags
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
Expand Down
2 changes: 1 addition & 1 deletion versioning/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.12.1
2024.12.2
21 changes: 9 additions & 12 deletions versioning/bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,28 @@ else
CURRENT_VERSION="0.0.0" # Default if file doesn't exist
fi

# Extract components
CURRENT_YEAR=$(date +%Y)
CURRENT_MONTH=$(date +%m)
if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{2}$ ]]; then
# Validate the current version format
if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]{1,2}\.[0-9]+$ ]]; then
echo "Error: Invalid version format in $VERSION_FILE"
exit 1
fi

# Extract components
CURRENT_YEAR=$(date +%Y)
CURRENT_MONTH=$(date +%-m) # Avoid leading zero for the month
CURRENT_SEQ=$(echo "$CURRENT_VERSION" | awk -F. '{print $3}')

VERSION_YEAR=$(echo "$CURRENT_VERSION" | awk -F. '{print $1}')
VERSION_MONTH=$(echo "$CURRENT_VERSION" | awk -F. '{print $2}')

# Determine new version
if [[ "$CURRENT_YEAR" == "$VERSION_YEAR" && "$CURRENT_MONTH" == "$VERSION_MONTH" ]]; then
NEXT_SEQ=$((10#$CURRENT_SEQ + 1))
if [ $NEXT_SEQ -gt 99 ]; then
echo "Error: Sequence number would exceed 99"
exit 1
fi
NEW_SEQ=$(printf "%02d" $NEXT_SEQ)
NEXT_SEQ=$((CURRENT_SEQ + 1))
else
NEW_SEQ="01" # Reset sequence for a new month
NEXT_SEQ=1 # Reset sequence for a new month
fi

NEW_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEW_SEQ}"
NEW_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEXT_SEQ}"

# Update the plain text VERSION file
echo "$NEW_VERSION" > "$VERSION_FILE"
Expand Down
Loading