From 866d3dde2a606a10a89a5d7ab0555364ed972aad Mon Sep 17 00:00:00 2001 From: Hammad Mohiuddin Date: Wed, 3 Apr 2024 11:33:01 -0700 Subject: [PATCH] Added GitHub Action workflow to build and release the Python wheels --- .github/workflows/build-and-release-whls.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/build-and-release-whls.yaml diff --git a/.github/workflows/build-and-release-whls.yaml b/.github/workflows/build-and-release-whls.yaml new file mode 100644 index 0000000..4201029 --- /dev/null +++ b/.github/workflows/build-and-release-whls.yaml @@ -0,0 +1,57 @@ +name: Build and Release Python Wheels + +on: + release: + types: [published] + tags: + - 'v*' # Trigger for tags like v1.0, v2.0, ... + +jobs: + build-and-release: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build twine + + - name: Build wheel + run: | + python -m build + + - name: Verify wheel files + run: | + twine check dist/* + for file in dist/*.whl; do + if ! [[ $file =~ .*-py3-none-any.whl$ ]]; then + echo "Error: Wheel $file is not marked as pure Python." + exit 1 + fi + done + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + path: dist/* + + - name: Upload wheel and sdist files to release + uses: softprops/action-gh-release@v2 + with: + files: dist/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # - name: Publish to PyPI + # if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v') + # uses: pypa/gh-action-pypi-publish@v1.4.2 + # with: + # password: ${{ secrets.PYPI_API_TOKEN }} + # packages_dir: dist