Release to Test PyPI #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Get the tag version | |
id: get-version | |
run: | | |
echo ${GITHUB_REF#refs/tags/} | |
echo "TAG::${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
- name: Test version/tag correspondence | |
id: version-check | |
run: | | |
neo_version=$(python -c "import neo; print(neo.__version__)") | |
tag_version=${{ steps.get-version.outputs.TAG }} | |
echo $neo_version | |
echo $tag_version | |
if [[ $tag_version == $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/* |