Skip to content

Merge pull request #170 from AllenNeuralDynamics/seanf-fusion-multiscale #32

Merge pull request #170 from AllenNeuralDynamics/seanf-fusion-multiscale

Merge pull request #170 from AllenNeuralDynamics/seanf-fusion-multiscale #32

Workflow file for this run

name: Tag and Publish to PyPI
on:
push:
branches:
- main
permissions:
contents: write
jobs:
tag-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Read version from setup.py
id: get_version
run: |
VERSION=$(python - << 'EOF'
import re, pathlib
text = pathlib.Path("setup.py").read_text()
m = re.search(r"version\s*=\s*['\"](\d+\.\d+\.\d+)['\"]", text)
if not m:
raise SystemExit("Could not find version=... in setup.py")
print(m.group(1))
EOF
)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Detected version: $VERSION"
- name: Create tag if needed
id: tag_step
run: |
VERSION="${{ steps.get_version.outputs.version }}"
TAG="v$VERSION"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, not creating a new one."
echo "created=false" >> "$GITHUB_OUTPUT"
else
echo "Creating tag $TAG"
git tag "$TAG"
git push origin "$TAG"
echo "created=true" >> "$GITHUB_OUTPUT"
fi
- name: Set up Python 3.11
if: steps.tag_step.outputs.created == 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build package
if: steps.tag_step.outputs.created == 'true'
run: |
cd ./Rhapso
pip install setuptools wheel
cd ..
python setup.py sdist bdist_wheel
- name: Publish on PyPI
if: steps.tag_step.outputs.created == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
password: ${{ secrets.AIND_PYPI_TOKEN }}