diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..cd1f796 --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -0,0 +1,45 @@ +name: Publish Python package to PyPI + +#on: +# push: +# tags: +# - "v*" +on: + release: + types: [published] + +jobs: + publish: + runs-on: self-hosted + + steps: + - name: Check out repository + uses: https://github.com/actions/checkout@v4 + + - name: Create virtual environment + run: python3 -m venv .venv + + - name: Install build tools + run: .venv/bin/pip install --upgrade build twine + + - name: Verify tag matches package version + run: | + TAG="${GITHUB_REF_NAME}" + VERSION="$(grep -m1 '^version = ' pyproject.toml | cut -d '"' -f2)" + if [ "$TAG" != "v$VERSION" ]; then + echo "::error::Tag ${TAG} does not match package version v${VERSION}" + exit 1 + fi + + - name: Build package + run: .venv/bin/python3 -m build + + - name: Check package + run: .venv/bin/python3 -m twine check dist/* + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + TWINE_NON_INTERACTIVE: "1" + run: .venv/bin/python3 -m twine upload dist/* diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..efaea9d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,42 @@ +# This workflow will upload a Python Package to PyPI when a release is created +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Create and Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + build-and-publish: + name: Build and Publish + environment: pypi + permissions: + id-token: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + #- uses: actions/setup-python@v5 + # with: + # python-version: "3.x" + + - name: Install build tools + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade build + + - name: Build release + run: | + python -m build --sdist --wheel + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1