Skip to content

Commit

Permalink
Merge pull request #8 from unexcellent/publish_on_version_change
Browse files Browse the repository at this point in the history
Only run publish action on version change
  • Loading branch information
unexcellent authored Nov 19, 2024
2 parents 1d9609f + 491b076 commit 7efe543
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,20 @@ jobs:
- name: Build the package
run: poetry build

- name: Get current version from pyproject.toml
id: get_version
run: echo "VERSION=$(poetry version -s)" >> $GITHUB_ENV

- name: Check last version on PyPI
id: check_pypi_version
- name: Check if version exists on PyPI
id: check-version
run: |
LAST_VERSION=$(curl -s https://pypi.org/pypi/<your-package-name>/json | jq -r .info.version)
echo "LAST_VERSION=$LAST_VERSION" >> $GITHUB_ENV
PACKAGE_NAME=$(poetry version | awk '{print $1}')
PACKAGE_VERSION=$(poetry version | awk '{print $2}')
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" https://pypi.org/pypi/$PACKAGE_NAME/$PACKAGE_VERSION/json)
if [ "$RESPONSE" == "200" ]; then
echo "Version $PACKAGE_VERSION already exists on PyPI. Skipping publish step."
echo "exists=true" >> $GITHUB_ENV
else
echo "exists=false" >> $GITHUB_ENV
fi
shell: bash

- name: Publish to PyPI (release only)
if: env.VERSION != env.LAST_VERSION
if: env.exists == 'false'
run: poetry publish --no-interaction --username __token__ --password ${{ secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "quantio"
version = "0.9.0"
version = "0.9.1"
description = "Type hinting and safe unit conversion for physical quantities in Python."
authors = []
readme = "README.md"
Expand Down

0 comments on commit 7efe543

Please sign in to comment.