Skip to content

Weekly Release

Weekly Release #3

name: Weekly Release
on:
schedule:
# Every Friday at 2 PM UTC
- cron: "0 14 * * 5"
workflow_dispatch:
inputs:
release_type:
description: "Release type"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bump2version build twine
pip install -e .[all]
- name: Run full test suite
run: |
python -m pytest tests/ --cov=datafog
python -m pytest tests/benchmark_text_service.py
- name: Generate changelog
run: |
python scripts/generate_changelog.py
- name: Determine version bump
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "bump_type=${{ github.event.inputs.release_type }}" >> $GITHUB_OUTPUT
else
# Auto-determine based on commit messages
if git log --oneline $(git describe --tags --abbrev=0)..HEAD | grep -q "BREAKING"; then
echo "bump_type=major" >> $GITHUB_OUTPUT
elif git log --oneline $(git describe --tags --abbrev=0)..HEAD | grep -q "feat:"; then
echo "bump_type=minor" >> $GITHUB_OUTPUT
else
echo "bump_type=patch" >> $GITHUB_OUTPUT
fi
fi
- name: Bump version
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
bump2version ${{ steps.version.outputs.bump_type }}
echo "NEW_VERSION=$(python -c 'from datafog import __version__; print(__version__)')" >> $GITHUB_ENV
- name: Build package
run: |
python -m build
- name: Check wheel size
run: |
WHEEL_SIZE=$(du -m dist/*.whl | cut -f1)
if [ "$WHEEL_SIZE" -ge 5 ]; then
echo "❌ Wheel size too large: ${WHEEL_SIZE}MB"
exit 1
fi
echo "✅ Wheel size OK: ${WHEEL_SIZE}MB"
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create v${{ env.NEW_VERSION }} \
--title "DataFog v${{ env.NEW_VERSION }}" \
--notes-file CHANGELOG_LATEST.md \
dist/*
- name: Push changes
run: |
git push origin dev --tags
- name: Notify Discord
if: env.DISCORD_WEBHOOK
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
curl -X POST "$DISCORD_WEBHOOK" \
-H "Content-Type: application/json" \
-d "{\"content\": \"🚀 DataFog v${{ env.NEW_VERSION }} is live! Install with: \`pip install datafog==${{ env.NEW_VERSION }}\`\"}"