Skip to content

Workflow file for this run

name: Publish cr.cube on TestPYPI, PYPI and Nexus
on:
release:
types: [created]
jobs:
pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Autobump version
run: |
# from refs/tags/v0.1.2 get 0.1.2
VERSION=$(echo $GITHUB_REF | sed 's#.*/v##')
PLACEHOLDER=$(grep '__version__ = ' src/cr/cube/__init__.py)
VERSION_FILE='src/cr/cube/__init__.py'
# ensure the placeholder is there. If grep doesn't find the placeholder
# it exits with exit code 1 and github actions aborts the build.
grep "$PLACEHOLDER" "$VERSION_FILE"
sed -i "s/$PLACEHOLDER/__version__ = \"${VERSION}\"/g" "$VERSION_FILE"
shell: bash
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build cr.cube
run: python setup.py sdist bdist_wheel
- name: Publish on test-PYPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TESTPYPI_APIKEY }}
run: twine upload --repository testpypi dist/*
- name: Publish on PYPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_APIKEY }}
run: twine upload dist/*
nexus:
runs-on: ubuntu-latest
needs: pypi
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build wheels and upload to Nexus
env:
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
run: |
pip wheel . numpy==1.16.2
PYPI_NEXUS=https://ui.nexus.crint.net/repository/unstable/
for whl in *.whl; do
if [ -f $whl ]; then
echo "Twine uploading: $whl"
twine upload -r $PYPI_NEXUS --repository-url $PYPI_NEXUS -u "$NEXUS_USER" -p "$NEXUS_PASSWORD" $whl
fi
done