From 5a993165cd621436e8ca7e40a5f2d0d9f6e116c0 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 21 Dec 2024 14:54:47 +0100 Subject: [PATCH 1/2] Rollback to the last working point --- .github/workflows/versioning.yml | 25 +++++++++++-------------- versioning/bump_version.sh | 17 +++++++++++------ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index 9f5f371..2e49b1a 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -1,11 +1,14 @@ -# Workflow for managing versioning, tagging, and conditional updates +# Workflow for managing versioning and tagging --- -name: Bump Version and Tag +name: Version Bump and Tag on: # yamllint disable-line rule:truthy push: branches: - main + paths-ignore: + - '**/VERSION' + - '**/VERSION_YAML' workflow_dispatch: inputs: update_stable: @@ -18,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: "actions/checkout@v4" - name: Set up Git run: | @@ -27,19 +30,13 @@ jobs: - name: Bump Version run: | - chmod +x ./versioning/bump_version.sh - ./versioning/bump_version.sh + chmod +x "./versioning/bump_version.sh" + "./versioning/bump_version.sh" - name: Push Changes and Tags env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" run: | - git push https://x-access-token:${GITHUB_TOKEN}@github.com/edwardtfn/TX-Ultimate-Easy.git main - git push https://x-access-token:${GITHUB_TOKEN}@github.com/edwardtfn/TX-Ultimate-Easy.git --tags - - - name: Conditionally Update Stable Tag - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.update_stable == 'true' }} - run: | - git tag -f stable - git push https://x-access-token:${GITHUB_TOKEN}@github.com/edwardtfn/TX-Ultimate-Easy.git stable --force + git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" main + git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" --tags ... diff --git a/versioning/bump_version.sh b/versioning/bump_version.sh index 3b85e58..6cd72c6 100644 --- a/versioning/bump_version.sh +++ b/versioning/bump_version.sh @@ -5,15 +5,15 @@ VERSION_YAML_FILE="./versioning/VERSION_YAML" # Read the current version if [ -f "$VERSION_FILE" ]; then - CURRENT_VERSION=$(cat "$VERSION_FILE") + CURRENT_VERSION=$(cat $VERSION_FILE) else CURRENT_VERSION="0.0.0" # Default if file doesn't exist fi # Extract components CURRENT_YEAR=$(date +%Y) -CURRENT_MONTH=$(date +%-m) # Use %-m to avoid leading zero for the month -if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]+\.[0-9]+$ ]]; then +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 @@ -24,12 +24,17 @@ VERSION_MONTH=$(echo "$CURRENT_VERSION" | awk -F. '{print $2}') # Determine new version if [[ "$CURRENT_YEAR" == "$VERSION_YEAR" && "$CURRENT_MONTH" == "$VERSION_MONTH" ]]; then - NEXT_SEQ=$((CURRENT_SEQ + 1)) + 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 - NEXT_SEQ=1 # Reset sequence for a new month + NEW_SEQ="01" # Reset sequence for a new month fi -NEW_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEXT_SEQ}" +NEW_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEW_SEQ}" # Update the plain text VERSION file echo "$NEW_VERSION" > "$VERSION_FILE" From f32e2eee4f2162b9bc0c779b433a6d42c0b07026 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 21 Dec 2024 17:14:00 +0100 Subject: [PATCH 2/2] Add quotes around file path in cat command Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- versioning/bump_version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versioning/bump_version.sh b/versioning/bump_version.sh index 6cd72c6..3c51f7c 100644 --- a/versioning/bump_version.sh +++ b/versioning/bump_version.sh @@ -5,7 +5,7 @@ VERSION_YAML_FILE="./versioning/VERSION_YAML" # Read the current version if [ -f "$VERSION_FILE" ]; then - CURRENT_VERSION=$(cat $VERSION_FILE) + CURRENT_VERSION=$(cat "$VERSION_FILE") else CURRENT_VERSION="0.0.0" # Default if file doesn't exist fi