Skip to content

Commit 07e652b

Browse files
committed
Automate PyPI releases
1 parent 3b397f3 commit 07e652b

2 files changed

Lines changed: 87 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ jobs:
6060
- name: Install development tools
6161
run: |
6262
python -m pip install --upgrade pip
63-
python -m pip install --editable . --requirement requirements-test.txt pyright build
63+
python -m pip install \
64+
--editable . \
65+
--requirement requirements-test.txt \
66+
--requirement requirements-docs.txt \
67+
pyright \
68+
build
6469
6570
- name: Check formatting
6671
run: |
@@ -80,5 +85,8 @@ jobs:
8085
tests/integration \
8186
tests/fixtures/customxml/generate_fixture.py
8287
88+
- name: Build documentation
89+
run: python -m sphinx -W --keep-going -b html docs docs/.build/html
90+
8391
- name: Build distributions
8492
run: python -m build

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
test:
12+
name: Test Python ${{ matrix.python-version }}
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: ["3.12", "3.13", "3.14"]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
cache: pip
27+
cache-dependency-path: requirements-test.txt
28+
29+
- name: Install test dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
python -m pip install --editable . --requirement requirements-test.txt
33+
34+
- name: Verify release version
35+
run: |
36+
package_version="$(python -c 'import docx; print(docx.__version__)')"
37+
tag_version="${GITHUB_REF_NAME#v}"
38+
test "$package_version" = "$tag_version"
39+
40+
- name: Run unit and integration tests
41+
run: python -m pytest -q
42+
43+
- name: Run acceptance tests
44+
run: python -m behave --format progress --stop --tags=-wip
45+
46+
publish:
47+
name: Publish to PyPI
48+
needs: test
49+
runs-on: ubuntu-latest
50+
environment:
51+
name: pypi
52+
url: https://pypi.org/project/python-docx-oss/
53+
permissions:
54+
contents: read
55+
id-token: write
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: "3.12"
64+
65+
- name: Build distributions
66+
run: |
67+
python -m pip install --upgrade build twine
68+
python -m build
69+
python -m twine check dist/*
70+
71+
- name: Verify release version
72+
run: |
73+
package_version="$(python -c 'import docx; print(docx.__version__)')"
74+
tag_version="${GITHUB_REF_NAME#v}"
75+
test "$package_version" = "$tag_version"
76+
77+
- name: Publish distributions
78+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)