Skip to content

Commit

Permalink
ci: Automate uploading to correct upload channel
Browse files Browse the repository at this point in the history
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 <eliuriegas@fb.com>
  • Loading branch information
seemethere committed May 11, 2020
1 parent 7a2d061 commit d4813a4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
19 changes: 16 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ commands:
# git fetch --force origin ${CIRCLE_BRANCH}/merge:merged/${CIRCLE_BRANCH}
# git checkout "merged/$CIRCLE_BRANCH"
# fi
designate_upload_channel:
description: "inserts the correct upload channel into ${BASH_ENV}"
steps:
- run:
name: adding UPLOAD_CHANNEL to BASH_ENV
command: |
our_upload_channel=nightly
# On tags upload to test instead
if [[ -n "${CIRCLE_TAG}" ]]; then
our_upload_channel=test
fi
echo "export UPLOAD_CHANNEL=${our_upload_channel}" >> ${BASH_ENV}
binary_common: &binary_common
parameters:
Expand Down Expand Up @@ -59,7 +71,6 @@ binary_common: &binary_common
default: "pytorch/manylinux-cuda101"
environment:
PYTHON_VERSION: << parameters.python_version >>
BUILD_VERSION: << parameters.build_version >>
PYTORCH_VERSION: << parameters.pytorch_version >>
UNICODE_ABI: << parameters.unicode_abi >>
CU_VERSION: << parameters.cu_version >>
Expand Down Expand Up @@ -358,12 +369,13 @@ jobs:
steps:
- attach_workspace:
at: ~/workspace
- designate_upload_channel
- run:
command: |
# Prevent credential from leaking
conda install -yq anaconda-client
set -x
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/workspace/*.tar.bz2 -u pytorch-nightly --label main --no-progress --force
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/workspace/*.tar.bz2 -u "pytorch-${UPLOAD_CHANNEL}" --label main --no-progress --force
# Requires org-member context
binary_wheel_upload:
Expand All @@ -376,6 +388,7 @@ jobs:
steps:
- attach_workspace:
at: ~/workspace
- designate_upload_channel
- checkout
- run:
command: |
Expand All @@ -387,7 +400,7 @@ jobs:
export AWS_SECRET_ACCESS_KEY="${PYTORCH_BINARY_AWS_SECRET_ACCESS_KEY}"
set -x
for pkg in ~/workspace/*.whl; do
aws s3 cp "$pkg" "s3://pytorch/whl/nightly/<< parameters.subfolder >>" --acl public-read
aws s3 cp "$pkg" "s3://pytorch/whl/${UPLOAD_CHANNEL}/<< parameters.subfolder >>" --acl public-read
done
Expand Down
19 changes: 16 additions & 3 deletions .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ commands:
# git fetch --force origin ${CIRCLE_BRANCH}/merge:merged/${CIRCLE_BRANCH}
# git checkout "merged/$CIRCLE_BRANCH"
# fi
designate_upload_channel:
description: "inserts the correct upload channel into ${BASH_ENV}"
steps:
- run:
name: adding UPLOAD_CHANNEL to BASH_ENV
command: |
our_upload_channel=nightly
# On tags upload to test instead
if [[ -n "${CIRCLE_TAG}" ]]; then
our_upload_channel=test
fi
echo "export UPLOAD_CHANNEL=${our_upload_channel}" >> ${BASH_ENV}

binary_common: &binary_common
parameters:
Expand Down Expand Up @@ -59,7 +71,6 @@ binary_common: &binary_common
default: "pytorch/manylinux-cuda101"
environment:
PYTHON_VERSION: << parameters.python_version >>
BUILD_VERSION: << parameters.build_version >>
PYTORCH_VERSION: << parameters.pytorch_version >>
UNICODE_ABI: << parameters.unicode_abi >>
CU_VERSION: << parameters.cu_version >>
Expand Down Expand Up @@ -358,12 +369,13 @@ jobs:
steps:
- attach_workspace:
at: ~/workspace
- designate_upload_channel
- run:
command: |
# Prevent credential from leaking
conda install -yq anaconda-client
set -x
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/workspace/*.tar.bz2 -u pytorch-nightly --label main --no-progress --force
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/workspace/*.tar.bz2 -u "pytorch-${UPLOAD_CHANNEL}" --label main --no-progress --force

# Requires org-member context
binary_wheel_upload:
Expand All @@ -376,6 +388,7 @@ jobs:
steps:
- attach_workspace:
at: ~/workspace
- designate_upload_channel
- checkout
- run:
command: |
Expand All @@ -387,7 +400,7 @@ jobs:
export AWS_SECRET_ACCESS_KEY="${PYTORCH_BINARY_AWS_SECRET_ACCESS_KEY}"
set -x
for pkg in ~/workspace/*.whl; do
aws s3 cp "$pkg" "s3://pytorch/whl/nightly/<< parameters.subfolder >>" --acl public-read
aws s3 cp "$pkg" "s3://pytorch/whl/${UPLOAD_CHANNEL}/<< parameters.subfolder >>" --acl public-read
done


Expand Down
6 changes: 6 additions & 0 deletions packaging/pkg_helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ setup_build_version() {
else
export BUILD_VERSION="$BUILD_VERSION$VERSION_SUFFIX"
fi

# Set build version based on tag if on tag
if [[ -n "${CIRCLE_TAG}" ]]; then
# Strip tag
export BUILD_VERSION="$(echo "${CIRCLE_TAG}" | sed -e 's/^v//' -e 's/-.*$//')"
fi
}

# Set some useful variables for OS X, if applicable
Expand Down

0 comments on commit d4813a4

Please sign in to comment.