Skip to content
Merged
Show file tree
Hide file tree
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
74 changes: 74 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Publish Python Package to PyPI
on:
workflow_dispatch:
# push:
# branches:
# - main

jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout repo
uses: actions/checkout@v7

- name: Setup uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d

- name: Get version from pyproject.toml
id: get-version
run: |
VERSION=$(python setup.py --version)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Found version: $VERSION"

- name: Build package
run: uv build

- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: python-package-distributions
path: dist/

create-release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v7

- name: Download build artifacts
uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist/

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ needs.build.outputs.version }}" \
--title "Release v${{ needs.build.outputs.version }}" \
--draft=false \
--prerelease=false

publish:
runs-on: ubuntu-latest
needs: [build, create-release]
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
18 changes: 18 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Run Tests

on:
pull_request:
workflow_dispatch:

jobs:
check_test_all:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v7

- name: Setup uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d

- name: Run tests
run: uv run python -m unittest discover --start-directory tests
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ solemn
Run via: `$ python setup.py test` (or `$ python tests/tests.py`)

## Build
A GitHub Action exists for this at: [.github/workflows/publish.yaml](.github/workflows/publish.yaml)

Alternatively build and publish manually with:

- `$ python setup.py sdist bdist_wheel`
- `$ twine upload dist/* -r testpypi --skip-existing` assuming twine is installed and *~/.pypirc* exists with something like:
```
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_suite():

setup(
name='Vose-Alias-Method',
version='1.2.1',
version='1.2.2',
description=('Python implementation of Vose\'s alias method, an efficient algorithm for sampling from a discrete probability distribution.'),
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
Loading