Skip to content

Commit c7480d9

Browse files
authored
Merge pull request #1373 from alejoe91/release-actions
Add workflow actions for automated release to PyPI
2 parents b61bdab + aee9134 commit c7480d9

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release to Test PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
jobs:
8+
release:
9+
environment: TEST_PYPI_API_TOKEN
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python 3.10
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.10"
18+
- name: Install Tools
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install setuptools wheel twine build
22+
pip install .
23+
- name: Test version/tag correspondence
24+
id: version-check
25+
run: |
26+
neo_version=$(python -c "import neo; print(neo.__version__)")
27+
if [[ ${{ github.event.release.tag_name }} == $neo_version ]]; then
28+
echo "VERSION_TAG_MATCH=true" >> $GITHUB_OUTPUT
29+
echo "Version matches tag, proceeding with release to Test PyPI"
30+
else
31+
echo "VERSION_TAG_MATCH=false" >> $GITHUB_OUTPUT
32+
echo "Version does not match tag! Fix this before proceeding."
33+
exit 1
34+
fi
35+
- name: Package and Upload
36+
env:
37+
STACKMANAGER_VERSION: ${{ github.event.release.tag_name }}
38+
TWINE_USERNAME: __token__
39+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
40+
if: ${{ steps.version-check.outputs.VERSION_TAG_MATCH == 'true' }}
41+
run: |
42+
python -m build --sdist --wheel
43+
twine upload --repository testpypi dist/*
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release to PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
environment: PYPI_API_TOKEN
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python 3.10
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: "3.10"
17+
- name: Install Tools
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install setuptools wheel twine build
21+
- name: Package and Upload
22+
env:
23+
STACKMANAGER_VERSION: ${{ github.event.release.tag_name }}
24+
TWINE_USERNAME: __token__
25+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
26+
run: |
27+
python -m build --sdist --wheel
28+
twine upload dist/*

0 commit comments

Comments
 (0)