refactor: upload to S3 instead of release #7
Workflow file for this run
This file contains 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: Build | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
build-linux: | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
- arch: 'x64' | |
type: 'cuda' | |
pip_args: '' | |
- arch: 'x64' | |
type: 'cpu' | |
pip_args: '--extra-index-url https://download.pytorch.org/whl/cpu' | |
- arch: 'x64' | |
type: 'rocm' | |
pip_args: '' | |
runs-on: ubuntu-latest | |
env: | |
artifact_name: linux-${{ matrix.build.arch }}-${{ matrix.build.type }}.tar.br | |
python_url: 'https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10+20241016-x86_64_v3-unknown-linux-gnu-install_only_stripped.tar.gz' | |
pip_args: ${{ matrix.build.pip_args }} -r requirements.${{ matrix.build.type }}.txt | |
steps: | |
- name: Remove unnecessary files | |
run: | | |
sudo rm -rf \ | |
"$AGENT_TOOLSDIRECTORY" \ | |
/opt/google/chrome \ | |
/opt/microsoft/msedge \ | |
/opt/microsoft/powershell \ | |
/opt/pipx \ | |
/opt/ghc \ | |
/opt/hostedtoolcache/CodeQL \ | |
/usr/lib/mono \ | |
/usr/local/julia* \ | |
/usr/local/lib/android \ | |
/usr/local/share/chromium \ | |
/usr/local/share/powershell \ | |
/usr/share/dotnet \ | |
/usr/share/swift | |
sudo docker image prune --all --force | |
- uses: actions/checkout@v4 | |
- name: Cache Python Download | |
id: cache-python | |
uses: actions/cache@v4 | |
with: | |
path: python.tar.gz | |
key: ${{ runner.os }}-python | |
- name: Download Python | |
if: steps.cache-python.outputs.cache-hit != 'true' | |
run: curl -L -o python.tar.gz ${{ env.python_url }} | |
- name: Cache Pip Packages | |
uses: actions/cache@v4 | |
id: cache-pip-packages | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-${{ matrix.build.type }}-pip-cache | |
- name: Extract Python | |
run: tar -xzf python.tar.gz | |
- name: Install packages | |
run: ./python/bin/python -m pip install --no-compile ${{ env.pip_args }} | |
- name: Clean up | |
run: | | |
rm -rf python/lib/python3.11/site-packages/torch/test | |
rm -rf python/lib/python3.11/site-packages/torch/bin/test_* | |
rm -rf python/lib/python3.11/site-packages/torch/include | |
rm -rf python/share | |
find python/ -type d -name "tests" -exec rm -rf {} + | |
find python/ -type d -name "__pycache__" -exec rm -rf {} + | |
- name: Strip (CUDA) | |
run: | | |
strip -s python/lib/python3.11/site-packages/triton/_C/libtriton.so | |
if: matrix.build.type == 'cuda' | |
- name: Build artifact | |
run: | | |
cd python | |
tar -cf - * | brotli -6 > /tmp/${{ env.artifact_name }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.artifact_name }} | |
path: /tmp/${{ env.artifact_name }} | |
compression-level: 0 | |
build-windows: | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
- arch: 'x64' | |
type: 'cuda' | |
pip_args: '' | |
- arch: 'x64' | |
type: 'directml' | |
pip_args: '' | |
- arch: 'x64' | |
type: 'cpu' | |
pip_args: '' | |
- arch: 'x64' | |
type: 'zluda' | |
pip_args: '' | |
runs-on: windows-latest | |
env: | |
artifact_name: win32-${{ matrix.build.arch }}-${{ matrix.build.type }}.tar.br | |
python_url: 'https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10+20241016-x86_64-pc-windows-msvc-shared-install_only_stripped.tar.gz' | |
pip_args: ${{ matrix.build.pip_args }} -r requirements.${{ matrix.build.type }}.txt | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache Python Download | |
id: cache-python | |
uses: actions/cache@v4 | |
with: | |
path: python.tar.gz | |
key: ${{ runner.os }}-python | |
- name: Download Python | |
if: steps.cache-python.outputs.cache-hit != 'true' | |
run: curl -L -o python.tar.gz ${{ env.python_url }} | |
- name: Cache Pip Packages | |
uses: actions/cache@v4 | |
id: cache-pip-packages | |
with: | |
path: ~\AppData\Local\pip\cache | |
key: ${{ runner.os }}-${{ matrix.build.type }}-pip-cache | |
- name: Extract Python | |
run: tar -xzf python.tar.gz | |
- name: Install packages | |
run: .\python\python.exe -m pip install --no-compile ${{ env.pip_args }} | |
- name: Clean up | |
run: | | |
rm -r -fo python/Lib/site-packages/torch/include | |
rm -r -fo python/share | |
Remove-Item 'python\*' -Recurse -Include *.pdb | |
Remove-Item 'python\*' -Recurse -Include *.lib | |
Get-ChildItem -path python -Include '__pycache__' -Recurse -force | Remove-Item -force -Recurse | |
- name: Build artifact | |
run: | | |
cd python | |
tar -cf - * | brotli -6 > C:\WINDOWS\Temp\${{ env.artifact_name }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.artifact_name }} | |
path: C:\WINDOWS\Temp\${{ env.artifact_name }} | |
compression-level: 0 | |
build-mac-arm: | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
- arch: 'arm64' | |
type: 'cpu' | |
runs-on: macos-14 | |
env: | |
artifact_name: darwin-${{ matrix.build.arch }}-${{ matrix.build.type }}.tar.br | |
python_url: 'https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10+20241016-aarch64-apple-darwin-install_only_stripped.tar.gz' | |
pip_args: -r requirements.${{ matrix.build.type }}.txt | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache Python Download | |
id: cache-python | |
uses: actions/cache@v4 | |
with: | |
path: python.tar.gz | |
key: ${{ runner.os }}-python | |
- name: Download Python | |
if: steps.cache-python.outputs.cache-hit != 'true' | |
run: curl -L -o python.tar.gz ${{ env.python_url }} | |
- name: Cache Pip Packages | |
uses: actions/cache@v4 | |
id: cache-pip-packages | |
with: | |
path: ~/Library/Caches/pip | |
key: ${{ runner.os }}-${{ matrix.build.type }}-pip-cache | |
- name: Extract Python | |
run: tar -xzf python.tar.gz | |
- name: Install packages | |
run: ./python/bin/python -m pip install --no-compile ${{ env.pip_args }} | |
- name: Clean up | |
run: | | |
rm -rf python/lib/python3.11/site-packages/torch/include | |
rm -rf python/share | |
find python/ -type d -name "tests" -exec rm -rf {} + | |
find python/ -type d -name "__pycache__" -exec rm -rf {} + | |
- name: Build artifact | |
run: | | |
cd python | |
tar -cf - * | brotli -6 > /tmp/${{ env.artifact_name }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.artifact_name }} | |
path: /tmp/${{ env.artifact_name }} | |
compression-level: 0 | |
build-mac-x86: | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
- arch: 'x64' | |
type: 'cpu' | |
runs-on: macos-13 | |
env: | |
artifact_name: darwin-${{ matrix.build.arch }}-${{ matrix.build.type }}.tar.br | |
python_url: 'https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.11.10+20241016-x86_64-apple-darwin-install_only_stripped.tar.gz' | |
pip_args: -r requirements.${{ matrix.build.type }}.txt | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache Python Download | |
id: cache-python | |
uses: actions/cache@v4 | |
with: | |
path: python.tar.gz | |
key: ${{ runner.os }}-python | |
- name: Download Python | |
if: steps.cache-python.outputs.cache-hit != 'true' | |
run: curl -L -o python.tar.gz ${{ env.python_url }} | |
- name: Cache Pip Packages | |
uses: actions/cache@v4 | |
id: cache-pip-packages | |
with: | |
path: ~/Library/Caches/pip | |
key: ${{ runner.os }}-${{ matrix.build.type }}-pip-cache | |
- name: Extract Python | |
run: tar -xzf python.tar.gz | |
- name: Install packages | |
run: ./python/bin/python -m pip install --no-compile ${{ env.pip_args }} | |
- name: Clean up | |
run: | | |
rm -rf python/lib/python3.11/site-packages/torch/include | |
rm -rf python/share | |
find python/ -type d -name "tests" -exec rm -rf {} + | |
find python/ -type d -name "__pycache__" -exec rm -rf {} + | |
- name: Build artifact | |
run: | | |
cd python | |
tar -cf - * | brotli -6 > /tmp/${{ env.artifact_name }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.artifact_name }} | |
path: /tmp/${{ env.artifact_name }} | |
compression-level: 0 | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: | |
- build-linux | |
- build-windows | |
- build-mac-arm | |
- build-mac-x86 | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
path: artifacts/ | |
merge-multiple: true | |
- name: Upload artifacts to S3 bucket | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} | |
run: | | |
aws s3 cp ./artifacts s3://${{ vars.S3_BUCKET }}/${{ vars.S3_PREFIX }}/${{ github.ref_name }}/ --recursive --endpoint-url ${{ secrets.S3_ENDPOINT }} | |
- name: Upload version file to S3 bucket | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} | |
run: | | |
jq -n --arg version '${{ github.ref_name }}' '$ARGS.named' > /tmp/version.json | |
aws s3 cp /tmp/version.json s3://${{ vars.S3_BUCKET }}/${{ vars.S3_PREFIX }}/version.json --endpoint-url ${{ secrets.S3_ENDPOINT }} |