diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index dbdb406..c15dfb5 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Git run: | @@ -34,8 +34,14 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - git push origin main - git push origin --tags --force + if ! git push origin main; then + echo "Failed to push to main branch" + exit 1 + fi + if ! git push origin --tags --force; then + echo "Failed to push tags" + exit 1 + fi - name: Conditionally Update Stable Tag if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.update_stable == 'true' }} diff --git a/versioning/bump_version.sh b/versioning/bump_version.sh index 5571617..6cd72c6 100644 --- a/versioning/bump_version.sh +++ b/versioning/bump_version.sh @@ -13,6 +13,10 @@ fi # Extract components CURRENT_YEAR=$(date +%Y) CURRENT_MONTH=$(date +%m) +if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{2}$ ]]; then + echo "Error: Invalid version format in $VERSION_FILE" + exit 1 +fi CURRENT_SEQ=$(echo "$CURRENT_VERSION" | awk -F. '{print $3}') VERSION_YEAR=$(echo "$CURRENT_VERSION" | awk -F. '{print $1}') @@ -20,7 +24,12 @@ VERSION_MONTH=$(echo "$CURRENT_VERSION" | awk -F. '{print $2}') # Determine new version if [[ "$CURRENT_YEAR" == "$VERSION_YEAR" && "$CURRENT_MONTH" == "$VERSION_MONTH" ]]; then - NEW_SEQ=$(printf "%02d" $((10#$CURRENT_SEQ + 1))) # Increment sequence + 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) else NEW_SEQ="01" # Reset sequence for a new month fi @@ -34,6 +43,15 @@ echo "$NEW_VERSION" > "$VERSION_FILE" echo "version: $NEW_VERSION" > "$VERSION_YAML_FILE" # Commit and tag -git add "$VERSION_FILE" "$VERSION_YAML_FILE" -git commit -m "Bump version to $NEW_VERSION" -git tag "v$NEW_VERSION" +if ! git add "$VERSION_FILE" "$VERSION_YAML_FILE"; then + echo "Error: Failed to stage version files" + exit 1 +fi +if ! git commit -m "Bump version to $NEW_VERSION"; then + echo "Error: Failed to commit version bump" + exit 1 +fi +if ! git tag "v$NEW_VERSION"; then + echo "Error: Failed to create version tag" + exit 1 +fi