Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Automatic PyPI Publishing using Tags and add Auto Releasing #148

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
poetry version ${GITHUB_REF##*/v}
poetry publish --build
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/tag_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Publishing workflow

name: Tag Publish

# Use more columns for terminal output
env:
COLUMNS: 120
PYTHONIOENCODING: utf8

# trigger the publishing of the
# gatorgrade package to PyPI
# with any tag starting with 'v'
on:
push:
tags:
- 'v*'

# Create one single job
# that publishes the package
# to PyPI using Poetry

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
poetry install
- name: Configure Poetry for PyPI
run: |
poetry config repositories.pypi https://upload.pypi.org/legacy/
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
- name: Publish package to PyPI
run: |
poetry publish --repository pypi --build
- name: Check for Successful Publication
run: |
version=$(poetry version --short)
echo "Checking if package gatorgrade version $version is available on PyPI..."
response=$(curl -s "https://pypi.org/pypi/gatorgrade/$version/json")
if echo "$response" | grep -q "$version"; then
echo "Package gatorgrade version $version is successfully published on PyPI."
else
echo "Package gatorgrade version $version was not found on PyPI."
exit 1
fi

60 changes: 60 additions & 0 deletions .github/workflows/test_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Test Publishing workflow
name: Test Publish

# Use more columns for terminal output
env:
COLUMNS: 120
PYTHONIOENCODING: utf8

# trigger the test publishing of the
# gatorgrade package to PyPI
# with any tag starting with 't'
on:
push:
tags:
- 't*'

# Create one single job
# that test publishes the package
# to PyPI using Poetry
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '^3.11' # Use the Python version compatible with your project

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry install

- name: Configure Poetry for TestPyPI
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }}

- name: Publish package to TestPyPI
run: |
poetry publish --repository testpypi --build

- name: Check for Successful Publication
run: |
version=$(poetry version --short)
echo "Checking if package gatorgrade version $version is available on TestPyPI..."
response=$(curl -s "https://test.pypi.org/pypi/gatorgrade/$version/json")
if echo "$response" | grep -q "$version"; then
echo "Package gatorgrade version $version is successfully published on TestPyPI."
else
echo "Package gatorgrade version $version was not found on TestPyPI."
exit 1
fi
Loading