Skip to content

fix CI for build condition #36

fix CI for build condition

fix CI for build condition #36

Workflow file for this run

name: Test
on:
push:
branches:
- master
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', '3.14']
steps:
- name: Print github context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo $GITHUB_CONTEXT
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v6
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.event_name == 'push' && github.ref == 'refs/heads/master' )
|| ( github.event_name == 'release' )
)
}}
needs:
- tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: astral-sh/setup-uv@v6
- name: build package
run: uv build
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: distributions
path: dist/
publish-to-testpypi:
name: Upload release to TestPyPI
if: ${{ github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' }} # only publish to TestPyPI on push to master
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.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 TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
repository-url: https://test.pypi.org/legacy/
publish-to-pypi:
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
github-release:
name: Sign the Python 🐍 distribution 📦 with Sigstore and upload them to GitHub Release
if: ${{ github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
needs:
- publish-to-pypi
environment: release
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
"$GITHUB_REF_NAME" dist/**
--repo "$GITHUB_REPOSITORY"