Skip to content

Set exact version 4.1.2 (#34) #40

Set exact version 4.1.2 (#34)

Set exact version 4.1.2 (#34) #40

name: Publish Python 🐍 distributions πŸ“¦ to PyPI and TestPyPI
on:
push:
tags:
- v*
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions πŸ“¦ to PyPI and TestPyPI
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: |
VERSION_TAG=`echo ${GITHUB_REF_NAME} \
| sed -r 's#v([0-9]+\.[0-9]\.[0-9])#\1#g' \
| sed 's#[^a-zA-Z0-9_\.\-]#_#g'`
echo "tag version = $VERSION_TAG"
VERSION_FILE=$(echo 'import version; print(version.VERSION)' | python -)
echo "file version = $VERSION_FILE"
if [ "$VERSION_TAG" != "$VERSION_FILE" ]; then
echo "Version in file 'version.py' must be the same as the pushed tag"
exit 1
fi
python -m build --sdist --wheel --outdir dist/
# make this available for test
# - name: Publish distribution πŸ“¦ to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN_V2 }}
# repository_url: https://test.pypi.org/legacy/
- name: Publish distribution πŸ“¦ to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
env:
PYTHON_MOIRA_CLIENT_VERSION: ${{ github.ref_name }}
with:
password: ${{ secrets.PYPI_API_TOKEN_V2 }}