diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index 3ae4d04..2e49b1a 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -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: | diff --git a/versioning/VERSION b/versioning/VERSION index d969417..f36eb7f 100644 --- a/versioning/VERSION +++ b/versioning/VERSION @@ -1 +1 @@ -2024.12.1 +2024.12.2 \ No newline at end of file diff --git a/versioning/bump_version.sh b/versioning/bump_version.sh index fdcb88e..ea46c5a 100644 --- a/versioning/bump_version.sh +++ b/versioning/bump_version.sh @@ -10,13 +10,15 @@ 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}') @@ -24,17 +26,12 @@ 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"