Skip to content

0.7.0

0.7.0 #17

Workflow file for this run

name: release-main
on:
release:
types: [published]
jobs:
set-version:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Export tag
id: vars
run: |
release_version="${GITHUB_REF_NAME}"
if [[ ! "$release_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Release tag must be a plain X.Y.Z version, for example 0.3.0. Do not use a v prefix." >&2
exit 1
fi
echo "version=$release_version" >> "$GITHUB_OUTPUT"
if: ${{ github.event_name == 'release' }}
- name: Validate checked-in versions
run: |
python - <<'PY'
import json
import os
import sys
import tomllib
from pathlib import Path
expected = os.environ["RELEASE_VERSION"]
pyproject = tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]
plugin = json.loads(Path(".claude-plugin/plugin.json").read_text())["version"]
lock = tomllib.loads(Path("uv.lock").read_text())
locked = next(
package["version"]
for package in lock["package"]
if package["name"] == "docx-editor"
)
versions = {
"release tag": expected,
"pyproject.toml": pyproject,
"uv.lock": locked,
".claude-plugin/plugin.json": plugin,
}
mismatches = {name: version for name, version in versions.items() if version != expected}
if mismatches:
for name, version in versions.items():
print(f"{name}: {version}", file=sys.stderr)
raise SystemExit("Release versions must all match before publishing.")
PY
env:
RELEASE_VERSION: ${{ steps.vars.outputs.version }}
if: ${{ github.event_name == 'release' }}
- name: Update project version
run: |
sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml
env:
RELEASE_VERSION: ${{ steps.vars.outputs.version }}
if: ${{ github.event_name == 'release' }}
- name: Upload updated pyproject.toml
uses: actions/upload-artifact@v4
with:
name: pyproject-toml
path: pyproject.toml
publish:
runs-on: ubuntu-latest
needs: [set-version]
permissions:
id-token: write # Required for trusted publishing
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up the environment
uses: ./.github/actions/setup-python-env
- name: Download updated pyproject.toml
uses: actions/download-artifact@v4
with:
name: pyproject-toml
- name: Build package
run: uv build
- name: Publish package
run: uv publish
deploy-docs:
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write # Required for gh-pages push
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up the environment
uses: ./.github/actions/setup-python-env
- name: Deploy documentation
run: uv run mkdocs gh-deploy --force