Skip to content

Commit f9e4e8d

Browse files
chore: add release.sh script to automate version tagging
Tags the new version, updates all @vX.Y.Z references in README.md, and prints a reminder to run the w3 release.sh. Usage: ./release.sh [new-version] (auto-increments patch if omitted) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e88e428 commit f9e4e8d

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

release.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/sh
2+
# release.sh — tag a new oasdiff-action version and update the README
3+
#
4+
# Usage: ./release.sh [new-version]
5+
# e.g. ./release.sh v0.0.35
6+
# ./release.sh # auto-increments the patch version
7+
#
8+
# After running this, also run release.sh in the w3 repo to update the docs page.
9+
10+
set -e
11+
12+
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
13+
14+
# ── Resolve version ──────────────────────────────────────────────────────────
15+
16+
if [ -n "$1" ]; then
17+
NEW="$1"
18+
else
19+
LATEST=$(git -C "$REPO_DIR" tag --sort=-v:refname | grep '^v[0-9]' | head -1)
20+
if [ -z "$LATEST" ]; then
21+
echo "error: no existing tags found — provide a version explicitly" >&2
22+
exit 1
23+
fi
24+
MAJOR=$(echo "$LATEST" | cut -d. -f1)
25+
MINOR=$(echo "$LATEST" | cut -d. -f2)
26+
PATCH=$(echo "$LATEST" | cut -d. -f3)
27+
NEW="${MAJOR}.${MINOR}.$((PATCH + 1))"
28+
fi
29+
30+
case "$NEW" in v*) ;; *) NEW="v${NEW}" ;; esac
31+
32+
OLD=$(git -C "$REPO_DIR" tag --sort=-v:refname | grep '^v[0-9]' | head -1)
33+
34+
if [ "$NEW" = "$OLD" ]; then
35+
echo "error: new version ($NEW) is the same as the current tag" >&2
36+
exit 1
37+
fi
38+
39+
echo "Releasing $OLD$NEW"
40+
41+
# ── Validate git state ───────────────────────────────────────────────────────
42+
43+
cd "$REPO_DIR"
44+
45+
BRANCH=$(git branch --show-current)
46+
if [ "$BRANCH" != "main" ]; then
47+
echo "error: not on main (currently on '$BRANCH') — check out main before releasing" >&2
48+
exit 1
49+
fi
50+
51+
git fetch origin main --quiet
52+
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then
53+
echo "error: local main is not up to date with origin/main — run 'git pull' first" >&2
54+
exit 1
55+
fi
56+
57+
# ── Tag ──────────────────────────────────────────────────────────────────────
58+
59+
git tag "$NEW"
60+
git push origin "$NEW"
61+
echo "✓ Tagged and pushed $NEW"
62+
63+
# ── Update README.md ─────────────────────────────────────────────────────────
64+
65+
sed -i '' "s|@${OLD}|@${NEW}|g" "$REPO_DIR/README.md"
66+
git add README.md
67+
git commit -m "chore: bump action version to ${NEW}"
68+
git push origin main
69+
echo "✓ Updated README.md and pushed"
70+
71+
# ── Done ─────────────────────────────────────────────────────────────────────
72+
73+
echo ""
74+
echo "Release $NEW complete."
75+
echo " Tag: https://github.com/oasdiff/oasdiff-action/releases/tag/${NEW}"
76+
echo ""
77+
echo "Next: run release.sh in the w3 repo to update the docs page (version: ${NEW})"

0 commit comments

Comments
 (0)