2018-03-06 23:36:50 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# publish_packages.sh uploads our packages to package repositories like npm
|
2018-09-03 18:49:57 +02:00
|
|
|
set -o nounset
|
|
|
|
set -o errexit
|
|
|
|
set -o pipefail
|
|
|
|
readonly ROOT=$(dirname "${0}")/..
|
2018-03-06 23:36:50 +01:00
|
|
|
|
2021-03-10 20:03:29 +01:00
|
|
|
NPM_VERSION=$(pulumictl get version --language javascript)
|
2019-01-23 21:13:19 +01:00
|
|
|
"${ROOT}/scripts/build-sdk.sh" $(echo ${NPM_VERSION} | sed -e 's/\+.*//g') $(git rev-parse HEAD)
|
|
|
|
|
2018-04-15 07:25:35 +02:00
|
|
|
if [[ "${TRAVIS_PUBLISH_PACKAGES:-}" == "true" ]]; then
|
2018-03-06 23:36:50 +01:00
|
|
|
echo "Publishing NPM package to NPMjs.com:"
|
2018-04-05 23:03:20 +02:00
|
|
|
NPM_TAG="dev"
|
|
|
|
|
2019-01-31 23:07:48 +01:00
|
|
|
if [[ "${TRAVIS_BRANCH:-}" == features/* ]]; then
|
|
|
|
NPM_TAG=$(echo "${TRAVIS_BRANCH}" | sed -e 's|^features/|feature-|g')
|
|
|
|
fi
|
|
|
|
|
2020-01-30 21:28:31 +01:00
|
|
|
if [[ "${TRAVIS_BRANCH:-}" == feature-* ]]; then
|
|
|
|
NPM_TAG=$(echo "${TRAVIS_BRANCH}")
|
|
|
|
fi
|
|
|
|
|
2019-09-12 20:08:24 +02:00
|
|
|
PKG_NAME=$(jq -r .name < "${ROOT}/sdk/nodejs/bin/package.json")
|
|
|
|
PKG_VERSION=$(jq -r .version < "${ROOT}/sdk/nodejs/bin/package.json")
|
|
|
|
|
2019-08-13 20:41:32 +02:00
|
|
|
# If the package doesn't have an alpha tag, use the tag of latest instead of
|
2018-04-05 23:03:20 +02:00
|
|
|
# dev. NPM uses this tag as the default version to add, so we want it to mean
|
|
|
|
# the newest released version.
|
2019-09-12 20:08:24 +02:00
|
|
|
if [[ "${PKG_VERSION}" != *-alpha* ]]; then
|
2018-04-05 23:03:20 +02:00
|
|
|
NPM_TAG="latest"
|
|
|
|
fi
|
|
|
|
|
2019-09-12 20:08:24 +02:00
|
|
|
# Now, perform the publish. The logic here is a little goofy because npm provides
|
|
|
|
# no way to say "if the package already exists, don't fail" but we want these
|
|
|
|
# semantics (so, for example, we can restart builds which may have failed after
|
|
|
|
# publishing, or so two builds can run concurrently, which is the case for when we
|
|
|
|
# tag master right after pushing a new commit and the push and tag travis jobs both
|
|
|
|
# get the same version.
|
|
|
|
#
|
|
|
|
# We exploit the fact that `npm info <package-name>@<package-version>` has no output
|
|
|
|
# when the package does not exist.
|
|
|
|
pushd "${ROOT}/sdk/nodejs/bin"
|
|
|
|
if [ "$(npm info ${PKG_NAME}@${PKG_VERSION})" == "" ]; then
|
|
|
|
if ! npm publish -tag "${NPM_TAG}"; then
|
|
|
|
# if we get here, we have a TOCTOU issue, so check again
|
|
|
|
# to see if it published. If it didn't bail out.
|
|
|
|
if [ "$(npm info ${PKG_NAME}@${PKG_VERSION})" == "" ]; then
|
|
|
|
echo "NPM publishing failed, aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
npm info 2>/dev/null
|
|
|
|
popd
|
2018-03-06 23:36:50 +01:00
|
|
|
|
|
|
|
echo "Publishing Pip package to pulumi.com:"
|
|
|
|
twine upload \
|
2018-09-03 18:49:57 +02:00
|
|
|
-u pulumi -p "${PYPI_PASSWORD}" \
|
2019-09-12 20:08:24 +02:00
|
|
|
"${ROOT}/sdk/python/env/src/dist"/*.whl \
|
|
|
|
--skip-existing \
|
|
|
|
--verbose
|
2018-04-11 20:33:53 +02:00
|
|
|
|
2019-10-30 04:14:49 +01:00
|
|
|
echo "Publishing .nupkgs to nuget.org:"
|
|
|
|
find /opt/pulumi/nuget -name 'Pulumi*.nupkg' \
|
|
|
|
-exec dotnet nuget push -k ${NUGET_PUBLISH_KEY} -s https://api.nuget.org/v3/index.json {} ';'
|
|
|
|
|
2020-04-21 19:39:26 +02:00
|
|
|
echo "Publishing Docker containers to hub.docker.com:"
|
2020-05-27 22:29:48 +02:00
|
|
|
"${ROOT}/scripts/build-docker.sh" "${NPM_VERSION}" --publish
|
2019-09-05 21:20:48 +02:00
|
|
|
|
2020-04-21 19:39:26 +02:00
|
|
|
echo "Building package docs:"
|
2020-04-14 10:40:11 +02:00
|
|
|
"$(go env GOPATH)/src/github.com/pulumi/scripts/ci/build-package-docs.sh" pulumi
|
2019-01-23 21:13:19 +01:00
|
|
|
fi
|
2018-09-03 18:49:57 +02:00
|
|
|
|
2019-01-23 21:13:19 +01:00
|
|
|
exit 0
|