Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and publish release whls #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/build-and-release-whls.yaml
Original file line number Diff line number Diff line change
@@ -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 files to release
uses: softprops/action-gh-release@v2
with:
files: dist/*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Publish to PyPI
# if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't need this if condition since the workflow trigger already takes care of it

# uses: pypa/[email protected]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can upgrade this to the latest version of the action

# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
# packages_dir: dist