Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 10 additions & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- name: Checkout release branch
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
fetch-depth: 0

- name: Set up Python
Expand All @@ -35,24 +36,22 @@ jobs:
- name: Install dependencies
run: ./scripts/setup.sh

- name: Bootstrap tag
id: tag-bootstrap
run: ./scripts/version-tag-bootstrap.sh true

- name: Tag version
id: tag-version
- name: Create GitHub release
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: ./scripts/version-tag-id.sh
run: ./scripts/create-release.sh true

- name: Build
if: steps.tag-version.outputs.released == 'true'
if: steps.create-release.outputs.released == 'true'
run: ./scripts/build.sh

- name: Publish to GitHub
id: publish-github
if: steps.tag-version.outputs.released == 'true'
- name: Publish GitHub release
id: publish-release
if: steps.create-release.outputs.released == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./scripts/publish.sh
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ exclude_lines = [
"pragma: no cover",
]

[tool.setuptools_scm]
tag_regex = "v?(?P<version>\\d+\\.\\d+\\.\\d+.*)"

# Decide next SemVer, create the tag, create the GitHub release
[tool.semantic_release]
version_source = "tag"
tag_format = "v{version}"
# Start here if no tag exists yet:
initial_version = "0.1.0"
allow_initial_release = true

# Use tag to set __version__/project version for build artifact
[tool.setuptools_scm]
tag_regex = "v?(?P<version>\\d+\\.\\d+\\.\\d+.*)"
54 changes: 54 additions & 0 deletions scripts/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# Create a GitHub release.
# - Bootstrap the version tag if it doesn't exist.
# - Determine the next version from commit history.
# - Tag the commit with the new version and push it.
# - Create a GitHub release with semantic-release.
# - Output the release tag and whether a release was created.

PUSH_TAG="${1:-false}"
INITIAL_VERSION_TAG="v0.0.0"

# Only configure Git identity in CI environment
if [[ -n "${CI:-}" || -n "${GITHUB_ACTIONS:-}" ]]; then
echo "Configuring Git identity for CI environment"
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
fi

# Bootstrap the version tag if it doesn't exist.
if ! git describe --tags --abbrev=0 >/dev/null 2>&1; then
echo "No version tags found; bootstrapping $INITIAL_VERSION_TAG"
git tag -a "${INITIAL_VERSION_TAG}" "$(git rev-list --max-parents=0 HEAD)" -m "bootstrap"

if [ "$PUSH_TAG" = "true" ]; then
echo "Pushing tag $INITIAL_VERSION_TAG"
git push -f origin "${INITIAL_VERSION_TAG}"
else
echo "Pushing bootstrap tag is disabled (PUSH_TAG=$PUSH_TAG)"
fi
fi

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

# Publish with semantic release.
uv run python -m semantic_release publish
after="$(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
released=true
tag="$after"
fi

if [ -z "$GITHUB_OUTPUT" ]; then
echo "GITHUB_OUTPUT is not set"
exit 1
fi

echo "released=$released" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
22 changes: 0 additions & 22 deletions scripts/version-tag-bootstrap.sh

This file was deleted.

24 changes: 0 additions & 24 deletions scripts/version-tag-id.sh

This file was deleted.