diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 0000000..38a2c31 --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,46 @@ +name: Build and Publish + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install Poetry + run: curl -sSL https://install.python-poetry.org | python3 - + + - name: Configure Poetry to add to PATH + run: echo "${{ runner.tool_cache }}/poetry/$(poetry --version | awk '{print $3}')/bin" >> $GITHUB_PATH + + - name: Install dependencies + run: | + cd pkg + poetry install + + - name: Run tests + run: poetry run pytest -v . --junitxml=results.xml + + - name: Build the package + run: poetry build + + - name: Publish to PyPI + if: github.ref == 'refs/heads/master' + env: + POETRY_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + POETRY_PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + run: poetry publish --build --username $POETRY_PYPI_USERNAME --password $POETRY_PYPI_API_TOKEN +