From 2d4df9bae1daee7768553757d26058bbb2c6e2e4 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sun, 26 May 2024 08:57:14 +0200 Subject: [PATCH] feat: Add PyPI publishing workflow Introduced a Forgejo Actions workflow for automatically publishing new versions to PyPI upon pushing tags. This enhancement automates the release process for Python packages, ensuring that tagged commits trigger a build and publish sequence in a controlled, containerized environment. The workflow includes steps for setting up the environment, installing dependencies, and securely uploading the package using stored PyPI tokens. By automating the release pipeline, this change aims to reduce manual errors, streamline version releases, and support continuous delivery practices for Python projects. --- .forgejo/workflows/release.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .forgejo/workflows/release.yml diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..a344b2d --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,32 @@ +name: Python Package CI/CD + +on: + workflow_dispatch: + push: + tags: + - "*" + +jobs: + publish: + name: Publish to PyPI + container: + image: node:20-bookworm + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + apt update + apt install -y python3 python3-venv + + - name: Publish to PyPI + run: | + python3 -m venv venv + . ./venv/bin/activate + pip install -U twine build + python -m build . + python -m twine upload --username __token__ --password ${PYPI_TOKEN} dist/* + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}