diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ade46d9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: Build and publish DeepSpeed-Kernels release + +on: + push: + tags: + - 'v*.*.*' + +jobs: + deploy: + runs-on: [self-hosted, cpu] + environment: release-env + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Check environment + run: | + which python + python --version + which nvcc + nvcc --version + python -c "import torch; print('torch:', torch.__version__, torch)" + python -c "import torch; print('CUDA available:', torch.cuda.is_available())" + - name: Get release version from tag + run: | + echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV + - name: Check release version + run: | + pip install packaging + python release/check_release_version.py --release_version ${{ env.RELEASE_VERSION }} + - name: Build DeepSpeed-Kernels + run: | + ts=$(date +%s) + DS_KERNELS_MAKE_JOBS=10 DS_KERNELS_BUILD_STRING=".dev${ts}" CUDA_ARCH_LIST="80;86;89;90" python setup.py bdist_wheel + fname=$(ls dist) + nname=$(echo $fname | sed 's/cp[0-9]\+-cp[0-9]\+/py3-none/' | sed 's/linux/manylinux1/') + mv "dist/$fname" "dist/$nname" + ls -al + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + repository-url: https://upload.pypi.org/legacy/ + - name: Bump version + run: | + python release/bump_patch_version.py --current_version ${{ env.RELEASE_VERSION }} + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GH_PAT }} + add-paths: | + version.txt + body: | + **Auto-generated PR to update version.txt after a DeepSpeed release** + Released version - ${{ env.RELEASE_VERSION }} + Author - @${{ github.actor }} + branch: AutoPR/${{ env.RELEASE_VERSION }} + assignees: ${{ github.actor }} + title: "Update version.txt after ${{ env.RELEASE_VERSION }} release" + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> diff --git a/release/bump_patch_version.py b/release/bump_patch_version.py new file mode 100644 index 0000000..719f4d4 --- /dev/null +++ b/release/bump_patch_version.py @@ -0,0 +1,22 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 + +# DeepSpeed Team + +import argparse +from packaging import version as pkg_version + +parser = argparse.ArgumentParser() + +parser.add_argument("--current_version", + type=str, + help="The current version being published to help set the next version.") + +args = parser.parse_args() + +current_version = pkg_version.parse(args.current_version) + +with open('./version.txt', 'w') as fd: + fd.write(f'{current_version.major}.{current_version.minor}.{current_version.micro + 1}\n') + +print(f'{current_version} -> {current_version.major}.{current_version.minor}.{current_version.micro + 1}') diff --git a/release/check_release_version.py b/release/check_release_version.py new file mode 100644 index 0000000..266094b --- /dev/null +++ b/release/check_release_version.py @@ -0,0 +1,20 @@ +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: Apache-2.0 + +# DeepSpeed Team + +import argparse +from packaging import version as pkg_version + +parser = argparse.ArgumentParser() + +parser.add_argument("--release_version", type=str, help="The new version being published.") + +args = parser.parse_args() + +release_version = pkg_version.parse(args.release_version) + +with open('./version.txt') as fd: + repo_version = pkg_version.parse(fd.read()) + +assert repo_version == release_version, f"{repo_version=} does not match {release_version=}, unable to proceed"