Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions scripts/create-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ if [[ -n "${CI:-}" || -n "${GITHUB_ACTIONS:-}" ]]; then
git config --local user.name "github-actions"
fi

# Fetch tags to ensure we have the latest version.
git fetch --tags --force --prune

# Show relevant commit history.
echo "Last 10 main commits (subject only):"
git --no-pager log --pretty=format:'%h %s' -10
echo "Commits since last tag (if any):"
last="$(git describe --tags --abbrev=0 2>/dev/null || echo none)"
if [ "$last" != "none" ]; then
git --no-pager log --pretty=format:'%h %s' "$last"..HEAD
fi

# Bootstrap the version tag if it doesn't exist.
if ! git describe --tags --abbrev=0 >/dev/null 2>&1; then
first_commit="$(git rev-list --max-parents=0 HEAD)"
Expand All @@ -32,18 +44,24 @@ if ! git describe --tags --abbrev=0 >/dev/null 2>&1; then
fi

# Record previous tag (if any).
before="$(git describe --tags --abbrev=0 2>/dev/null || echo none)"
previous_tag="$(git describe --tags --abbrev=0 2>/dev/null || echo none)"

# Publish with semantic release.
export SEMANTIC_RELEASE_LOG=DEBUG
uv run python -m semantic_release publish
after="$(git describe --tags --abbrev=0 2>/dev/null || echo none)"
new_tag="$(git describe --tags --abbrev=0 2>/dev/null || echo none)"

# Determine if a release was created.
released=false
tag=""
if [ "$after" != "none" ] && [ "$after" != "$before" ]; then
if [ "$new_tag" != "none" ] && [ "$new_tag" != "$previous_tag" ]; then
released=true
tag="$after"
tag="$new_tag"
echo "New tag was created (new_tag=$new_tag, previous_tag=$previous_tag)"
else
echo "No new tag was created (new_tag=$new_tag, previous_tag=$previous_tag)"
git --no-pager log --pretty=format:'%h %s' "${INITIAL_VERSION_TAG}..HEAD" | sed -n '1,50p'
uv run python -m semantic_release version --noop --log DEBUG
fi

if [ -z "$GITHUB_OUTPUT" ]; then
Expand Down