Skip to content

Nightly Build

Nightly Build #142

Workflow file for this run

name: Nightly Build
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * *' # Runs daily at 22:00 EST
jobs:
main:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history and tags
- name: Get latest release tag
id: get-latest-tag
run: |
LATEST_TAG=$(git tag --sort=-version:refname | head -n 1)
echo "latest_tag=$LATEST_TAG" >> $GITHUB_ENV
echo "Latest tag found: $LATEST_TAG"
- name: Scan for Changes
id: check-diff
run: |
if [ -z "$LATEST_TAG" ]; then
echo "No previous tag found."
echo "has_changed=true" >> $GITHUB_ENV
else
CHANGED_FILES=$(git diff --name-only $LATEST_TAG HEAD)
if [ -z "$CHANGED_FILES" ]; then
echo "has_changed=false" >> $GITHUB_ENV
else
echo "has_changed=true" >> $GITHUB_ENV
fi
fi
- name: Exit if unchanged
run: |
if [ "$has_changed" = "true" ]; then
exit
fi
- name: Checkout code
uses: actions/checkout@v4
- name: Get Current Date
id: date
run: |
export TZ='America/New_York' # Set timezone to EST
echo "ISO=$(date +'%Y.%m.%d')" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.*'
- name: Install Python Packages
run: |
pip install toml poetry
- name: Initialize Poetry
run: |
poetry lock
poetry install --no-root --no-interaction
- name: Update version in pyproject.toml
run: |
python -c "
from toml import load, dump
with open('pyproject.toml', 'r') as f:
data = load(f)
data['project']['version'] = 'v${{ env.ISO }}'
with open('pyproject.toml', 'w') as f:
dump(data, f)
"
- name: Save Changes
uses: stefanzweifel/git-auto-commit-action@v5
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.ISO }}
name: ${{ env.ISO }}
body: Automatic Nightly Build
prerelease: false
draft: false
- name: Build package
run: poetry build
- name: Publish package to PyPI
run: poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}