Files
account_do/.gitea/workflows/publish.yml
T

71 lines
2.0 KiB
YAML

name: Publish Package
on:
push:
branches:
- "**"
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build tools
run: |
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
- name: Check package
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 \
--repository-url https://gitea.joseagrc.com/api/packages/tryton-do/pypi \
dist/*