Skip to content

Commit fede11a

Browse files
fix(ci): keep lockfile in sync
during releases
1 parent ff1c48d commit fede11a

3 files changed

Lines changed: 46 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ jobs:
4444
permissions:
4545
contents: write
4646
outputs:
47-
commit_sha: ${{ steps.semantic-release.outputs.commit_sha }}
48-
released: ${{ steps.semantic-release.outputs.released }}
49-
tag: ${{ steps.semantic-release.outputs.tag }}
50-
version: ${{ steps.semantic-release.outputs.version }}
47+
commit_sha: ${{ steps.release-metadata.outputs.commit_sha }}
48+
released: ${{ steps.release-plan.outputs.released }}
49+
tag: ${{ steps.release-plan.outputs.tag }}
50+
version: ${{ steps.release-plan.outputs.version }}
5151
steps:
5252
- uses: actions/checkout@v4
5353
with:
@@ -80,12 +80,41 @@ jobs:
8080
exit 0
8181
fi
8282
echo "ready=true" >> "$GITHUB_OUTPUT"
83-
- name: Semantic release
83+
- name: Plan release
8484
if: steps.release-baseline.outputs.ready == 'true'
85-
id: semantic-release
86-
uses: python-semantic-release/python-semantic-release@v10.4.1
87-
with:
88-
github_token: ${{ secrets.GITHUB_TOKEN }}
85+
id: release-plan
86+
env:
87+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
run: |
89+
current_version="$(python - <<'PY'
90+
from pathlib import Path
91+
import tomllib
92+
93+
pyproject = tomllib.loads(Path("pyproject.toml").read_text())
94+
print(pyproject["project"]["version"])
95+
PY
96+
)"
97+
next_version="$(uv run --python 3.14 semantic-release version --print)"
98+
99+
if [ "$next_version" = "$current_version" ]; then
100+
echo "released=false" >> "$GITHUB_OUTPUT"
101+
echo "version=$current_version" >> "$GITHUB_OUTPUT"
102+
echo "tag=v$current_version" >> "$GITHUB_OUTPUT"
103+
exit 0
104+
fi
105+
106+
echo "released=true" >> "$GITHUB_OUTPUT"
107+
echo "version=$next_version" >> "$GITHUB_OUTPUT"
108+
echo "tag=v$next_version" >> "$GITHUB_OUTPUT"
109+
- name: Run semantic release
110+
if: steps.release-baseline.outputs.ready == 'true' && steps.release-plan.outputs.released == 'true'
111+
env:
112+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
run: uv run --python 3.14 semantic-release version --strict
114+
- name: Capture release metadata
115+
if: steps.release-baseline.outputs.ready == 'true' && steps.release-plan.outputs.released == 'true'
116+
id: release-metadata
117+
run: echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
89118

90119
publish-package:
91120
if: needs.release.outputs.released == 'true'
@@ -104,7 +133,7 @@ jobs:
104133
with:
105134
python-version: "3.14"
106135
- name: Install dependencies
107-
run: uv sync --python 3.14 --frozen
136+
run: uv sync --python 3.14 --locked
108137
- name: Build package
109138
run: uv build
110139
- name: Install Twine
@@ -133,7 +162,7 @@ jobs:
133162
python-version: "3.14"
134163
- uses: actions/configure-pages@v5
135164
- name: Install dependencies
136-
run: uv sync --python 3.14 --frozen
165+
run: uv sync --python 3.14 --locked
137166
- name: Build docs
138167
run: uv run --python 3.14 mkdocs build --strict
139168
- name: Upload Pages artifact

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ dev = [
5151
]
5252

5353
[tool.semantic_release]
54+
build_command = """
55+
uv lock
56+
uv build
57+
uv run --python 3.14 mkdocs build --strict
58+
"""
5459
commit_message = "chore(release): v{version}"
5560
commit_parser = "conventional"
5661
tag_format = "v{version}"
@@ -74,4 +79,3 @@ minor_tags = ["feat"]
7479
patch_tags = ["fix", "perf"]
7580
parse_squash_commits = true
7681
ignore_merge_commits = true
77-

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)