|
| 1 | +name: Weekly Release |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Every Friday at 2 PM UTC |
| 6 | + - cron: "0 14 * * 5" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + release_type: |
| 10 | + description: "Release type" |
| 11 | + required: true |
| 12 | + default: "patch" |
| 13 | + type: choice |
| 14 | + options: |
| 15 | + - patch |
| 16 | + - minor |
| 17 | + - major |
| 18 | + |
| 19 | +jobs: |
| 20 | + release: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + if: github.ref == 'refs/heads/dev' |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + |
| 30 | + - name: Set up Python |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version: "3.10" |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip |
| 38 | + pip install bump2version build twine |
| 39 | + pip install -e .[all] |
| 40 | +
|
| 41 | + - name: Run full test suite |
| 42 | + run: | |
| 43 | + python -m pytest tests/ --cov=datafog |
| 44 | + python -m pytest tests/benchmark_text_service.py |
| 45 | +
|
| 46 | + - name: Generate changelog |
| 47 | + run: | |
| 48 | + python scripts/generate_changelog.py |
| 49 | +
|
| 50 | + - name: Determine version bump |
| 51 | + id: version |
| 52 | + run: | |
| 53 | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then |
| 54 | + echo "bump_type=${{ github.event.inputs.release_type }}" >> $GITHUB_OUTPUT |
| 55 | + else |
| 56 | + # Auto-determine based on commit messages |
| 57 | + if git log --oneline $(git describe --tags --abbrev=0)..HEAD | grep -q "BREAKING"; then |
| 58 | + echo "bump_type=major" >> $GITHUB_OUTPUT |
| 59 | + elif git log --oneline $(git describe --tags --abbrev=0)..HEAD | grep -q "feat:"; then |
| 60 | + echo "bump_type=minor" >> $GITHUB_OUTPUT |
| 61 | + else |
| 62 | + echo "bump_type=patch" >> $GITHUB_OUTPUT |
| 63 | + fi |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Bump version |
| 67 | + run: | |
| 68 | + git config --local user.email "action@github.com" |
| 69 | + git config --local user.name "GitHub Action" |
| 70 | + bump2version ${{ steps.version.outputs.bump_type }} |
| 71 | + echo "NEW_VERSION=$(python -c 'from datafog import __version__; print(__version__)')" >> $GITHUB_ENV |
| 72 | +
|
| 73 | + - name: Build package |
| 74 | + run: | |
| 75 | + python -m build |
| 76 | +
|
| 77 | + - name: Check wheel size |
| 78 | + run: | |
| 79 | + WHEEL_SIZE=$(du -m dist/*.whl | cut -f1) |
| 80 | + if [ "$WHEEL_SIZE" -ge 5 ]; then |
| 81 | + echo "❌ Wheel size too large: ${WHEEL_SIZE}MB" |
| 82 | + exit 1 |
| 83 | + fi |
| 84 | + echo "✅ Wheel size OK: ${WHEEL_SIZE}MB" |
| 85 | +
|
| 86 | + - name: Publish to PyPI |
| 87 | + env: |
| 88 | + TWINE_USERNAME: __token__ |
| 89 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 90 | + run: twine upload dist/* |
| 91 | + |
| 92 | + - name: Create GitHub Release |
| 93 | + env: |
| 94 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + run: | |
| 96 | + gh release create v${{ env.NEW_VERSION }} \ |
| 97 | + --title "DataFog v${{ env.NEW_VERSION }}" \ |
| 98 | + --notes-file CHANGELOG_LATEST.md \ |
| 99 | + dist/* |
| 100 | +
|
| 101 | + - name: Push changes |
| 102 | + run: | |
| 103 | + git push origin dev --tags |
| 104 | +
|
| 105 | + - name: Notify Discord |
| 106 | + if: env.DISCORD_WEBHOOK |
| 107 | + env: |
| 108 | + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} |
| 109 | + run: | |
| 110 | + curl -X POST "$DISCORD_WEBHOOK" \ |
| 111 | + -H "Content-Type: application/json" \ |
| 112 | + -d "{\"content\": \"🚀 DataFog v${{ env.NEW_VERSION }} is live! Install with: \`pip install datafog==${{ env.NEW_VERSION }}\`\"}" |
0 commit comments