|
| 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