Skip to content

Commit ff034cb

Browse files
authored
Adding tagged builds to torchaudio (#2471) (#2475)
Summary: Adding tagged builds for torchaudio see: pytorch/vision#6140 Pull Request resolved: #2471 Reviewed By: hwangjeff Differential Revision: D37080828 Pulled By: atalman fbshipit-source-id: 13d754f522510514f0148ba465ce12a320058722
1 parent 633c2ab commit ff034cb

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ on:
66
push:
77
branches:
88
- nightly
9+
tags:
10+
# NOTE: Binary build pipelines should only get triggered on release candidate builds
11+
# Release candidate tags look like: v1.11.0-rc1
12+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
913
workflow_dispatch:
14+
env:
15+
CHANNEL: "nightly"
1016
jobs:
1117
build_wheels:
1218
name: "Build TorchAudio M1 wheels"
@@ -17,6 +23,13 @@ jobs:
1723
steps:
1824
- name: Checkout repository
1925
uses: actions/checkout@v2
26+
- name: Set CHANNEL (only for tagged pushes)
27+
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') }}
28+
run: |
29+
# reference ends with an RC suffix
30+
if [[ ${GITHUB_REF_NAME} = *-rc[0-9]* ]]; then
31+
echo "CHANNEL=test" >> "$GITHUB_ENV"
32+
fi
2033
- name: Build TorchAudio M1 wheel
2134
shell: arch -arch arm64 bash {0}
2235
env:
@@ -27,10 +40,15 @@ jobs:
2740
. ~/miniconda3/etc/profile.d/conda.sh
2841
set -ex
2942
. packaging/pkg_helpers.bash
30-
setup_build_version
43+
# if we are uploading to test channell, our version consist only of the base: 0.x.x - no date string or suffix added
44+
if [[ $CHANNEL == "test" ]]; then
45+
setup_base_build_version
46+
else
47+
setup_build_version
48+
fi
3149
WHL_NAME=torchaudio-${BUILD_VERSION}-cp${PY_VERS/.}-cp${PY_VERS/.}-macosx_11_0_arm64.whl
3250
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy cmake ninja wheel pkg-config
33-
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
51+
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
3452
conda run -p ${ENV_NAME} python3 -mpip install delocate
3553
conda run -p ${ENV_NAME} python3 setup.py bdist_wheel
3654
export PYTORCH_VERSION="$(conda run -p ${ENV_NAME} python3 -mpip show torch | grep ^Version: | sed 's/Version: *//')"
@@ -45,25 +63,24 @@ jobs:
4563
. ~/miniconda3/etc/profile.d/conda.sh
4664
set -ex
4765
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy
48-
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/nightly
66+
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
4967
conda run -p ${ENV_NAME} python3 -mpip install dist/*.whl
5068
# Test torch is importable, by changing cwd and running import commands
5169
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torchaudio;print('torchaudio version is ', torchaudio.__version__)"
5270
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torch;import torchaudio;torchaudio.set_audio_backend('sox_io')"
5371
conda env remove -p ${ENV_NAME}
5472
- name: Upload wheel to GitHub
55-
if: ${{ github.event_name == 'push' && steps.extract_branch.outputs.branch == 'nightly' }}
73+
if: ${{ github.event_name == 'push' && (github.event.ref == 'ref/heads/nightly' || startsWith(github.event.ref, 'refs/tags/')) }}
5674
uses: actions/upload-artifact@v3
5775
with:
5876
name: torchaudio-py${{ matrix.py_vers }}-macos11-m1
5977
path: dist/
6078
- name: Upload wheel to S3
61-
if: ${{ github.event_name == 'push' && steps.extract_branch.outputs.branch == 'nightly' }}
79+
if: ${{ github.event_name == 'push' && (github.event.ref == 'ref/heads/nightly' || startsWith(github.event.ref, 'refs/tags/')) }}
6280
shell: arch -arch arm64 bash {0}
6381
env:
6482
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }}
6583
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }}
66-
CHANNEL: nightly
6784
run: |
6885
for pkg in dist/*; do
6986
aws s3 cp "$pkg" "s3://pytorch/whl/${CHANNEL}/cpu/" --acl public-read

packaging/pkg_helpers.bash

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,30 @@ setup_cuda() {
101101
# Usage: setup_build_version
102102
setup_build_version() {
103103
if [[ -z "$BUILD_VERSION" ]]; 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" )
108-
BUILD_VERSION="$_VERSION_BASE.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
104+
if [[ -z "$1" ]]; then
105+
setup_base_build_version
106+
else
107+
BUILD_VERSION="$1"
108+
fi
109+
BUILD_VERSION="$BUILD_VERSION.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
109110
else
110111
BUILD_VERSION="$BUILD_VERSION$VERSION_SUFFIX"
111112
fi
113+
114+
# Set build version based on tag if on tag
115+
if [[ -n "${CIRCLE_TAG}" ]]; then
116+
# Strip tag
117+
BUILD_VERSION="$(echo "${CIRCLE_TAG}" | sed -e 's/^v//' -e 's/-.*$//')${VERSION_SUFFIX}"
118+
fi
119+
120+
export BUILD_VERSION
121+
}
122+
123+
setup_base_build_version() {
124+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
125+
# version.txt for some reason has `a` character after major.minor.rev
126+
# command below yields 0.10.0 from version.txt containing 0.10.0a0
127+
BUILD_VERSION=$( cut -f 1 -d a "$SCRIPT_DIR/../version.txt" )
112128
export BUILD_VERSION
113129
}
114130

0 commit comments

Comments
 (0)