|
1 | 1 | name: Release Workflow |
| 2 | +permissions: {} |
2 | 3 |
|
3 | 4 | on: |
4 | 5 | push: |
5 | 6 | tags: |
6 | 7 | - "*" |
7 | 8 |
|
8 | 9 | jobs: |
9 | | - build: |
10 | | - name: Build wheel |
11 | | - strategy: |
12 | | - fail-fast: true |
13 | | - matrix: |
14 | | - include: |
15 | | - - { os: "macos-14", torch-version: "2.6.0", torch-backend: "cpu" } |
16 | | - - { os: "macos-14", torch-version: "2.7.1", torch-backend: "cpu" } |
17 | | - - { os: "macos-14", torch-version: "2.8.0", torch-backend: "cpu" } |
18 | | - - { os: "macos-14", torch-version: "2.9.0", torch-backend: "cpu" } |
19 | | - - { os: "ubuntu-22.04", torch-version: "2.6.0", torch-backend: "cpu" } |
20 | | - - { os: "ubuntu-22.04", torch-version: "2.6.0", torch-backend: "cu124" } |
21 | | - - { os: "ubuntu-22.04", torch-version: "2.6.0", torch-backend: "cu126" } |
22 | | - - { os: "ubuntu-22.04", torch-version: "2.7.1", torch-backend: "cpu" } |
23 | | - - { os: "ubuntu-22.04", torch-version: "2.7.1", torch-backend: "cu126" } |
24 | | - - { os: "ubuntu-22.04", torch-version: "2.7.1", torch-backend: "cu128" } |
25 | | - - { os: "ubuntu-22.04", torch-version: "2.8.0", torch-backend: "cpu" } |
26 | | - - { os: "ubuntu-22.04", torch-version: "2.8.0", torch-backend: "cu126" } |
27 | | - - { os: "ubuntu-22.04", torch-version: "2.8.0", torch-backend: "cu128" } |
28 | | - - { os: "ubuntu-22.04", torch-version: "2.8.0", torch-backend: "cu129" } |
29 | | - - { os: "ubuntu-22.04", torch-version: "2.9.0", torch-backend: "cpu" } |
30 | | - - { os: "ubuntu-22.04", torch-version: "2.9.0", torch-backend: "cu126" } |
31 | | - - { os: "ubuntu-22.04", torch-version: "2.9.0", torch-backend: "cu128" } |
32 | | - - { os: "ubuntu-22.04", torch-version: "2.9.0", torch-backend: "cu130" } |
33 | | - - { os: "windows-latest", torch-version: "2.6.0", torch-backend: "cpu" } |
34 | | - - { os: "windows-latest", torch-version: "2.6.0", torch-backend: "cu124" } |
35 | | - - { os: "windows-latest", torch-version: "2.6.0", torch-backend: "cu126" } |
36 | | - - { os: "windows-latest", torch-version: "2.7.1", torch-backend: "cpu" } |
37 | | - - { os: "windows-latest", torch-version: "2.7.1", torch-backend: "cu126" } |
38 | | - - { os: "windows-latest", torch-version: "2.7.1", torch-backend: "cu128" } |
39 | | - - { os: "windows-latest", torch-version: "2.8.0", torch-backend: "cpu" } |
40 | | - - { os: "windows-latest", torch-version: "2.8.0", torch-backend: "cu126" } |
41 | | - - { os: "windows-latest", torch-version: "2.8.0", torch-backend: "cu128" } |
42 | | - - { os: "windows-latest", torch-version: "2.8.0", torch-backend: "cu129" } |
43 | | - - { os: "windows-latest", torch-version: "2.9.0", torch-backend: "cpu" } |
44 | | - - { os: "windows-latest", torch-version: "2.9.0", torch-backend: "cu126" } |
45 | | - - { os: "windows-latest", torch-version: "2.9.0", torch-backend: "cu128" } |
46 | | - - { os: "windows-latest", torch-version: "2.9.0", torch-backend: "cu130" } |
47 | | - env: |
48 | | - GLIBC_VERSION: "2_34" |
49 | | - DEFAULT_VERSION: "2.9.0" |
50 | | - runs-on: ${{ matrix.os }} |
51 | | - |
| 10 | + lint: |
| 11 | + name: Linters |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + security-events: write # Required for upload-sarif (used by zizmor-action) to upload SARIF files. |
52 | 15 | steps: |
53 | | - - name: Check if this is the default version |
54 | | - shell: bash |
55 | | - run: | |
56 | | - DEFAULT_BACKEND=$(jq -rn '{"Linux": "cu128", "Windows": "cpu", "macOS": "cpu"}["${{ runner.os }}"]') |
57 | | - if [[ "${{ matrix.torch-version }}" == "$DEFAULT_VERSION" && "${{ matrix.torch-backend }}" == "$DEFAULT_BACKEND" ]]; then |
58 | | - echo "IS_DEFAULT=true" >> $GITHUB_ENV |
59 | | - else |
60 | | - echo "IS_DEFAULT=false" >> $GITHUB_ENV |
61 | | - fi |
62 | | -
|
63 | 16 | - name: Checkout code |
64 | | - uses: actions/checkout@v4 |
65 | | - |
66 | | - - name: Free up disk space |
67 | | - if: ${{ runner.os == 'Linux' }} |
68 | | - # https://github.com/easimon/maximize-build-space/blob/master/action.yml |
69 | | - # https://github.com/easimon/maximize-build-space/tree/test-report |
70 | | - run: | |
71 | | - sudo rm -rf /usr/share/dotnet |
72 | | - sudo rm -rf /opt/ghc |
73 | | - sudo rm -rf /opt/hostedtoolcache/CodeQL |
74 | | -
|
75 | | - - name: Set up swap space |
76 | | - if: runner.os == 'Linux' |
77 | | - uses: pierotofy/set-swap-space@v1.0 |
| 17 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
78 | 18 | with: |
79 | | - swap-size-gb: 10 |
| 19 | + persist-credentials: false |
80 | 20 |
|
81 | | - - name: Get tag name |
82 | | - id: get_tag |
83 | | - shell: bash |
84 | | - run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 21 | + - name: zizmor |
| 22 | + uses: zizmorcore/zizmor-action@135698455da5c3b3e55f73f4419e481ab68cdd95 # v0.4.1 |
85 | 23 |
|
86 | | - - name: Install CUDA 12 on Linux |
87 | | - if: ${{ runner.os == 'Linux' && matrix.torch-backend != 'cpu' && matrix.torch-backend != 'cu130' }} |
88 | | - run: | |
89 | | - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb |
90 | | - sudo dpkg -i cuda-keyring_1.1-1_all.deb |
91 | | - sudo apt-get update |
92 | | - sudo apt-get -y install cuda-nvcc-12-9 cuda-libraries-dev-12.9 |
93 | | - echo "CUDA_HOME=/usr/local/cuda-12.9" >> $GITHUB_ENV |
94 | | - echo "/usr/local/cuda-12.9/bin" >> $GITHUB_PATH |
| 24 | + - name: typos |
| 25 | + uses: crate-ci/typos@65120634e79d8374d1aa2f27e54baa0c364fff5a # v1.42.1 |
95 | 26 |
|
96 | | - - name: Install CUDA 13 on Linux |
97 | | - if: ${{ runner.os == 'Linux' && matrix.torch-backend == 'cu130' }} |
98 | | - run: | |
99 | | - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb |
100 | | - sudo dpkg -i cuda-keyring_1.1-1_all.deb |
101 | | - sudo apt-get update |
102 | | - sudo apt-get -y install cuda-nvcc-13-0 cuda-libraries-dev-13.0 |
103 | | - echo "CUDA_HOME=/usr/local/cuda-13.0" >> $GITHUB_ENV |
104 | | - echo "/usr/local/cuda-13.0/bin" >> $GITHUB_PATH |
| 27 | + - name: Install tombi |
| 28 | + uses: tombi-toml/setup-tombi@f7cb38e77d9a62bc27a8445bf50e660e9496b893 # v1.0.7 |
105 | 29 |
|
106 | | - - name: Install CUDA 12 on Windows |
107 | | - if: ${{ runner.os == 'Windows' && matrix.torch-backend != 'cpu' && matrix.torch-backend != 'cu130' }} |
108 | | - shell: pwsh |
109 | | - run: | |
110 | | - $downloadUrl = "https://developer.download.nvidia.com/compute/cuda/12.9.1/local_installers/cuda_12.9.1_576.57_windows.exe" |
111 | | - $dst = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.9" |
112 | | - New-Item -Path "cuda" -ItemType Directory |
113 | | - New-Item -Path $dst -ItemType Directory |
114 | | - & "C:\msys64\usr\bin\wget" $downloadUrl -O "cuda.exe" -q |
115 | | - & 'C:\Program Files\7-Zip\7z' x "cuda.exe" -o"cuda" |
116 | | - $directories = Get-ChildItem -Directory -Path "cuda" |
117 | | - foreach ($dir in $directories) { |
118 | | - $items = Get-ChildItem -Path (Join-Path "cuda" $dir.Name) |
119 | | - foreach ($item in $items) { |
120 | | - if ($item.PSIsContainer) { |
121 | | - Write-Output "$($item.FullName)" |
122 | | - Copy-Item -Path "$($item.FullName)\*" -Destination $dst -Recurse -Force |
123 | | - } |
124 | | - } |
125 | | - } |
126 | | - Write-Output "CUDA_HOME=$dst" >> $env:GITHUB_ENV |
127 | | - Write-Output "$dst\bin" >> $env:GITHUB_PATH |
| 30 | + - name: Validate TOML files |
| 31 | + run: tombi lint |
128 | 32 |
|
129 | | - - name: Install CUDA 13 on Windows |
130 | | - if: ${{ runner.os == 'Windows' && matrix.torch-backend == 'cu130' }} |
131 | | - shell: pwsh |
132 | | - run: | |
133 | | - $downloadUrl = "https://developer.download.nvidia.com/compute/cuda/13.0.2/local_installers/cuda_13.0.2_windows.exe" |
134 | | - $dst = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0" |
135 | | - New-Item -Path "cuda" -ItemType Directory |
136 | | - New-Item -Path $dst -ItemType Directory |
137 | | - & "C:\msys64\usr\bin\wget" $downloadUrl -O "cuda.exe" -q |
138 | | - & 'C:\Program Files\7-Zip\7z' x "cuda.exe" -o"cuda" |
139 | | - $directories = Get-ChildItem -Directory -Path "cuda" |
140 | | - foreach ($dir in $directories) { |
141 | | - $items = Get-ChildItem -Path (Join-Path "cuda" $dir.Name) |
142 | | - foreach ($item in $items) { |
143 | | - if ($item.PSIsContainer) { |
144 | | - Write-Output "$($item.FullName)" |
145 | | - Copy-Item -Path "$($item.FullName)\*" -Destination $dst -Recurse -Force |
146 | | - } |
147 | | - } |
148 | | - } |
149 | | - Write-Output "CUDA_HOME=$dst" >> $env:GITHUB_ENV |
150 | | - Write-Output "$dst\bin" >> $env:GITHUB_PATH |
| 33 | + - name: Ruff |
| 34 | + uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1 |
151 | 35 |
|
152 | | - - name: Check CUDA installation |
153 | | - if: ${{ matrix.torch-backend != 'cpu' }} |
154 | | - shell: bash |
155 | | - run: | |
156 | | - nvcc -V |
157 | | - echo CUDA_HOME=$CUDA_HOME |
| 36 | + build: |
| 37 | + name: Build distribution |
| 38 | + runs-on: ubuntu-latest |
| 39 | + needs: lint |
| 40 | + permissions: |
| 41 | + actions: write # Upload artifact |
| 42 | + steps: |
| 43 | + - name: Checkout code |
| 44 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 45 | + with: |
| 46 | + persist-credentials: false |
158 | 47 |
|
159 | 48 | - name: Install uv |
160 | | - uses: astral-sh/setup-uv@v5 |
| 49 | + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 |
161 | 50 | with: |
162 | 51 | version: "latest" |
| 52 | + enable-cache: false |
163 | 53 |
|
164 | | - - name: Override torch_version.json |
165 | | - shell: bash |
166 | | - run: | |
167 | | - PLATFORM=$(jq -rn '{"Linux": "linux", "Windows": "win32", "macOS": "darwin"}["${{ runner.os }}"]') |
168 | | - if [ $PLATFORM = "darwin" ]; then |
169 | | - VERSION=${{ matrix.torch-version }} |
170 | | - else |
171 | | - VERSION=${{ matrix.torch-version }}+${{ matrix.torch-backend }} |
172 | | - fi |
173 | | - jq -n --arg platform "$PLATFORM" --arg version "$VERSION" '{($platform): $version}' > src/fastabx/torch_version.json |
174 | | -
|
175 | | - - name: Override latest git tag |
176 | | - shell: bash |
177 | | - env: |
178 | | - TAG: ${{ steps.get_tag.outputs.TAG_NAME }} |
179 | | - run: | |
180 | | - git config user.name "GitHub Actions Bot" |
181 | | - git config user.email "<>" |
182 | | - git add src/fastabx/torch_version.json |
183 | | - git commit -m "update" || true |
184 | | - git tag --force $TAG |
185 | | -
|
186 | | - - name: Build wheel |
187 | | - shell: bash |
188 | | - run: | |
189 | | - uv venv -p 3.12 |
190 | | - uv pip install setuptools setuptools-scm numpy ninja |
191 | | - uv pip install torch==${{ matrix.torch-version }} --index-url https://download.pytorch.org/whl/${{ matrix.torch-backend }} |
192 | | - uv build --wheel --no-build-isolation |
193 | | -
|
194 | | - - name: Relabel the Linux wheel |
195 | | - if: runner.os == 'Linux' |
196 | | - run: | |
197 | | - uvx --with patchelf auditwheel repair ./dist/*abi3-linux*.whl -w ./dist --plat manylinux_${GLIBC_VERSION}_x86_64 --exclude "libtorch*" --exclude "libc10*" --exclude "libcu*" |
198 | | - rm ./dist/*abi3-linux*.whl |
199 | | -
|
200 | | - - name: Copy the wheel with torch version and backend |
201 | | - shell: bash |
202 | | - run: | |
203 | | - wheel=$(ls ./dist/fastabx-*.whl) |
204 | | - if [ "$IS_DEFAULT" = true ]; then |
205 | | - cp "$wheel" "${wheel/-cp/+${{ matrix.torch-backend }}.torch${{ matrix.torch-version }}-cp}" |
206 | | - else |
207 | | - mv "$wheel" "${wheel/-cp/+${{ matrix.torch-backend }}.torch${{ matrix.torch-version }}-cp}" |
208 | | - fi |
| 54 | + - name: Build wheel and sdist |
| 55 | + run: uv build |
209 | 56 |
|
210 | | - - name: Upload artifacts |
211 | | - uses: actions/upload-artifact@v4 |
| 57 | + - name: Upload dists |
| 58 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
212 | 59 | with: |
213 | | - name: dist-${{ matrix.os }}-${{ matrix.torch-backend }}-${{ matrix.torch-version }} |
214 | | - path: ./dist/* |
| 60 | + name: python-package-distributions |
| 61 | + path: dist/ |
215 | 62 |
|
216 | | - release: |
217 | | - name: Create release |
218 | | - needs: build |
| 63 | + publish-to-pypi: |
| 64 | + name: Publish to PyPI |
219 | 65 | runs-on: ubuntu-latest |
| 66 | + needs: build |
| 67 | + environment: |
| 68 | + name: publish-to-pypi |
| 69 | + permissions: |
| 70 | + actions: read # Download artifact |
| 71 | + id-token: write # Needed for trusted publishing |
220 | 72 | steps: |
221 | | - - name: Checkout code |
222 | | - uses: actions/checkout@v4 |
| 73 | + - name: Download all dists |
| 74 | + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 |
| 75 | + with: |
| 76 | + name: python-package-distributions |
| 77 | + path: dist/ |
223 | 78 |
|
224 | 79 | - name: Install uv |
225 | | - uses: astral-sh/setup-uv@v5 |
| 80 | + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 |
226 | 81 | with: |
227 | 82 | version: "latest" |
| 83 | + enable-cache: false |
228 | 84 |
|
229 | | - - name: Get tag name |
230 | | - id: get_tag |
231 | | - run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
232 | | - |
233 | | - - name: Download all artifacts |
234 | | - uses: actions/download-artifact@v4 |
235 | | - with: |
236 | | - path: artifacts |
| 85 | + - name: Upload to PyPI |
| 86 | + run: uv publish --trusted-publishing always |
237 | 87 |
|
238 | | - - name: Move the artifacts |
239 | | - run: | |
240 | | - mkdir ./dist |
241 | | - mv ./artifacts/**/*.whl ./dist |
242 | 88 |
|
243 | | - - name: Build sdist |
244 | | - run: uv build --sdist |
| 89 | + github-release: |
| 90 | + name: GitHub release |
| 91 | + runs-on: ubuntu-latest |
| 92 | + needs: build |
| 93 | + permissions: |
| 94 | + actions: read # Download artifact |
| 95 | + contents: write # Create GitHub release |
| 96 | + steps: |
| 97 | + - name: Checkout code |
| 98 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 99 | + with: |
| 100 | + persist-credentials: false |
245 | 101 |
|
246 | | - - name: List artifacts |
247 | | - run: find ./dist |
| 102 | + - name: Download all dists |
| 103 | + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 |
| 104 | + with: |
| 105 | + name: python-package-distributions |
| 106 | + path: ./dist/ |
248 | 107 |
|
249 | | - - name: Create Release |
| 108 | + - name: Create release |
250 | 109 | env: |
251 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
252 | | - TAG: ${{ steps.get_tag.outputs.TAG_NAME }} |
253 | | - run: gh release create "$TAG" ./dist/* |
254 | | - |
255 | | - - name: Remove non default wheels |
256 | | - run: |
257 | | - rm ./dist/*torch*.whl |
258 | | - |
259 | | - - name: Upload to PyPI |
260 | | - run: uv publish -t ${{ secrets.UV_PUBLISH_TOKEN }} |
| 110 | + GITHUB_TOKEN: ${{ github.token }} |
| 111 | + run: gh release create "${GITHUB_REF#refs/tags/}" ./dist/* |
0 commit comments