diff --git a/.github/scripts/bump-jdbc-plugin-version.mjs b/.github/scripts/bump-jdbc-plugin-version.mjs index dea4e4badb..c072bd9e78 100644 --- a/.github/scripts/bump-jdbc-plugin-version.mjs +++ b/.github/scripts/bump-jdbc-plugin-version.mjs @@ -31,6 +31,10 @@ function isReleaseBumpRelevantJdbcPluginChange(file) { return true; } +function hasJdbcPluginVersionChange(file) { + return file === POM_PATH || file === MANIFEST_PATH; +} + function updatePomVersion(pomXml, version) { return pomXml.replace(/()([^<]+)(<\/version>)/, `$1${version}$3`); } @@ -48,7 +52,7 @@ export function evaluateJdbcPluginReleaseBump({ changedFiles, pomXml, manifestJs throw new Error(`JDBC plugin version mismatch: pom.xml is ${pomVersion} but manifest.json is ${currentManifestVersion}.`); } - const shouldBump = changedFiles.some(isReleaseBumpRelevantJdbcPluginChange); + const shouldBump = changedFiles.some(isReleaseBumpRelevantJdbcPluginChange) && !changedFiles.some(hasJdbcPluginVersionChange); const newVersion = shouldBump ? bumpPatchVersion(pomVersion) : pomVersion; return { changed: shouldBump, diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a742cfa7fb..78defa27aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,9 +49,21 @@ jobs: if: steps.bump.outputs.changed == 'true' shell: bash run: | + TMP_DIR="$(mktemp -d)" + cp plugins/jdbc/pom.xml "$TMP_DIR/pom.xml" + cp plugins/jdbc/manifest.json "$TMP_DIR/manifest.json" + git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + git fetch origin main + git switch -C jdbc-plugin-version-bump origin/main + cp "$TMP_DIR/pom.xml" plugins/jdbc/pom.xml + cp "$TMP_DIR/manifest.json" plugins/jdbc/manifest.json git add plugins/jdbc/pom.xml plugins/jdbc/manifest.json + if git diff --cached --quiet; then + echo "JDBC plugin version ${{ steps.bump.outputs.new_version }} is already on main." + exit 0 + fi git commit -m "chore(jdbc): bump plugin version [skip ci]" git push origin HEAD:main diff --git a/.github/workflows/sync-mirrors.yml b/.github/workflows/sync-mirrors.yml index 78913f7f1e..cad877d6c3 100644 --- a/.github/workflows/sync-mirrors.yml +++ b/.github/workflows/sync-mirrors.yml @@ -26,6 +26,9 @@ jobs: set -euo pipefail git remote add cnb "https://cnb:${CNB_TOKEN}@cnb.cool/dbxio.com/dbx.git" git push cnb --all --force + if [ "${GITHUB_REF_TYPE}" = "tag" ]; then + git push cnb ":refs/tags/${GITHUB_REF_NAME}" || true + fi git push cnb --tags --force sync-atomgit: @@ -44,6 +47,9 @@ jobs: set -euo pipefail git remote add atomgit "https://t8y2:${ATOMGIT_TOKEN}@atomgit.com/t8y2/dbx.git" git push atomgit --all --force + if [ "${GITHUB_REF_TYPE}" = "tag" ]; then + git push atomgit ":refs/tags/${GITHUB_REF_NAME}" || true + fi git push atomgit --tags --force sync-gitee: @@ -62,4 +68,7 @@ jobs: set -euo pipefail git remote add gitee "https://codetty:${GITEE_TOKEN}@gitee.com/codetty/dbx.git" git push gitee --all --force + if [ "${GITHUB_REF_TYPE}" = "tag" ]; then + git push gitee ":refs/tags/${GITHUB_REF_NAME}" || true + fi git push gitee --tags --force diff --git a/packages/app-tests/jdbcPluginRelease.test.ts b/packages/app-tests/jdbcPluginRelease.test.ts index e6a92efb09..bafa8ca113 100644 --- a/packages/app-tests/jdbcPluginRelease.test.ts +++ b/packages/app-tests/jdbcPluginRelease.test.ts @@ -70,6 +70,22 @@ test("auto bumps JDBC plugin patch version when runtime files changed for releas assert.match(result.manifestJson, /"version": "0\.1\.10"/); }); +test("does not auto bump JDBC plugin again when release range already includes a version bump", () => { + const result = evaluateJdbcPluginReleaseBump({ + changedFiles: [ + "plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java", + "plugins/jdbc/pom.xml", + "plugins/jdbc/manifest.json", + ], + pomXml: "0.1.10", + manifestJson: '{ "version": "0.1.10" }', + }); + + assert.equal(result.changed, false); + assert.equal(result.oldVersion, "0.1.10"); + assert.equal(result.newVersion, "0.1.10"); +}); + test("does not auto bump JDBC plugin version for release packaging-only changes", () => { const result = evaluateJdbcPluginReleaseBump({ changedFiles: ["plugins/jdbc/README.md", "plugins/jdbc/package.sh"],