Skip to content

Commit 9c92e3d

Browse files
authored
Merge pull request #125 from kaijensen55/fix/ci-uv-build
ci: use uv build in publish workflows
2 parents a66121d + 7dffaa3 commit 9c92e3d

14 files changed

+312
-31
lines changed

.github/workflows/auto_ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
os: [ubuntu-latest, windows-latest]
1818

1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v5
2121
- name: Set up Python ${{ matrix.python-version }}
2222
uses: actions/setup-python@v6
2323
with:
@@ -44,9 +44,6 @@ jobs:
4444
- name: Test with pytest
4545
run: |
4646
uv run pytest --doctest-modules --cov -v xbbg
47-
- name: Build Sphinx docs
48-
run: |
49-
uv run sphinx-build -b html docs docs/_build/html
5047
- name: Coverage report
5148
run: |
5249
uv run codecov --token=ff17768d-30bd-4917-98f2-a011606597ea

.github/workflows/ci_docs.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-docs:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v5
14+
- name: Set up Python 3.12
15+
uses: actions/setup-python@v6
16+
with:
17+
python-version: '3.12'
18+
- name: Install uv
19+
run: |
20+
curl -LsSf https://astral.sh/uv/install.sh | sh
21+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
22+
- name: Sync docs dependencies
23+
run: |
24+
uv --version
25+
uv sync --locked --extra docs
26+
- name: Build Sphinx HTML
27+
run: |
28+
uv run sphinx-build -W -b html docs docs/_build/html
29+
- name: Link check (non-blocking)
30+
continue-on-error: true
31+
run: |
32+
uv run sphinx-build -b linkcheck docs docs/_build/linkcheck
33+
- name: Trigger Read the Docs build (main only)
34+
if: github.ref == 'refs/heads/main'
35+
env:
36+
READTHEDOCS_TOKEN: ${{ secrets.READTHEDOCS_TOKEN }}
37+
READTHEDOCS_PROJECT: ${{ secrets.READTHEDOCS_PROJECT }}
38+
run: |
39+
if [ -n "${READTHEDOCS_TOKEN}" ] && [ -n "${READTHEDOCS_PROJECT}" ]; then
40+
curl -sSf -X POST \
41+
-H "Authorization: Token ${READTHEDOCS_TOKEN}" \
42+
-H "Content-Type: application/json" \
43+
-d '{"version": "latest"}' \
44+
https://readthedocs.org/api/v3/projects/${READTHEDOCS_PROJECT}/versions/latest/builds/
45+
else
46+
echo "READTHEDOCS_* secrets not set; skipping RTD trigger"
47+
fi
48+
49+

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
steps:
3232
- name: Checkout repository
33-
uses: actions/checkout@v3
33+
uses: actions/checkout@v5
3434
with:
3535
# We must fetch at least the immediate parents so that if this is
3636
# a pull request then we can checkout the head.

.github/workflows/publish_docs.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish Docs (Read the Docs)
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
steps:
13+
- uses: actions/checkout@v5
14+
- name: Trigger Read the Docs build for latest
15+
if: env.READTHEDOCS_TOKEN != '' && env.READTHEDOCS_PROJECT != ''
16+
env:
17+
READTHEDOCS_TOKEN: ${{ secrets.READTHEDOCS_TOKEN }}
18+
READTHEDOCS_PROJECT: ${{ secrets.READTHEDOCS_PROJECT }}
19+
run: |
20+
curl -sSf -X POST \
21+
-H "Authorization: Token ${READTHEDOCS_TOKEN}" \
22+
-H "Content-Type: application/json" \
23+
-d '{"version": "latest"}' \
24+
https://readthedocs.org/api/v3/projects/${READTHEDOCS_PROJECT}/versions/latest/builds/
25+

.github/workflows/publish_testpypi.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- 'v*rc*'
88
- 'v*alpha*'
99
- 'v*beta*'
10+
- 'xbbg==*rc*'
11+
- 'xbbg==*alpha*'
12+
- 'xbbg==*beta*'
1013

1114
jobs:
1215
deploy:
@@ -16,7 +19,9 @@ jobs:
1619
contents: read
1720

1821
steps:
19-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v5
23+
with:
24+
fetch-depth: 0
2025
- name: Set up Python 3.11
2126
uses: actions/setup-python@v6
2227
with:
@@ -33,12 +38,9 @@ jobs:
3338
run: |
3439
iwr https://astral.sh/uv/install.ps1 -UseBasicParsing | iex
3540
"$env:USERPROFILE\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
36-
- name: Install build tooling with uv
37-
run: |
38-
uv pip install build
39-
- name: Build distributions
41+
- name: Build distributions with uv
4042
run: |
41-
uv run python -m build
43+
uv build
4244
- name: Publish to TestPyPI via OIDC
4345
uses: pypa/gh-action-pypi-publish@release/v1
4446
with:

.github/workflows/pypi_upload.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ jobs:
1313
contents: read
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v5
17+
with:
18+
fetch-depth: 0
1719
- name: Set up Python 3.11
1820
uses: actions/setup-python@v6
1921
with:
@@ -30,12 +32,9 @@ jobs:
3032
run: |
3133
iwr https://astral.sh/uv/install.ps1 -UseBasicParsing | iex
3234
"$env:USERPROFILE\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
33-
- name: Install build tooling with uv
34-
run: |
35-
uv pip install build
36-
- name: Build distributions
35+
- name: Build distributions with uv
3736
run: |
38-
uv run python -m build
37+
uv build
3938
- name: Publish to PyPI via OIDC
4039
uses: pypa/gh-action-pypi-publish@release/v1
4140
with:
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Attach Release Artifacts
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
build-and-attach:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
13+
steps:
14+
- uses: actions/checkout@v5
15+
with:
16+
fetch-depth: 0
17+
- name: Set up Python 3.11
18+
uses: actions/setup-python@v6
19+
with:
20+
python-version: '3.11'
21+
- name: Install uv (Linux/macOS)
22+
shell: bash
23+
run: |
24+
curl -LsSf https://astral.sh/uv/install.sh | sh
25+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
26+
# No manual version rewrite needed; setuptools_scm derives from tag
27+
- name: Build distributions with uv
28+
run: |
29+
uv build
30+
- name: Upload artifacts to GitHub Release
31+
uses: softprops/action-gh-release@v2
32+
with:
33+
files: dist/*
34+
35+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Update Sphinx index.rst on Release
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
update-index:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@v5
14+
- name: Update latest release line in docs/index.rst
15+
env:
16+
TAG_NAME: ${{ github.event.release.tag_name }}
17+
RELEASE_URL: ${{ github.event.release.html_url }}
18+
run: |
19+
set -euo pipefail
20+
VERSION="$TAG_NAME"
21+
VERSION="${VERSION#v}"
22+
VERSION="${VERSION#xbbg==}"
23+
NEW_LINE="Latest release: xbbg==${VERSION} (release: `notes <${RELEASE_URL}>`_)"
24+
awk -v repl="$NEW_LINE" '
25+
/\.. xbbg:latest-release-start/ { print; print repl; drop=1; next }
26+
/\.. xbbg:latest-release-end/ { drop=0; print; next }
27+
drop != 1 { print }
28+
' docs/index.rst > docs/index.rst.tmp && mv docs/index.rst.tmp docs/index.rst
29+
- name: Update changelog section in docs/index.rst
30+
env:
31+
TAG_NAME: ${{ github.event.release.tag_name }}
32+
RELEASE_URL: ${{ github.event.release.html_url }}
33+
RELEASE_BODY: ${{ github.event.release.body }}
34+
PUBLISHED_AT: ${{ github.event.release.published_at }}
35+
run: |
36+
set -euo pipefail
37+
VERSION="$TAG_NAME"
38+
VERSION="${VERSION#v}"
39+
VERSION="${VERSION#xbbg==}"
40+
# Prepare RST changelog entry from the release body; normalize bullets and ensure blank line
41+
printf "*%s* - see release: `notes <%s>`_\n\n%s\n" "$VERSION" "$RELEASE_URL" "$RELEASE_BODY" > .idx_changelog_entry.rst
42+
sed -E 's/^\* /- /' .idx_changelog_entry.rst > .idx_changelog_entry.fix && mv .idx_changelog_entry.fix .idx_changelog_entry.rst
43+
awk 'BEGIN{prev_empty=1} {
44+
if ($0 ~ /^-/ && prev_empty==0) { print "" }
45+
print; prev_empty = ($0 ~ /^\s*$/) ? 1 : 0
46+
}' .idx_changelog_entry.rst > .idx_changelog_entry2.rst && mv .idx_changelog_entry2.rst .idx_changelog_entry.rst
47+
# Replace the block between markers with the new entry
48+
awk 'BEGIN{emit=1}
49+
/\.. xbbg:changelog-start/ { print; system("cat .idx_changelog_entry.rst"); skip=1; next }
50+
/\.. xbbg:changelog-end/ { skip=0; print; next }
51+
skip!=1 { print }' docs/index.rst > docs/index.rst.tmp && mv docs/index.rst.tmp docs/index.rst
52+
- name: Commit docs index update
53+
if: ${{ env.ACT != 'true' }}
54+
run: |
55+
set -euo pipefail
56+
if git diff --quiet; then
57+
echo "No docs changes to commit"
58+
exit 0
59+
fi
60+
git config user.name "github-actions[bot]"
61+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
62+
git add docs/index.rst
63+
git commit -m "docs(index): update What's New and latest release for ${{ github.event.release.tag_name }}"
64+
git push
65+
66+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Update README on Release
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
update-readme:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@v5
14+
- name: Update latest release line in README
15+
env:
16+
TAG_NAME: ${{ github.event.release.tag_name }}
17+
RELEASE_URL: ${{ github.event.release.html_url }}
18+
run: |
19+
set -euo pipefail
20+
VERSION="$TAG_NAME"
21+
VERSION="${VERSION#v}"
22+
VERSION="${VERSION#xbbg==}"
23+
NEW_LINE="Latest release: xbbg==${VERSION} (release: [notes](${RELEASE_URL}))"
24+
awk -v repl="$NEW_LINE" '
25+
/<!-- xbbg:latest-release-start -->/ { print; print repl; drop=1; next }
26+
/<!-- xbbg:latest-release-end -->/ { drop=0; print; next }
27+
drop != 1 { print }
28+
' README.md > README.md.tmp && mv README.md.tmp README.md
29+
- name: Update changelog section in README
30+
env:
31+
TAG_NAME: ${{ github.event.release.tag_name }}
32+
RELEASE_URL: ${{ github.event.release.html_url }}
33+
RELEASE_BODY: ${{ github.event.release.body }}
34+
PUBLISHED_AT: ${{ github.event.release.published_at }}
35+
run: |
36+
set -euo pipefail
37+
VERSION="$TAG_NAME"
38+
VERSION="${VERSION#v}"
39+
VERSION="${VERSION#xbbg==}"
40+
# Use the ISO date part
41+
DATE="${PUBLISHED_AT%%T}"
42+
# Prepare changelog entry (avoid bare URL)
43+
printf "_%s_ - see release: [notes](%s)\n\n%s\n" "$VERSION" "$RELEASE_URL" "$RELEASE_BODY" > .changelog_entry.md
44+
# Normalize list bullets to dash and ensure a blank line before list items
45+
sed -E 's/^\* /- /' .changelog_entry.md > .changelog_entry.bullets && mv .changelog_entry.bullets .changelog_entry.md
46+
awk 'BEGIN{prev_empty=1} {
47+
if ($0 ~ /^-/ && prev_empty==0) { print "" }
48+
print; prev_empty = ($0 ~ /^\s*$/) ? 1 : 0
49+
}' .changelog_entry.md > .changelog_entry.fix && mv .changelog_entry.fix .changelog_entry.md
50+
# Replace the block between markers with the new entry
51+
sed -n '1,/<!-- xbbg:changelog-start -->/p' README.md > README.md.tmp
52+
cat .changelog_entry.md >> README.md.tmp
53+
sed -n '/<!-- xbbg:changelog-end -->/,$p' README.md >> README.md.tmp
54+
mv README.md.tmp README.md
55+
- name: Commit README changelog update
56+
if: ${{ env.ACT != 'true' }}
57+
run: |
58+
set -euo pipefail
59+
if git diff --quiet; then
60+
echo "No README changes to commit"
61+
exit 0
62+
fi
63+
git config user.name "github-actions[bot]"
64+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
65+
git add README.md
66+
git commit -m "docs(README): update changelog for ${{ github.event.release.tag_name }}"
67+
git push
68+
- name: Commit changes
69+
if: ${{ env.ACT != 'true' }}
70+
run: |
71+
set -euo pipefail
72+
if git diff --quiet; then
73+
echo "No README changes to commit"
74+
exit 0
75+
fi
76+
git config user.name "github-actions[bot]"
77+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
78+
git add README.md
79+
git commit -m "docs(README): update latest release to ${{ github.event.release.tag_name }}"
80+
git push
81+

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
recursive-include xbbg/markets *.yml
2+
prune xbbg/tests
3+

0 commit comments

Comments
 (0)