Skip to content

Initialize version to None. #8

Initialize version to None.

Initialize version to None. #8

Workflow file for this run

name: Publish RC Python distributions to TestPyPI
on:
push:
branches:
- 'release/**'
- 'hotfix/**'
- 'support/**'
env:
PACKAGE_NAME: exchange_calendars_extensions_api
MODULE_NAME: exchange_calendars_extensions.api
jobs:
build-and-publish:
name: Build and publish release candidate Python distribution to TestPyPI.
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Install poetry.
run: pipx install poetry
- name: Set up Python 3.10.
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: 'poetry'
- name: Determine RC version number.
run: |
export RC_VERSION=$(echo ${{ github.ref_name }} | sed -e 's/^\(release\|hotfix\|support\)\///')rc${{ github.run_number }}
echo "RC version is $RC_VERSION."
echo "RC_VERSION=$RC_VERSION" >> $GITHUB_ENV
- name: Set poetry package version from tag.
run: poetry version ${{ env.RC_VERSION }}
- name: Determine path to version.py from module name.
run: |
export VERSION_PATH=$(echo ${{ env.MODULE_NAME }} | sed 's/\./\//g')/version.py
echo "VERSION_PATH=VERSION_PATH" >> $GITHUB_ENV
- name: Generate version.py
run: |
echo "version = '${{ env.RC_VERSION }}'" > ${{ env.VERSION_PATH }}
- name: Generate requirements.txt.
run: poetry export -f requirements.txt --without-hashes > requirements.txt
- name: Build package with poetry.
run: poetry build
- name: Publish package to Test PyPI.
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Install from testpypi and import.
run: |
i=0
while (($i<120)) && [[ ! $(curl --max-time 120 -s https://test.pypi.org/pypi/${{ env.PACKAGE_NAME }}/json | jq -r '.releases | keys[]') =~ (^|[[:space:]])${{ env.RC_VERSION }}($|[[:space:]]) ]];\
do echo waiting for package to appear in test index, sleeping 5s; sleep 5s; let i++; done
pip install --no-cache-dir --index-url https://test.pypi.org/simple ${{ env.PACKAGE_NAME }}==${{ env.RC_VERSION }} --no-deps
pip install -r requirements.txt
python -c 'import ${{ env.MODULE_NAME }};print(${{ env.MODULE_NAME }}.__version__)'