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

Add workflow to publish on PyPI #70

Merged
merged 5 commits into from
Nov 1, 2024
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
22 changes: 22 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Set up
description: Set up Python environment and install dependencies
inputs:
python-version:
description: The Python version to use
required: true

runs:
using: composite
steps:
- name: Install Poetry
shell: bash
run: pipx install poetry

- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: poetry

- name: Install dependencies
shell: bash
run: poetry install
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ jobs:
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
cache: poetry
- name: Install dependencies
run: poetry install
- name: Run tests
run: poetry run pytest
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release

on:
release:
types: [published]

jobs:
test:
uses: ./.github/workflows/ci.yml

# If tests are successful, we build the wheel and push it to the release
build-wheel:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
python-version: '3.13'

- name: Check package version matches tag
run: |
pkgver=$(python -c "import autocorpus; print(autocorpus.__version__, end='')")

# NB: tag name must be prefixed by "v" (the default for GitHub Releases)
test v$pkgver = ${{ github.ref_name }}

- name: Build package
run: poetry build

# Upload files as test artifact (to be retrieved later)
- uses: actions/upload-artifact@v4
with:
path: dist/*

# Publish files as release artifacts
- uses: softprops/action-gh-release@v2
with:
files: dist/*

# If all goes well, publish to PyPI
publish-pypi:
needs: build-wheel
name: Publish to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- name: Download wheel and sdist artifacts
uses: actions/download-artifact@v4
with:
name: artifact
path: dist

- name: Display structure of downloaded files
run: ls -R dist

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ keywords = [
"natural language processing",
"text mining",
"biomedical literature",
"semantics, health data",
"semantics",
"health data"
]
classifiers = ["Intended Audience :: Science/Research"]

Expand Down