Skip to content

Commit

Permalink
Merge pull request #70 from omicsNLP/pypi-release-workflow
Browse files Browse the repository at this point in the history
Add workflow to publish on PyPI
  • Loading branch information
alexdewar authored Nov 1, 2024
2 parents 0ba1bbd + 54d730a commit 0879668
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 7 deletions.
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

0 comments on commit 0879668

Please sign in to comment.