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

Add workflow actions for automated release to PyPI #1373

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
43 changes: 43 additions & 0 deletions .github/workflows/publish-to-pypi-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release to Test PyPI

on:
push:
tags:
- '*'
jobs:
release:
environment: TEST_PYPI_API_TOKEN
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Tools
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build
pip install .
- name: Test version/tag correspondence
id: version-check
run: |
neo_version=$(python -c "import neo; print(neo.__version__)")
if [[ ${{ github.event.release.tag_name }} == $neo_version ]]; then
echo "VERSION_TAG_MATCH=true" >> $GITHUB_OUTPUT
echo "Version matches tag, proceeding with release to Test PyPI"
else
echo "VERSION_TAG_MATCH=false" >> $GITHUB_OUTPUT
echo "Version does not match tag! Fix this before proceeding."
exit 1
fi
- name: Package and Upload
env:
STACKMANAGER_VERSION: ${{ github.event.release.tag_name }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
if: ${{ steps.version-check.outputs.VERSION_TAG_MATCH == 'true' }}
run: |
python -m build --sdist --wheel
twine upload --repository testpypi dist/*
28 changes: 28 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release to PyPI

on:
workflow_dispatch:

jobs:
release:
environment: PYPI_API_TOKEN
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Tools
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build
- name: Package and Upload
env:
STACKMANAGER_VERSION: ${{ github.event.release.tag_name }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m build --sdist --wheel
twine upload --repository testpypi dist/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't mention "testpypi"

alejoe91 marked this conversation as resolved.
Show resolved Hide resolved