Use CI post version for Gitea package uploads

This commit is contained in:
José Arturo García
2026-07-22 19:30:47 -04:00
parent f448205978
commit 9374457c57
2 changed files with 34 additions and 4 deletions
+28 -1
View File
@@ -24,6 +24,26 @@ jobs:
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install build twine 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 - name: Build package
run: | run: |
python -m build python -m build
@@ -32,12 +52,19 @@ jobs:
run: | run: |
python -m twine check dist/* 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 - name: Publish to Gitea PyPI registry
env: env:
TWINE_USERNAME: ${{ secrets.GITEA_PACKAGE_USER }} TWINE_USERNAME: ${{ secrets.GITEA_PACKAGE_USER }}
TWINE_PASSWORD: ${{ secrets.GITEA_PACKAGE_TOKEN }} TWINE_PASSWORD: ${{ secrets.GITEA_PACKAGE_TOKEN }}
run: | run: |
python -m twine upload \ python -m twine upload \
--skip-existing \
--repository-url https://gitea.joseagrc.com/api/packages/tryton-do/pypi \ --repository-url https://gitea.joseagrc.com/api/packages/tryton-do/pypi \
dist/* dist/*
+6 -3
View File
@@ -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 ``actions/upload-artifact`` because current Gitea Actions runners do not support
the GitHub artifact API required by ``upload-artifact@v4``. the GitHub artifact API required by ``upload-artifact@v4``.
The publishing workflow uses ``twine upload --skip-existing`` so repeated The publishing workflow creates a CI-only package version by appending the run
commits with the same package version do not fail. To publish a new package number to the module version from ``tryton.cfg``. For example, a module version
artifact, update the module version in ``tryton.cfg`` before pushing. 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: Required repository secrets: