No leading zero on versions
This commit is contained in:
@@ -5,23 +5,25 @@ This project uses a time-based versioning scheme: `year.month.sequential_number`
|
|||||||
This scheme makes it easy to identify when a version was released and provides a clear order for releases within a given month.
|
This scheme makes it easy to identify when a version was released and provides a clear order for releases within a given month.
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
- `2024.12.01` – First release of December 2024.
|
- `2024.1.1` – First release of January 2024.
|
||||||
- `2024.12.02` – Second release of December 2024.
|
- `2024.12.2` – Second release of December 2024.
|
||||||
- `2025.01.01` – First release of January 2025.
|
- `2025.3.1` – First release of March 2025.
|
||||||
|
|
||||||
## Files
|
## Files
|
||||||
- **`VERSION`**: Contains the current version of the project as plain text.
|
- **`VERSION`**: Contains the current version of the project as plain text.
|
||||||
- **`bump_version.sh`**: A script to increment the version based on the current date and release sequence.
|
- **`bump_version.sh`**: A script to increment the version based on the current date and release sequence.
|
||||||
- **`README.md`**: Documentation for the versioning process.
|
- **`README.md`**: Documentation for the versioning process.
|
||||||
|
|
||||||
## Versioning Rules
|
## Version Validation
|
||||||
1. The version format is `YYYY.MM.NN`, where:
|
|
||||||
- `YYYY` is the current year.
|
The versioning system enforces strict format validation:
|
||||||
- `MM` is the current month (two digits).
|
- Year must be a 4-digit number (YYYY)
|
||||||
- `NN` is the sequential release number within the month (starting at `01`).
|
- Month must be a number from 1 to 12 without leading zeros
|
||||||
2. On each new merge to the `main` branch:
|
- Sequence must be a positive number with no leading zeros (1, 2, ...).
|
||||||
- If the month hasn’t changed, the sequential number (`NN`) is incremented.
|
|
||||||
- If the month has changed, the sequential number resets to `01`.
|
The `bump_version.sh` script includes validation checks and will fail if:
|
||||||
|
- The version format is invalid.
|
||||||
|
- Other format-related issues are detected.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ VERSION_YAML_FILE="./versioning/VERSION_YAML"
|
|||||||
|
|
||||||
# Read the current version
|
# Read the current version
|
||||||
if [ -f "$VERSION_FILE" ]; then
|
if [ -f "$VERSION_FILE" ]; then
|
||||||
CURRENT_VERSION=$(cat $VERSION_FILE)
|
CURRENT_VERSION=$(cat "$VERSION_FILE")
|
||||||
else
|
else
|
||||||
CURRENT_VERSION="0.0.0" # Default if file doesn't exist
|
CURRENT_VERSION="0.0.0" # Default if file doesn't exist
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract components
|
# Extract components
|
||||||
CURRENT_YEAR=$(date +%Y)
|
CURRENT_YEAR=$(date +%Y)
|
||||||
CURRENT_MONTH=$(date +%m)
|
CURRENT_MONTH=$(date +%-m) # Use %-m to avoid leading zero for the month
|
||||||
if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{2}$ ]]; then
|
if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
echo "Error: Invalid version format in $VERSION_FILE"
|
echo "Error: Invalid version format in $VERSION_FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -24,17 +24,12 @@ VERSION_MONTH=$(echo "$CURRENT_VERSION" | awk -F. '{print $2}')
|
|||||||
|
|
||||||
# Determine new version
|
# Determine new version
|
||||||
if [[ "$CURRENT_YEAR" == "$VERSION_YEAR" && "$CURRENT_MONTH" == "$VERSION_MONTH" ]]; then
|
if [[ "$CURRENT_YEAR" == "$VERSION_YEAR" && "$CURRENT_MONTH" == "$VERSION_MONTH" ]]; then
|
||||||
NEXT_SEQ=$((10#$CURRENT_SEQ + 1))
|
NEXT_SEQ=$((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)
|
|
||||||
else
|
else
|
||||||
NEW_SEQ="01" # Reset sequence for a new month
|
NEXT_SEQ=1 # Reset sequence for a new month
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NEW_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEW_SEQ}"
|
NEW_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEXT_SEQ}"
|
||||||
|
|
||||||
# Update the plain text VERSION file
|
# Update the plain text VERSION file
|
||||||
echo "$NEW_VERSION" > "$VERSION_FILE"
|
echo "$NEW_VERSION" > "$VERSION_FILE"
|
||||||
|
|||||||
Reference in New Issue
Block a user