diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..6479d81 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,41 @@ +name: Publish to PyPI + +on: + push: + tags: + - 'v*' # Trigger this workflow for tags starting with "v" + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 # Specify the Python version + + - name: Install Poetry + run: | + python -m pip install --upgrade pip + pip install poetry + + - name: Extract version from tag + id: get_version + run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + + - name: Update version in pyproject.toml + run: poetry version ${{ env.version }} + + - name: Install dependencies + run: poetry install --no-root + + - name: Build and Publish to PyPI + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} + run: | + poetry build + poetry publish