Skip to content
Closed
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
72 changes: 72 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Release

on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:

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

build_package:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.13'

- name: Install uv
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1

- name: Check tag matches pyproject.toml version
run: |
TAG_VERSION="${GITHUB_REF##*/}"
TAG_VERSION_NO_PREFIX="${TAG_VERSION#v}"
echo "Tag version: $TAG_VERSION (stripped: $TAG_VERSION_NO_PREFIX)"
PYPROJECT_VERSION=$(grep '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "pyproject.toml version: $PYPROJECT_VERSION"
if [ "$TAG_VERSION_NO_PREFIX" != "$PYPROJECT_VERSION" ]; then
echo "Tag version ($TAG_VERSION_NO_PREFIX) does not match pyproject.toml version ($PYPROJECT_VERSION)" >&2
exit 1
fi
shell: bash

- name: Build package
run: uv build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Upload Python artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: python-dist
path: dist/

create_release:
runs-on: ubuntu-latest
needs: build_package
steps:
- name: Download Python artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: python-dist
path: dist/

- name: Create Release
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # v2.3.3
with:
files: |
dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 5 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
run: uv sync --extra dev

- name: Test with pytest
run: |
pytest
run: uv run pytest

- name: Check coverage
run: |
pytest --cov=snakesay --cov-fail-under=65
run: uv run pytest --cov=snakesay --cov-fail-under=65
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ classifiers = [
[project.scripts]
snakesay = "snakesay.snakesay:main"

[build-system]
requires = ["setuptools>=77.0.3", "wheel"]
build-backend = "setuptools.build_meta"
[project.optional-dependencies]
dev = [
"pytest",
"pytest-cov"
]

[build-system]
requires = ["uv_build>=0.8.14,<0.9.0"]
build-backend = "uv_build"
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pytest]
pythonpath = .
pythonpath = ./src
2 changes: 0 additions & 2 deletions requirements-dev.txt

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions snakesay/snakesay.py → src/snakesay/snakesay.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def rewrap(speech: str) -> Tuple[List[str], int]:
return [line.ljust(width) for line in lines], width


def main():
def main(): # pragma: no cover
print(snakesay(*sys.argv[1:]))


if __name__ == '__main__':
if __name__ == '__main__': # pragma: no cover
main()
248 changes: 248 additions & 0 deletions uv.lock

Large diffs are not rendered by default.