Skip to content

Commit 03fb04c

Browse files
committed
fix(action): handle tag collisions and force tag updates
- Add 'needs: test-python' to JS test job to ensure sequential execution and avoid variable/tag collisions - Add '--force' (-f) flag to git tag and git push commands in index.ts to support Moving Tag strategy and handle re-runs - Consolidate robust verification for both jobs Refs: #7
1 parent fc898ac commit 03fb04c

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

.github/workflows/run_increment_version.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
echo "Python Ghost Update Verified via get_version()!"
4646
4747
test-js:
48+
needs: test-python # Run sequentially to avoid tag/variable collisions
4849
runs-on: ubuntu-latest
4950
if: github.repository == 'candango/increment-version'
5051
permissions:

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Version {
1111
prerelease?: { type: string; number: number };
1212

1313
constructor(versionString: string) {
14-
// Suporta 0.9.8a1, 0.9.8-a1, 0.9.8-a.1, etc.
14+
// Robust regex for PEP 440 (0.9.8a1) and SemVer (0.9.8-a.1 or 0.9.8-a1)
1515
const match = versionString.match(/^(\d+)\.(\d+)\.(\d+)(?:[-.]([a-z]+)[.-]?(\d+))?$/i) ||
1616
versionString.match(/^(\d+)\.(\d+)\.(\d+)(?:([a-z]+)(\d+))?$/i);
1717

@@ -204,10 +204,12 @@ async function run(): Promise<void> {
204204

205205
try {
206206
core.info(`Creating Git tag: v${newVersionStr}`);
207-
await exec("git", ["tag", `v${newVersionStr}`]);
207+
// Use -f to allow overwriting tags (Moving Tag strategy)
208+
await exec("git", ["tag", "-f", `v${newVersionStr}`]);
208209
const remoteRepo = `https://x-access-token:${authToken}@github.com/${owner}/${repo}.git`;
209210
await exec("git", ["remote", "set-url", "origin", remoteRepo]);
210-
await exec("git", ["push", "origin", `v${newVersionStr}`]);
211+
// Use -f to allow forcing the tag update on remote
212+
await exec("git", ["push", "-f", "origin", `v${newVersionStr}`]);
211213
core.info("Git push successful.");
212214
} catch (error: any) {
213215
core.setFailed(`Failed tagging repository head: ${error.message}`);

0 commit comments

Comments
 (0)