Skip to content

Commit

Permalink
chore(ci): release packages
Browse files Browse the repository at this point in the history
  • Loading branch information
abcdabcd987 committed Dec 28, 2023
1 parent 69f5d4a commit 087b42a
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 49 deletions.
47 changes: 0 additions & 47 deletions .github/workflows/build_wheel.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/gpu-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
- "*.md"
- "assets/**"
- "docs/**"
branches-ignore:
- ci-wheel
pull_request:
paths-ignore:
- "*.md"
Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/release_wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Release
on:
push:
branches:
- ci-wheel
tags:
- "v[0-9]+*"

env:
TORCH_CUDA_ARCH_LIST: "8.0 8.6 8.9+PTX" # Need fix for 9.0
PUNICA_CI_TORCH_VERSION: "2.1.0"

jobs:
build:
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.11"]
cuda: ["11.8", "12.1"]
runs-on: [self-hosted]
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Build wheel
run: |
chown -R $CI_UID:$CI_GID "$GITHUB_WORKSPACE"
version="$(cat version.txt)"
docker run --rm -t \
-v "$CI_RUNNER_CACHE_DIR":/ci-cache \
-v "$GITHUB_WORKSPACE":/app \
-e PUNICA_CI_PYTHON_VERSION=${{ matrix.python }} \
-e PUNICA_CI_CUDA_VERSION=${{ matrix.cuda }} \
-e PUNICA_CI_TORCH_VERSION=$PUNICA_CI_TORCH_VERSION \
-e PUNICA_BUILD_VERSION=$version \
-e TORCH_CUDA_ARCH_LIST="$TORCH_CUDA_ARCH_LIST" \
--user $CI_UID:$CI_GID \
pytorch/manylinux-builder:cuda${{ matrix.cuda }} \
bash /app/ci/run-ci-build-wheel.bash
- run: du -h dist/*

- uses: actions/upload-artifact@v4
with:
name: wheel-cuda${{ matrix.cuda }}-python${{ matrix.python }}
path: dist/*

release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true
pattern: wheel-*

- run: ls -lah dist/

- uses: softprops/action-gh-release@v1
with:
draft: true
files: |
dist/punica-*.whl
dist/punica-*.tar.gz
- name: Clone wheel index
run: git clone https://oauth2:${WHL_TOKEN}@github.com/punica-ai/whl.git punica-whl
env:
WHL_TOKEN: ${{ secrets.WHL_TOKEN }}

- name: Update wheel index
shell: python
run: |
import pathlib
import hashlib
import re
for path in sorted(pathlib.Path("dist").glob("*.whl")):
with open(path, "rb") as f:
sha256 = hashlib.sha256(f.read()).hexdigest()
ver, cu = re.findall(r"punica-([0-9.]+)\+cu(\d+)-", path.name)[0]
with open(f"punica-whl/cu{cu}/index.html", "a") as f:
f.write(f'<a href="https://github.com/punica-ai/punica/releases/download/v{ver}/{path.name}#sha256={sha256}">{path.name}</a><br>\n')
- name: Push wheel index
run: |
cd punica-whl
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "update whl"
git push
- name: Upload sdist to pypi
run: |
pip install twine
python -m twine upload --repository testpypi --username=__token__ dist/*.tar.gz
env:
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
6 changes: 4 additions & 2 deletions ci/run-ci-build-wheel.bash
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export XDG_CACHE_HOME=/ci-cache/xdg-cache
mkdir -p "$CONDA_pkgs_dirs" "$XDG_CACHE_HOME"
export HOME=/tmp/home
mkdir -p $HOME
export PATH="$HOME/.local/bin:$PATH"
CUDA_MAJOR="${PUNICA_CI_CUDA_VERSION%.*}"
CUDA_MINOR="${PUNICA_CI_CUDA_VERSION#*.}"
PYVER="${PUNICA_CI_PYTHON_VERSION//./}"
export PATH="$HOME/.local/bin:$PATH"
export PATH="/opt/python/cp${PYVER}-cp${PYVER}/bin:$PATH"


Expand All @@ -39,5 +39,7 @@ echo "::endgroup::"

echo "::group::Build wheel for Punica"
cd "$PROJECT_ROOT"
python -m build --no-isolation
PUNICA_BUILD_VERSION="${PUNICA_BUILD_VERSION}+cu${CUDA_MAJOR}${CUDA_MINOR}" python -m build --no-isolation
rm -f dist/*.tar.gz
python -m build --no-isolation --sdist
echo "::endgroup::"

0 comments on commit 087b42a

Please sign in to comment.