diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..0a3c8ce --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,75 @@ +name: Build and Release + +permissions: + contents: write + +on: + push: + branches: [main] + tags: + - 'v*' + pull_request: + branches: [main] + +jobs: + build-and-publish: + name: Build Wheel and Publish to PyPI + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write # Required for trusted publishing to PyPI + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.8' + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install build + + - name: Get version from pyproject.toml + id: get_version + run: | + VERSION=$(grep -E '^version = ' pyproject.toml | cut -d '"' -f 2) + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Building version: $VERSION" + + - name: Build wheel and sdist + run: python -m build + + - name: List built files + run: | + echo "Files in dist/:" + ls -lh dist/ + + - name: Upload wheel artifact + uses: actions/upload-artifact@v4 + with: + name: querit-${{ steps.get_version.outputs.version }}-wheel + path: dist/*.whl + if-no-files-found: error + retention-days: 30 + + - name: Upload to GitHub Release + if: startsWith(github.ref, 'refs/tags/v') + uses: softprops/action-gh-release@v2 + with: + files: | + dist/*.whl + dist/*.tar.gz + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/v') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip-existing: false