-
Notifications
You must be signed in to change notification settings - Fork 2.9k
113 lines (107 loc) · 3.31 KB
/
Copy pathpublish-fa4.yml
File metadata and controls
113 lines (107 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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