Skip to content

Commit

Permalink
Merge pull request #18 from PCain02/main
Browse files Browse the repository at this point in the history
feat: Automatic PyPI Publishing using Tags
  • Loading branch information
AlishChhetri authored Oct 17, 2024
2 parents df9df18 + 6db3d2e commit eb7e9be
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 3 deletions.
22 changes: 19 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -15,8 +23,16 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.

**Operating System**
What operating system were you using when you encountered the bug?
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Publishing workflow

name: Publish

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

# trigger the publishing of the
# execexam 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 execexam version $version is available on PyPI..."
response=$(curl -s "https://pypi.org/pypi/execexam/$version/json")
if echo "$response" | grep -q "$version"; then
echo "Package execexam version $version is successfully published on PyPI."
else
echo "Package execexam version $version was not found on PyPI."
exit 1
fi
48 changes: 48 additions & 0 deletions .github/workflows/test-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test Publish

on:
push:
tags:
- 't*' # Triggers on tags starting with 't'

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 execexam version $version is available on TestPyPI..."
response=$(curl -s "https://test.pypi.org/pypi/execexam/$version/json")
if echo "$response" | grep -q "$version"; then
echo "Package execexam version $version is successfully published on TestPyPI."
else
echo "Package execexam version $version was not found on TestPyPI."
exit 1
fi
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit eb7e9be

Please sign in to comment.