diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml index 1329dc9..d0666fd 100644 --- a/.gitea/workflows/publish.yml +++ b/.gitea/workflows/publish.yml @@ -24,6 +24,26 @@ jobs: python -m pip install --upgrade pip python -m pip install build twine + - name: Set CI package version + run: | + python - <<'PY' + from pathlib import Path + import os + import re + + path = Path('tryton.cfg') + text = path.read_text() + match = re.search(r'(?m)^version=(.+)$', text) + if not match: + raise SystemExit('tryton.cfg has no version entry') + base_version = match.group(1).strip() + run_number = os.environ.get('GITHUB_RUN_NUMBER', '0') + ci_version = f'{base_version}.post{run_number}' + text = re.sub(r'(?m)^version=.+$', f'version={ci_version}', text) + path.write_text(text) + print(f'Package version: {ci_version}') + PY + - name: Build package run: | python -m build @@ -32,12 +52,19 @@ jobs: run: | python -m twine check dist/* + - name: Check publishing credentials + env: + TWINE_USERNAME: ${{ secrets.GITEA_PACKAGE_USER }} + TWINE_PASSWORD: ${{ secrets.GITEA_PACKAGE_TOKEN }} + run: | + test -n "$TWINE_USERNAME" || { echo "Missing GITEA_PACKAGE_USER secret"; exit 1; } + test -n "$TWINE_PASSWORD" || { echo "Missing GITEA_PACKAGE_TOKEN secret"; exit 1; } + - name: Publish to Gitea PyPI registry env: TWINE_USERNAME: ${{ secrets.GITEA_PACKAGE_USER }} TWINE_PASSWORD: ${{ secrets.GITEA_PACKAGE_TOKEN }} run: | python -m twine upload \ - --skip-existing \ --repository-url https://gitea.joseagrc.com/api/packages/tryton-do/pypi \ dist/* diff --git a/doc/publishing.rst b/doc/publishing.rst index 78bcd37..a0082fc 100644 --- a/doc/publishing.rst +++ b/doc/publishing.rst @@ -6,9 +6,12 @@ PyPI-compatible package registry. The workflow intentionally does not use ``actions/upload-artifact`` because current Gitea Actions runners do not support the GitHub artifact API required by ``upload-artifact@v4``. -The publishing workflow uses ``twine upload --skip-existing`` so repeated -commits with the same package version do not fail. To publish a new package -artifact, update the module version in ``tryton.cfg`` before pushing. +The publishing workflow creates a CI-only package version by appending the run +number to the module version from ``tryton.cfg``. For example, a module version +of ``8.0.0`` is published as ``8.0.0.post123`` on run number ``123``. + +This is necessary because Gitea's PyPI-compatible registry is a custom package +repository for Twine and does not support ``twine upload --skip-existing``. Required repository secrets: