Skip to content

using uv for dev setup, build, publish #3

using uv for dev setup, build, publish

using uv for dev setup, build, publish #3

Workflow file for this run

name: Test
on:
push:
paths-ignore:
- 'doc/**'
pull_request:
paths-ignore:
- 'doc/**'
release:
types: [released]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: [3.9, '3.10', '3.11', '3.12', '3.13']
steps:
- name: Print github context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo $GITHUB_CONTEXT
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
cache-suffix: ${{ matrix.python-version }}
- name: Install Python
run: uv python install ${{ matrix.python-version }}
env:
UV_PYTHON_PREFERENCE: only-managed
- name: Install Transifex CLI
run: |
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
mv tx /usr/local/bin/tx
- name: Tox tests
run: uv run --only-dev tox -- -v --durations=25
build:
name: build distribution
if: github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master'
needs:
- tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python
uses: astral-sh/setup-uv@v3
- name: build package
run: uv build
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: distributions
path: dist/
pypi-publish:
name: Upload release to PyPI
if: github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/sphinx-intl
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: distributions
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
# for test
password: ${{ secrets.TESTPYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
# for production
# password: ${{ secrets.PYPI_TOKEN }}
github-release:
name: GitHub release
if: github.repository_owner == 'sphinx-doc'
runs-on: ubuntu-latest
needs:
- pypi-publish
environment: release
permissions:
contents: write # for softprops/action-gh-release to create GitHub release
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Get release version
id: get_version
uses: actions/github-script@v7
with:
script: core.setOutput('version', context.ref.replace("refs/tags/", ""))
- name: Create GitHub release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
name: "sphinx-intl ${{ steps.get_version.outputs.version }}"
body: "Changelog: https://sphinx-intl.readthedocs.io/en/master/changes.html"