From fe33210cde10e60dcaa4eb80500fda2ae3a76ae3 Mon Sep 17 00:00:00 2001 From: Niklas Bittner Date: Tue, 4 Feb 2025 01:28:00 +0100 Subject: [PATCH] ci: add gitea build and publish actions --- .gitea/scripts/setup-poetry.sh | 21 +++++++++++++++++++ .gitea/workflows/build.yml | 37 ++++++++++++++++++++++++++++++++++ .gitea/workflows/publish.yml | 29 ++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100755 .gitea/scripts/setup-poetry.sh create mode 100644 .gitea/workflows/build.yml create mode 100644 .gitea/workflows/publish.yml diff --git a/.gitea/scripts/setup-poetry.sh b/.gitea/scripts/setup-poetry.sh new file mode 100755 index 0000000..9f4141a --- /dev/null +++ b/.gitea/scripts/setup-poetry.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +echo "Setting up Python and Poetry..." + +# Install Poetry +pip install pipx +pipx install poetry + +# Add Poetry to PATH +echo "$HOME/.poetry/bin" >> $GITHUB_PATH + +# Configure Poetry +poetry config virtualenvs.create false + +poetry check + +poetry lock --check + +# Install dependencies +poetry install --no-root --no-interaction \ No newline at end of file diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..8e2c4c6 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,37 @@ +name: Build Python Package + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.13" + + - name: Run setup script + run: .gitea/scripts/setup-poetry.sh + + - name: Check code formatting by black + run: | + poetry run black . --check + + - name: Lint code by ruff + run: | + poetry run ruff . + + - name: Check types by pyright + run: | + poetry run pyright + + - name: Build package + run: poetry build diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..1088e1b --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish Python Package + +on: + push: + tags: + - "v*" + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.13" + + - name: Run setup script + run: .gitea/scripts/setup-poetry.sh + + - name: Build package + run: poetry build + + - name: Publish to PyPI + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} + run: poetry publish --username __token__ --password $POETRY_PYPI_TOKEN_PYPI