Skip to content

Nightly Prerelease Publishing #246

Nightly Prerelease Publishing

Nightly Prerelease Publishing #246

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Nightly Prerelease Publishing
on:
workflow_dispatch: # Allow manual triggers
schedule:
# Runs every day at 3:07am UTC.
- cron: '7 3 * * *'
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: master
# This second step is unnecessary but highly recommended because
# It will cache database and saves time re-downloading it if database isn't stale.
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Check dev version
run: | # Get current canonical version, append current date as an identifier
currentVer=$(python -c "from GANDLF import version; print(version)")
if [[ $currentVer == *"dev"* ]]; then
echo "publish_nightly=true" >> $GITHUB_ENV
else
echo "publish_nightly=false" >> $GITHUB_ENV
fi
- name: Install dependencies
if: env.publish_nightly
run: |
python -m pip install --upgrade pip==24.0
pip install scikit-build
pip install -e .
pip install build
- name: Annotate version
if: env.publish_nightly
run: | # Get current canonical version, append current date as an identifier
currentVer=$(python -c "from GANDLF import version; print(version)")
datestampnow=$(date +'%Y%m%d')
echo __version__ = \"$currentVer$datestampnow\" > ./GANDLF/version.py
- name: Build package
if: env.publish_nightly
run: python -m build
- name: Publish package
if: env.publish_nightly
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}