Skip to content

Commit

Permalink
[INFRA] Add automatic release to Pypi (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen authored Nov 15, 2024
1 parent 3c6197d commit 25cdacd
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: publish

on:
release:
types: [ published ]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Build distribution
run: pipx run build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
20 changes: 19 additions & 1 deletion src/clinicaio/hello.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
__all__ = ["greet"]
__all__ = [
"greet",
"say_goodbye",
]


def greet(name: str):
Expand All @@ -14,3 +17,18 @@ def greet(name: str):

def _build_greeting_message(name: str) -> str:
return f"Hello {name} !"


def say_goodbye(name: str):
"""Say goodbye to the person with the provided name.
Parameters
----------
name : str
The name of the person to say goodbye to.
"""
print(_build_good_bye_message(name))


def _build_good_bye_message(name: str) -> str:
return f"Goodbye {name} !"
18 changes: 18 additions & 0 deletions tests/unittests/test_hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,21 @@ def test_greet(capsys):

captured = capsys.readouterr()
assert captured.out == "Hello John Doe !\n"


def test_build_good_bye_message():
from clinicaio.hello import _build_good_bye_message

assert (
_build_good_bye_message("ClinicaIO developers")
== "Goodbye ClinicaIO developers !"
)


def test_say_goodbye(capsys):
from clinicaio.hello import say_goodbye

say_goodbye("John Doe")

captured = capsys.readouterr()
assert captured.out == "Goodbye John Doe !\n"

0 comments on commit 25cdacd

Please sign in to comment.