From f328bc0c0d151660dd776be2929842b582c73e0c Mon Sep 17 00:00:00 2001 From: Daethyra <109057945+Daethyra@users.noreply.github.com> Date: Tue, 15 Jul 2025 13:25:39 -0700 Subject: [PATCH] (workflow): automate pypi publishing - also updated some documentation --- .github/workflows/publish.yml | 57 +++++++++++++++++++++++++++++++++++ README.md | 4 +-- pyproject.toml | 2 +- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..95cb49c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,57 @@ +name: Publish Python Package to PyPI + +on: + release: + types: [published] + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install PDM + run: pip install pdm + + - name: Install dependencies + run: pdm install -G dev + + - name: Run formatting and linting + run: pdm run format lint + + - name: Run tests + run: pdm run test + + - name: Build package + run: pdm build + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: python-package + path: dist/ + + publish: + needs: build-and-test + runs-on: ubuntu-latest + environment: + name: pypi-publishing + url: https://pypi.org/p/transimage + + permissions: + id-token: write # Isolated to publish job only + + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: python-package + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/README.md b/README.md index 7d5eaf3..3e94f41 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ To set up the development environment: 1. Clone the repository 2. Install PDM if you haven't already: `pip install pdm` 3. Install dependencies: `pdm install` -4. Convert images: `python src/____main____.py ./input_image.jpg ./output_image.png png` +4. Convert images: `python src/__main__.py ./input_image.jpg ./output_image.png png` -### Using `____main____.py` directly as a CLI tool (Recommended) +### Using `__main__.py` directly as a CLI tool (Recommended) Once you've cloned the repository or downloaded the source code, you can use the `__main__.py` file directly by using the following: `python __main__.py ` diff --git a/pyproject.toml b/pyproject.toml index 8d0edda..d0d44bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "transimage" version = "1.0.0" -description = "Converts images from one format to another using Pillow. Supports JPG, PNG, BMP, and WebP." +description = "CLI tool for converting images from one format to another using Pillow. Supports JPG, PNG, BMP, and WebP." authors = [ {name = "Daethyra", email = "109057945+Daethyra@users.noreply.github.com"}, ]