43 lines
1.4 KiB
YAML
43 lines
1.4 KiB
YAML
name: Publish Python package
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
release:
|
|
types:
|
|
- published
|
|
|
|
jobs:
|
|
publish:
|
|
name: Publish shared Python package
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Build and publish package
|
|
env:
|
|
PACKAGE_REGISTRY_USERNAME: ${{ secrets.PACKAGE_REGISTRY_USERNAME }}
|
|
PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}
|
|
TWINE_REPOSITORY_URL: https://repos.gfranz.ch/api/packages/Gabriel20xx/pypi
|
|
run: |
|
|
set -euo pipefail
|
|
if [ -z "$PACKAGE_REGISTRY_USERNAME" ] || [ -z "$PACKAGE_REGISTRY_TOKEN" ]; then
|
|
echo 'PACKAGE_REGISTRY_USERNAME and PACKAGE_REGISTRY_TOKEN secrets are required.' >&2
|
|
exit 1
|
|
fi
|
|
python -m pip install --disable-pip-version-check --no-cache-dir build twine
|
|
package_directory="$RUNNER_TEMP/gitea-pypi-package"
|
|
python -m build packages/python-backend --outdir "$package_directory"
|
|
TWINE_USERNAME="$PACKAGE_REGISTRY_USERNAME" \
|
|
TWINE_PASSWORD="$PACKAGE_REGISTRY_TOKEN" \
|
|
python -m twine upload --non-interactive --skip-existing "$package_directory"/*
|