Publish flash-attn-4 to PyPI #6
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: Publish flash-attn-4 to PyPI | |
| on: | |
| push: | |
| tags: | |
| - 'fa4-v*' | |
| schedule: | |
| - cron: '0 8 * * 3' # Wednesday 08:00 UTC | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| prepare-release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_tag: ${{ steps.resolve-tag.outputs.release_tag }} | |
| steps: | |
| - name: Require default branch for manual runs | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| if [ "${{ github.ref_name }}" != "${{ github.event.repository.default_branch }}" ]; then | |
| echo "::error::Run this workflow from ${{ github.event.repository.default_branch }} only" | |
| exit 1 | |
| fi | |
| - uses: actions/checkout@v4 | |
| if: github.event_name != 'push' | |
| with: | |
| ref: ${{ github.event.repository.default_branch }} | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| if: github.event_name != 'push' | |
| with: | |
| python-version: '3.12' | |
| - name: Bump beta tag | |
| if: github.event_name != 'push' | |
| id: bump | |
| run: python .github/scripts/bump_beta_tag.py --push | |
| - name: Resolve release tag | |
| id: resolve-tag | |
| run: | | |
| if [ "${{ github.event_name }}" = "push" ]; then | |
| echo "release_tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "release_tag=${{ steps.bump.outputs.next_tag }}" >> "$GITHUB_OUTPUT" | |
| fi | |
| build: | |
| needs: prepare-release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.prepare-release.outputs.release_tag }} | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install build dependencies | |
| run: pip install build twine | |
| - name: Extract version from tag | |
| id: strip-prefix | |
| run: | | |
| TAG="${{ needs.prepare-release.outputs.release_tag }}" | |
| echo "version=${TAG#fa4-v}" >> "$GITHUB_OUTPUT" | |
| - name: Build package | |
| run: python -m build | |
| working-directory: flash_attn/cute | |
| env: | |
| SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.strip-prefix.outputs.version }} | |
| - name: Check package metadata | |
| run: twine check dist/* | |
| working-directory: flash_attn/cute | |
| - name: Store distribution packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: flash_attn/cute/dist/ | |
| github-release: | |
| needs: [prepare-release, build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download distribution packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.prepare-release.outputs.release_tag }} | |
| files: dist/* | |
| generate_release_notes: true | |
| prerelease: ${{ contains(needs.prepare-release.outputs.release_tag, '.beta') }} | |
| publish-to-pypi: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/flash-attn-4 | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download distribution packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |