Skip to content

Commit d4813a4

Browse files
committed
ci: Automate uploading to correct upload channel
Automate switch to the test channel on tag and swapping out our BUILD_VERSION for the tag name on tag. Swapping BUILD_VERSION doesn't work on windows, but that will come in a follow up commit. Signed-off-by: Eli Uriegas <[email protected]>
1 parent 7a2d061 commit d4813a4

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

.circleci/config.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ commands:
3030
# git fetch --force origin ${CIRCLE_BRANCH}/merge:merged/${CIRCLE_BRANCH}
3131
# git checkout "merged/$CIRCLE_BRANCH"
3232
# fi
33+
designate_upload_channel:
34+
description: "inserts the correct upload channel into ${BASH_ENV}"
35+
steps:
36+
- run:
37+
name: adding UPLOAD_CHANNEL to BASH_ENV
38+
command: |
39+
our_upload_channel=nightly
40+
# On tags upload to test instead
41+
if [[ -n "${CIRCLE_TAG}" ]]; then
42+
our_upload_channel=test
43+
fi
44+
echo "export UPLOAD_CHANNEL=${our_upload_channel}" >> ${BASH_ENV}
3345
3446
binary_common: &binary_common
3547
parameters:
@@ -59,7 +71,6 @@ binary_common: &binary_common
5971
default: "pytorch/manylinux-cuda101"
6072
environment:
6173
PYTHON_VERSION: << parameters.python_version >>
62-
BUILD_VERSION: << parameters.build_version >>
6374
PYTORCH_VERSION: << parameters.pytorch_version >>
6475
UNICODE_ABI: << parameters.unicode_abi >>
6576
CU_VERSION: << parameters.cu_version >>
@@ -358,12 +369,13 @@ jobs:
358369
steps:
359370
- attach_workspace:
360371
at: ~/workspace
372+
- designate_upload_channel
361373
- run:
362374
command: |
363375
# Prevent credential from leaking
364376
conda install -yq anaconda-client
365377
set -x
366-
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/workspace/*.tar.bz2 -u pytorch-nightly --label main --no-progress --force
378+
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/workspace/*.tar.bz2 -u "pytorch-${UPLOAD_CHANNEL}" --label main --no-progress --force
367379
368380
# Requires org-member context
369381
binary_wheel_upload:
@@ -376,6 +388,7 @@ jobs:
376388
steps:
377389
- attach_workspace:
378390
at: ~/workspace
391+
- designate_upload_channel
379392
- checkout
380393
- run:
381394
command: |
@@ -387,7 +400,7 @@ jobs:
387400
export AWS_SECRET_ACCESS_KEY="${PYTORCH_BINARY_AWS_SECRET_ACCESS_KEY}"
388401
set -x
389402
for pkg in ~/workspace/*.whl; do
390-
aws s3 cp "$pkg" "s3://pytorch/whl/nightly/<< parameters.subfolder >>" --acl public-read
403+
aws s3 cp "$pkg" "s3://pytorch/whl/${UPLOAD_CHANNEL}/<< parameters.subfolder >>" --acl public-read
391404
done
392405
393406

.circleci/config.yml.in

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ commands:
3030
# git fetch --force origin ${CIRCLE_BRANCH}/merge:merged/${CIRCLE_BRANCH}
3131
# git checkout "merged/$CIRCLE_BRANCH"
3232
# fi
33+
designate_upload_channel:
34+
description: "inserts the correct upload channel into ${BASH_ENV}"
35+
steps:
36+
- run:
37+
name: adding UPLOAD_CHANNEL to BASH_ENV
38+
command: |
39+
our_upload_channel=nightly
40+
# On tags upload to test instead
41+
if [[ -n "${CIRCLE_TAG}" ]]; then
42+
our_upload_channel=test
43+
fi
44+
echo "export UPLOAD_CHANNEL=${our_upload_channel}" >> ${BASH_ENV}
3345

3446
binary_common: &binary_common
3547
parameters:
@@ -59,7 +71,6 @@ binary_common: &binary_common
5971
default: "pytorch/manylinux-cuda101"
6072
environment:
6173
PYTHON_VERSION: << parameters.python_version >>
62-
BUILD_VERSION: << parameters.build_version >>
6374
PYTORCH_VERSION: << parameters.pytorch_version >>
6475
UNICODE_ABI: << parameters.unicode_abi >>
6576
CU_VERSION: << parameters.cu_version >>
@@ -358,12 +369,13 @@ jobs:
358369
steps:
359370
- attach_workspace:
360371
at: ~/workspace
372+
- designate_upload_channel
361373
- run:
362374
command: |
363375
# Prevent credential from leaking
364376
conda install -yq anaconda-client
365377
set -x
366-
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/workspace/*.tar.bz2 -u pytorch-nightly --label main --no-progress --force
378+
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/workspace/*.tar.bz2 -u "pytorch-${UPLOAD_CHANNEL}" --label main --no-progress --force
367379

368380
# Requires org-member context
369381
binary_wheel_upload:
@@ -376,6 +388,7 @@ jobs:
376388
steps:
377389
- attach_workspace:
378390
at: ~/workspace
391+
- designate_upload_channel
379392
- checkout
380393
- run:
381394
command: |
@@ -387,7 +400,7 @@ jobs:
387400
export AWS_SECRET_ACCESS_KEY="${PYTORCH_BINARY_AWS_SECRET_ACCESS_KEY}"
388401
set -x
389402
for pkg in ~/workspace/*.whl; do
390-
aws s3 cp "$pkg" "s3://pytorch/whl/nightly/<< parameters.subfolder >>" --acl public-read
403+
aws s3 cp "$pkg" "s3://pytorch/whl/${UPLOAD_CHANNEL}/<< parameters.subfolder >>" --acl public-read
391404
done
392405

393406

packaging/pkg_helpers.bash

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ setup_build_version() {
117117
else
118118
export BUILD_VERSION="$BUILD_VERSION$VERSION_SUFFIX"
119119
fi
120+
121+
# Set build version based on tag if on tag
122+
if [[ -n "${CIRCLE_TAG}" ]]; then
123+
# Strip tag
124+
export BUILD_VERSION="$(echo "${CIRCLE_TAG}" | sed -e 's/^v//' -e 's/-.*$//')"
125+
fi
120126
}
121127

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

0 commit comments

Comments
 (0)