Skip to content

Commit efc67ea

Browse files
authored
Adding tagged builds for M1 (#6140)
* Adding tagged builds * Testing * Testing * Testing * Testing * Adding conda builds
1 parent 9ce79e8 commit efc67ea

File tree

2 files changed

+53
-17
lines changed

2 files changed

+53
-17
lines changed

.github/workflows/build-m1-binaries.yml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ on:
77
branches:
88
- nightly
99
- main
10+
tags:
11+
# NOTE: Binary build pipelines should only get triggered on release candidate builds
12+
# Release candidate tags look like: v1.11.0-rc1
13+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
1014
workflow_dispatch:
15+
env:
16+
CHANNEL: "nightly"
1117
jobs:
1218
build_wheels:
1319
name: "Build TorchVision M1 wheels"
@@ -18,6 +24,13 @@ jobs:
1824
steps:
1925
- name: Checkout repository
2026
uses: actions/checkout@v2
27+
- name: Set CHANNEL (only for tagged pushes)
28+
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') }}
29+
run: |
30+
# reference ends with an RC suffix
31+
if [[ ${GITHUB_REF_NAME} = *-rc[0-9]* ]]; then
32+
echo "CHANNEL=test" >> "$GITHUB_ENV"
33+
fi
2134
- name: Build TorchVision M1 wheel
2235
shell: arch -arch arm64 bash {0}
2336
env:
@@ -29,10 +42,16 @@ jobs:
2942
export PATH=~/miniconda3/bin:$PATH
3043
set -ex
3144
. packaging/pkg_helpers.bash
32-
setup_build_version
45+
# if we are uploading to test channell, our version consist only of the base: 0.x.x - no date string or suffix added
46+
if [[ $CHANNEL == "test" ]]; then
47+
setup_base_build_version
48+
else
49+
setup_build_version
50+
fi
51+
3352
WHL_NAME=torchvision-${BUILD_VERSION}-cp${PY_VERS/.}-cp${PY_VERS/.}-macosx_11_0_arm64.whl
3453
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy libpng jpeg wheel pkg-config
35-
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
54+
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
3655
conda run -p ${ENV_NAME} python3 -mpip install delocate
3756
conda run -p ${ENV_NAME} python3 setup.py bdist_wheel
3857
export PYTORCH_VERSION="$(conda run -p ${ENV_NAME} python3 -mpip show torch | grep ^Version: | sed 's/Version: *//')"
@@ -47,7 +66,7 @@ jobs:
4766
. ~/miniconda3/etc/profile.d/conda.sh
4867
set -ex
4968
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy
50-
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
69+
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
5170
conda run -p ${ENV_NAME} python3 -mpip install dist/*.whl
5271
# Test torch is importable, by changing cwd and running import commands
5372
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torchvision;print('torchvision version is ', torchvision.__version__)"
@@ -60,12 +79,11 @@ jobs:
6079
name: torchvision-py${{ matrix.py_vers }}-macos11-m1
6180
path: dist/
6281
- name: Upload wheel to S3
63-
if: ${{ github.event_name == 'push' && steps.extract_branch.outputs.branch == 'nightly' }}
82+
if: ${{ github.event_name == 'push' && (steps.extract_branch.outputs.branch == 'nightly' || startsWith(github.event.ref, 'refs/tags/')) }}
6483
shell: arch -arch arm64 bash {0}
6584
env:
6685
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }}
6786
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }}
68-
CHANNEL: nightly
6987
run: |
7088
for pkg in dist/*; do
7189
aws s3 cp "$pkg" "s3://pytorch/whl/${CHANNEL}/cpu/" --acl public-read
@@ -79,7 +97,13 @@ jobs:
7997
steps:
8098
- name: Checkout repository
8199
uses: actions/checkout@v2
82-
100+
- name: Set CHANNEL (only for tagged pushes)
101+
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') }}
102+
run: |
103+
# reference ends with an RC suffix
104+
if [[ ${GITHUB_REF_NAME} = *-rc[0-9]* ]]; then
105+
echo "CHANNEL=test" >> "$GITHUB_ENV"
106+
fi
83107
- name: Install conda-build and purge previous artifacts
84108
shell: arch -arch arm64 bash {0}
85109
run: |
@@ -97,7 +121,13 @@ jobs:
97121
. ~/miniconda3/etc/profile.d/conda.sh
98122
set -ex
99123
. packaging/pkg_helpers.bash
100-
setup_build_version
124+
125+
if [[ $CHANNEL == "test" ]]; then
126+
setup_base_build_version
127+
else
128+
setup_build_version
129+
fi
130+
101131
setup_conda_pytorch_constraint
102132
export SOURCE_ROOT_DIR=$(pwd)
103133
conda build -c defaults $CONDA_CHANNEL_FLAGS --no-anaconda-upload --python "$PYTHON_VERSION" packaging/torchvision
@@ -113,9 +143,8 @@ jobs:
113143
shell: arch -arch arm64 bash {0}
114144
env:
115145
CONDA_PYTORCHBOT_TOKEN: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
116-
UPLOAD_CHANNEL: nightly
117146
run: |
118147
. ~/miniconda3/etc/profile.d/conda.sh
119148
conda install -yq anaconda-client
120149
set -x
121-
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/miniconda3/conda-bld/osx-arm64/*.tar.bz2 -u "pytorch-${UPLOAD_CHANNEL}" --label main --no-progress --force
150+
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/miniconda3/conda-bld/osx-arm64/*.tar.bz2 -u "pytorch-${CHANNEL}" --label main --no-progress --force

packaging/pkg_helpers.bash

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,30 @@ setup_cuda() {
101101
setup_build_version() {
102102
if [[ -z "$BUILD_VERSION" ]]; then
103103
if [[ -z "$1" ]]; then
104-
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
105-
# version.txt for some reason has `a` character after major.minor.rev
106-
# command below yields 0.10.0 from version.txt containing 0.10.0a0
107-
_VERSION_BASE=$( cut -f 1 -d a "$SCRIPT_DIR/../version.txt" )
104+
setup_base_build_version
108105
else
109-
_VERSION_BASE="$1"
106+
BUILD_VERSION="$1"
110107
fi
111-
export BUILD_VERSION="$_VERSION_BASE.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
108+
BUILD_VERSION="$BUILD_VERSION.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
112109
else
113-
export BUILD_VERSION="$BUILD_VERSION$VERSION_SUFFIX"
110+
BUILD_VERSION="$BUILD_VERSION$VERSION_SUFFIX"
114111
fi
115112

116113
# Set build version based on tag if on tag
117114
if [[ -n "${CIRCLE_TAG}" ]]; then
118115
# Strip tag
119-
export BUILD_VERSION="$(echo "${CIRCLE_TAG}" | sed -e 's/^v//' -e 's/-.*$//')${VERSION_SUFFIX}"
116+
BUILD_VERSION="$(echo "${CIRCLE_TAG}" | sed -e 's/^v//' -e 's/-.*$//')${VERSION_SUFFIX}"
120117
fi
118+
119+
export BUILD_VERSION
120+
}
121+
122+
setup_base_build_version() {
123+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
124+
# version.txt for some reason has `a` character after major.minor.rev
125+
# command below yields 0.10.0 from version.txt containing 0.10.0a0
126+
BUILD_VERSION=$( cut -f 1 -d a "$SCRIPT_DIR/../version.txt" )
127+
export BUILD_VERSION
121128
}
122129

123130
# Set some useful variables for OS X, if applicable

0 commit comments

Comments
 (0)