From fe18a8b9fe37809d64cd64da28bd2af79bff0772 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Tue, 31 Mar 2026 23:18:18 -0700 Subject: [PATCH 1/4] fix: resolve release workflow version bump issues - Fixed bump-version.js to properly handle --yes flag in CI environments - Added check to skip commit if no changes to package.json or CHANGELOG.md - Ensured script exits cleanly after version bump with --yes flag --- .gitea/workflows/release.yml | 8 +++-- scripts/bump-version.js | 66 +++++++++++++++++++++--------------- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index b64aaa4..b33ce9a 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -80,8 +80,12 @@ jobs: - name: Commit version bump run: | git add package.json CHANGELOG.md - git commit -m "chore: bump version to v${{ steps.version.outputs.new_version }}" - git push origin main + if git diff --cached --quiet; then + echo "No changes to commit (version may already be at target version)" + else + git commit -m "chore: bump version to v${{ steps.version.outputs.new_version }}" + git push origin main + fi - name: Create git tag for release run: | diff --git a/scripts/bump-version.js b/scripts/bump-version.js index 989a4b7..6fc2f65 100755 --- a/scripts/bump-version.js +++ b/scripts/bump-version.js @@ -175,37 +175,47 @@ function main() { console.log(`New version: ${currentVersion} → ${newVersion}`); } - // Confirm with user - const readline = require('readline'); - const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout - }); + // Confirm with user (or skip if --yes flag is set) + if (skipConfirm) { + // Update package.json + updatePackageJson(newVersion); - rl.question(`\nApply version ${newVersion}? (y/N) `, (answer) => { - if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') { - // Update package.json - updatePackageJson(newVersion); - - // Update changelog - if (bumpType !== 'custom') { - const commits = getCommitsSinceLastTag(); - updateChangelog(newVersion, commits, bumpType); - } - - console.log(`\n✅ Version bumped to ${newVersion}`); - console.log(`\nNext steps:`); - console.log(` 1. Review changes: git diff`); - console.log(` 2. Commit changes: git commit -am "chore: bump version to v${newVersion}"`); - console.log(` 3. Create tag: git tag -a v${newVersion} -m "Release v${newVersion}"`); - console.log(` 4. Push changes: git push origin main`); - console.log(` 5. Push tag: git push origin v${newVersion}`); - } else { - console.log('❌ Version bump cancelled'); + // Update changelog + if (bumpType !== 'custom') { + const commits = getCommitsSinceLastTag(); + updateChangelog(newVersion, commits, bumpType); } - rl.close(); - }); + console.log(`\n✅ Version bumped to ${newVersion}`); + process.exit(0); + } else { + const readline = require('readline'); + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout + }); + + rl.question(`\nApply version ${newVersion}? (y/N) `, (answer) => { + if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') { + // Update package.json + updatePackageJson(newVersion); + + // Update changelog + if (bumpType !== 'custom') { + const commits = getCommitsSinceLastTag(); + updateChangelog(newVersion, commits, bumpType); + } + + console.log(`\n✅ Version bumped to ${newVersion}`); + process.exit(0); + } else { + console.log('❌ Version bump cancelled'); + process.exit(1); + } + + rl.close(); + }); + } } // Run main function -- 2.52.0 From 89d0d081626810014ecaecc0738d6f0f8f38e6ce Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Tue, 31 Mar 2026 23:18:48 -0700 Subject: [PATCH 2/4] fix: add tag existence check in release workflow - Check if tag already exists before creating it - Skip tag creation if tag already exists --- .gitea/workflows/release.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index b33ce9a..7c867a4 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -91,8 +91,14 @@ jobs: run: | TAG_NAME="v${{ steps.version.outputs.new_version }}" echo "Creating tag $TAG_NAME" - git tag -a "$TAG_NAME" -m "Release $TAG_NAME" - git push origin "$TAG_NAME" + + # Check if tag already exists + if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then + echo "Tag $TAG_NAME already exists, skipping tag creation" + else + git tag -a "$TAG_NAME" -m "Release $TAG_NAME" + git push origin "$TAG_NAME" + fi - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 -- 2.52.0 From fe133eab99624d91183b2121f6641789dc1032fd Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Tue, 31 Mar 2026 23:22:38 -0700 Subject: [PATCH 3/4] fix: improve error handling in getCommitsSinceLastTag - Add nested try-catch to handle git log failures - Return empty array if all git attempts fail - Add warning message when commit history cannot be retrieved --- scripts/bump-version.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/bump-version.js b/scripts/bump-version.js index 6fc2f65..80be566 100755 --- a/scripts/bump-version.js +++ b/scripts/bump-version.js @@ -48,14 +48,22 @@ function getCommitsSinceLastTag() { if (!latestTag) { // No tags yet, get all commits - return execSync('git log --oneline --format=%s', { encoding: 'utf8' }).trim().split('\n'); + const commits = execSync('git log --oneline --format=%s', { encoding: 'utf8' }).trim(); + return commits ? commits.split('\n') : []; } const commits = execSync(`git log ${latestTag}..HEAD --oneline --format=%s`, { encoding: 'utf8' }).trim(); return commits ? commits.split('\n') : []; } catch (error) { // If no commits since tag or other error, get recent commits - return execSync('git log --oneline --format=%s -n 20', { encoding: 'utf8' }).trim().split('\n'); + try { + const commits = execSync('git log --oneline --format=%s -n 20', { encoding: 'utf8' }).trim(); + return commits ? commits.split('\n') : []; + } catch (innerError) { + // If all git log attempts fail, return empty array + console.warn('Warning: Could not retrieve commit history, defaulting to patch version'); + return []; + } } } -- 2.52.0 From f4aca275dec2d3efcbbe5097b2fbf4174fa30072 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Tue, 31 Mar 2026 23:23:01 -0700 Subject: [PATCH 4/4] fix: skip release steps if no version bump commit was made - Set output variable 'committed' in commit step - Add conditional execution to all subsequent steps - Only create tag, build Docker images, and deploy if commit was successful --- .gitea/workflows/release.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 7c867a4..5da1bfd 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -78,16 +78,20 @@ jobs: echo "New version: $NEW_VERSION" - name: Commit version bump + id: commit run: | git add package.json CHANGELOG.md if git diff --cached --quiet; then echo "No changes to commit (version may already be at target version)" + echo "committed=false" >> $GITHUB_OUTPUT else git commit -m "chore: bump version to v${{ steps.version.outputs.new_version }}" git push origin main + echo "committed=true" >> $GITHUB_OUTPUT fi - name: Create git tag for release + if: steps.commit.outputs.committed == 'true' run: | TAG_NAME="v${{ steps.version.outputs.new_version }}" echo "Creating tag $TAG_NAME" @@ -101,9 +105,11 @@ jobs: fi - name: Set up Docker Buildx + if: steps.commit.outputs.committed == 'true' uses: docker/setup-buildx-action@v3 - name: Build test-capable image + if: steps.commit.outputs.committed == 'true' run: | docker build \ --target test-runner \ @@ -112,6 +118,7 @@ jobs: . - name: Run tests inside test-capable container + if: steps.commit.outputs.committed == 'true' run: | docker run --rm \ -e DATABASE_URL="postgresql://user:pass@localhost:5432/dummy" \ @@ -119,6 +126,7 @@ jobs: npm run test:run - name: Build production image + if: steps.commit.outputs.committed == 'true' run: | docker build \ --target runner \ @@ -128,6 +136,7 @@ jobs: . - name: Push Docker images + if: steps.commit.outputs.committed == 'true' run: | echo "Pushing to ${{ env.REGISTRY }}..." # Check if we can authenticate to the registry using DOCKER_LOGIN and DOCKER_PASSWORD secrets @@ -152,6 +161,7 @@ jobs: fi - name: Deploy to dev (placeholder) + if: steps.commit.outputs.committed == 'true' run: | echo "Deploying version ${{ steps.version.outputs.new_version }} to dev environment..." # TODO: Add actual deployment steps -- 2.52.0