Skip to content

pypi-publish-nightly #166

pypi-publish-nightly

pypi-publish-nightly #166

name: pypi-publish-nightly
on:
schedule:
- cron: '35 10 * * *' # 10:35am UTC, 2:35am PST, 5:35am EST
workflow_dispatch:
jobs:
# nightly release check from https://stackoverflow.com/a/67527144
check-date:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/checkout@v3
- name: print latest_commit
run: echo ${{ github.sha }}
- id: should_run
continue-on-error: true
name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false"
nightly-build-pypi:
runs-on: ubuntu-latest
needs: check-date
if: ${{ needs.check_date.outputs.should_run != 'false' }}
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: "Setup Python, Poetry and Dependencies"
uses: packetcoders/action-setup-cache-python-poetry@main
with:
python-version: "3.10"
poetry-version: "1.7.1"
- name: Set release version
run: |
# Extract the version number from pyproject.toml using awk
CURRENT_VERSION=$(awk -F '"' '/version =/ { print $2 }' pyproject.toml | head -n 1)
# Export the CURRENT_VERSION with the .dev and current date suffix
NIGHTLY_VERSION="${CURRENT_VERSION}.dev$(date +%Y%m%d%H%M%S)"
sed -i "s/{{KONDUKTOR_COMMIT_SHA}}/${{ github.sha }}/g" konduktor/__init__.py
sed -i "s/__version__ = '.*'/__version__ = '1.0.0.dev${NIGHTLY_VERSION}'/g" konduktor/__init__.py
sed -i "0,/version = \"${CURRENT_VERSION}\"/s//version = \"${NIGHTLY_VERSION}\"/" pyproject.toml
sed -i 's/name = "konduktor"/name = "konduktor-nightly"/g' pyproject.toml
cat pyproject.toml
cat konduktor/__init__.py
- name: Configure poetry
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: poetry config pypi-token.pypi "$PYPI_TOKEN"
- name: Build the Python package
run: poetry build
- name: Publish the package to PyPI
run: poetry publish