Nightly Release (Alpha) #30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Nightly Release (Alpha) | |
on: | |
schedule: | |
# Monday-Wednesday: Alpha builds at 2 AM UTC | |
- cron: '0 2 * * 1-3' | |
workflow_dispatch: | |
inputs: | |
dry_run: | |
description: 'Dry run (skip PyPI publish)' | |
required: false | |
default: 'false' | |
type: boolean | |
force_build: | |
description: 'Force build even if no changes' | |
required: false | |
default: 'false' | |
type: boolean | |
jobs: | |
check-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
has_changes: ${{ steps.changes.outputs.has_changes }} | |
commit_count: ${{ steps.changes.outputs.commit_count }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: dev | |
- name: Check for changes since last alpha release | |
id: changes | |
run: | | |
LAST_ALPHA=$(git tag -l "*alpha*" --sort=-version:refname | head -n1) | |
if [ -z "$LAST_ALPHA" ]; then | |
echo "No previous alpha release found, checking last 24 hours" | |
SINCE="24 hours ago" | |
COMMIT_COUNT=$(git rev-list --count --since="$SINCE" dev) | |
else | |
echo "Last alpha release: $LAST_ALPHA" | |
COMMIT_COUNT=$(git rev-list --count ${LAST_ALPHA}..dev) | |
fi | |
echo "Commits since last alpha: $COMMIT_COUNT" | |
echo "commit_count=$COMMIT_COUNT" >> $GITHUB_OUTPUT | |
if [ "$COMMIT_COUNT" -gt 0 ] || [ "${{ github.event.inputs.force_build }}" = "true" ]; then | |
echo "has_changes=true" >> $GITHUB_OUTPUT | |
echo "✅ Changes detected, proceeding with nightly build" | |
else | |
echo "has_changes=false" >> $GITHUB_OUTPUT | |
echo "ℹ️ No changes since last alpha, skipping build" | |
fi | |
nightly-release: | |
needs: check-changes | |
if: needs.check-changes.outputs.has_changes == 'true' | |
runs-on: ubuntu-latest | |
outputs: | |
alpha_version: ${{ steps.version.outputs.alpha_version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: dev | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install bump2version build twine | |
pip install -e ".[all,dev]" | |
- name: Configure git | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
- name: Generate alpha version | |
id: version | |
run: | | |
set -e | |
CURRENT_VERSION=$(python -c "from datafog.__about__ import __version__; print(__version__)") | |
echo "Current version: $CURRENT_VERSION" | |
DATE_STAMP=$(date +"%Y%m%d") | |
TIME_STAMP=$(date +"%H%M") | |
COMMIT_SHORT=$(git rev-parse --short HEAD) | |
if [[ $CURRENT_VERSION == *"alpha"* ]]; then | |
BASE_VERSION=$(echo $CURRENT_VERSION | cut -d'a' -f1) | |
else | |
BASE_VERSION=$(python3 -c "import sys; version='$CURRENT_VERSION'; parts=version.split('.'); parts[1]=str(int(parts[1])+1); parts[2]='0'; print('.'.join(parts))") | |
fi | |
ALPHA_VERSION="${BASE_VERSION}a${DATE_STAMP}.${TIME_STAMP}.${COMMIT_SHORT}" | |
echo "Alpha version: $ALPHA_VERSION" | |
echo "alpha_version=$ALPHA_VERSION" >> $GITHUB_OUTPUT | |
sed -i "s/__version__ = \".*\"/__version__ = \"$ALPHA_VERSION\"/" datafog/__about__.py | |
sed -i "s/version=\".*\"/version=\"$ALPHA_VERSION\"/" setup.py | |
- name: Generate changelog for alpha | |
run: | | |
python scripts/generate_changelog.py --alpha --output ALPHA_CHANGELOG.md | |
- name: Build package | |
run: | | |
python -m build | |
python scripts/check_wheel_size.py | |
- name: Create alpha release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
ALPHA_VERSION="${{ steps.version.outputs.alpha_version }}" | |
git add datafog/__about__.py setup.py | |
git commit -m "chore: bump version to $ALPHA_VERSION for nightly release" | |
git tag -a "v$ALPHA_VERSION" -m "Alpha release $ALPHA_VERSION" | |
git push origin "v$ALPHA_VERSION" | |
gh release create "v$ALPHA_VERSION" \ | |
--title "🌙 Nightly Alpha $ALPHA_VERSION" \ | |
--notes-file ALPHA_CHANGELOG.md \ | |
--prerelease \ | |
--target dev \ | |
dist/* | |
- name: Publish to PyPI (Alpha) | |
if: github.event.inputs.dry_run != 'true' | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
echo "🚀 Publishing alpha release to PyPI..." | |
python -m twine upload dist/* --verbose | |
- name: Dry run summary | |
if: github.event.inputs.dry_run == 'true' | |
run: | | |
echo "🏃♂️ DRY RUN COMPLETED" | |
echo "Would have published: ${{ steps.version.outputs.alpha_version }}" | |
echo "Package contents:" | |
ls -la dist/ | |
- name: Cleanup old alpha releases | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "🧹 Cleaning up old alpha releases (keep last 7)..." | |
ALPHA_RELEASES=$(gh release list --limit 50 | grep alpha | tail -n +8 | cut -f3) | |
for release in $ALPHA_RELEASES; do | |
echo "Deleting old alpha release: $release" | |
gh release delete "$release" --yes || true | |
git push --delete origin "$release" || true | |
done | |
notify-alpha: | |
needs: [check-changes, nightly-release] | |
if: needs.check-changes.outputs.has_changes == 'true' && success() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Alpha release notification | |
run: | | |
echo "🌙 Nightly alpha release completed!" | |
echo "📦 New alpha version available for testing" | |
echo "💡 Install with: pip install datafog==${{ needs.nightly-release.outputs.alpha_version }}" | |
echo "📊 Commits included: ${{ needs.check-changes.outputs.commit_count }}" |