Skip to content

Commit ac39112

Browse files
committed
fix: make release workflow idempotent and reset version to last successful release
1 parent 7ab785c commit ac39112

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

.github/workflows/release.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ on:
99
permissions:
1010
contents: write
1111

12-
# This action requires a GitHub app with content write access installed
12+
# This action requires a GitHub app with content write access installed
1313
# to bypass the main branch protection rule and dispatch the event to a different repo
1414

1515
jobs:
1616
release:
1717
runs-on: ubuntu-latest
18-
outputs:
18+
outputs:
1919
no_commit: ${{ steps.git-release.outputs.NO_COMMIT }}
2020
steps:
2121
- name: Generate a token
@@ -53,6 +53,27 @@ jobs:
5353
node-version: ${{ env.NODE }}
5454
registry-url: https://registry.npmjs.org/
5555
- run: yarn
56+
# Clean up any stale version tags left from failed release runs.
57+
# Context:
58+
# - Each release run uses release-it to bump package.json, create a new Git tag (e.g., v7.0.0),
59+
# and then publish to NPM. If the run fails after the tag is created but before publish,
60+
# that tag remains both locally in the local repo (inside the GitHub Actions runner) and remotely on GitHub.
61+
# - "Locally" refers to the temporary clone created by actions/checkout@v4 inside the workflow runner.
62+
# - "Remotely" refers to the GitHub repository itself ("origin" on GitHub.com).
63+
# The command `git push origin :refs/tags/v7.0.0` deletes the remote tag.
64+
# - On the next run, if that stale tag still exists, release-it detects no version change
65+
# and fails with “Version not changed”.
66+
# This step checks whether the tag for the current package.json version already exists,
67+
# and deletes it locally and remotely so release-it can safely recreate it during this run.
68+
- name: Clean stale tags from failed releases
69+
run: |
70+
CURRENT_VERSION=$(node -p "require('./package.json').version")
71+
echo "Checking for existing tag v$CURRENT_VERSION..."
72+
if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then
73+
echo "Removing stale tag v$CURRENT_VERSION"
74+
git tag -d "v$CURRENT_VERSION" || true
75+
git push origin ":refs/tags/v$CURRENT_VERSION" || true
76+
fi
5677
- name: Release through Git
5778
id: git-release
5879
run: yarn release --ci --verbose
@@ -83,7 +104,7 @@ jobs:
83104
client-payload: '{"ref": "${{ github.ref }}", "VERSION_NUMBER": ${{ env.VERSION }}}'
84105
notify:
85106
# If any of job fails
86-
if: failure()
107+
if: failure()
87108
runs-on: ubuntu-latest
88109
needs:
89110
- release

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@teamimpact/veda-ui",
33
"description": "Dashboard",
4-
"version": "6.19.1",
4+
"version": "6.16.0",
55
"author": {
66
"name": "Development Seed",
77
"url": "https://developmentseed.org/"

0 commit comments

Comments
 (0)