From 26a244cbedcfa4aea86b04db875e6ad7d00f408f Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 21 Dec 2024 10:28:14 +0100 Subject: [PATCH 1/5] Fix potential overflow in sequence number Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- versioning/bump_version.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/versioning/bump_version.sh b/versioning/bump_version.sh index 5571617..6fa82c2 100644 --- a/versioning/bump_version.sh +++ b/versioning/bump_version.sh @@ -20,7 +20,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 From 23436428a413468525495319a88f106d660b5559 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 21 Dec 2024 10:29:12 +0100 Subject: [PATCH 2/5] Add error handling for invalid version format Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- versioning/bump_version.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/versioning/bump_version.sh b/versioning/bump_version.sh index 6fa82c2..d11d706 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}') From 04ca752c3be99a4e97f5b0e487b47b680b8604bc Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 21 Dec 2024 10:29:46 +0100 Subject: [PATCH 3/5] Add error handling for git operations Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- versioning/bump_version.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/versioning/bump_version.sh b/versioning/bump_version.sh index d11d706..6cd72c6 100644 --- a/versioning/bump_version.sh +++ b/versioning/bump_version.sh @@ -43,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 From 5569260f925bcdcc643b96c833c3f4d44ddc7806 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 21 Dec 2024 10:30:28 +0100 Subject: [PATCH 4/5] Update checkout action version Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .github/workflows/versioning.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index dbdb406..3a5f76f 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: | From 737343e395a6e623b840abec4c18688af9fd6269 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 21 Dec 2024 10:31:23 +0100 Subject: [PATCH 5/5] Add fetch-depth: 0 to checkout action Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .github/workflows/versioning.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index 3a5f76f..c15dfb5 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -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' }}