From 6cad50fea31f35ced1af33d5c8c548defcd52a62 Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Sun, 21 Jun 2020 15:35:31 -0700 Subject: [PATCH 01/13] update scripts to support community packages --- ci/add-plugin-installer-script.js | 2 +- ci/publish-tfgen-package | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/add-plugin-installer-script.js b/ci/add-plugin-installer-script.js index 1d75d34..5fed515 100644 --- a/ci/add-plugin-installer-script.js +++ b/ci/add-plugin-installer-script.js @@ -37,7 +37,7 @@ stdin.on("close", function() { if (name.lastIndexOf("/") !== -1) { name = name.substring(name.lastIndexOf("/")+1); } - packageJSON.scripts["install"] = `node scripts/install-pulumi-plugin.js resource ${name} ${packageJSON.version}`; + packageJSON.scripts["install"] = `node scripts/install-pulumi-plugin.js resource ${name} --server ${packageJSON.repository}/releases/download/${packageJSON.version} ${packageJSON.version}`; // Now print out the result to stdout. console.log(JSON.stringify(packageJSON, null, 4)); diff --git a/ci/publish-tfgen-package b/ci/publish-tfgen-package index bc9e960..70f77f1 100755 --- a/ci/publish-tfgen-package +++ b/ci/publish-tfgen-package @@ -94,9 +94,9 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then if [ -n "${NO_TFGEN_PYTHON_PACKAGE}" ] ; then echo "Skipping publishing pip package because of NO_TFGEN_PYTHON_PACKAGE" else - echo "Publishing Pip package to pulumi.com:" + echo "Publishing Pip package to pypi:" twine upload \ - -u pulumi -p "${PYPI_PASSWORD}" \ + -u "${PYPI_USERNAME}" -p "${PYPI_PASSWORD}" \ "${SOURCE_ROOT}/sdk/python/bin/dist/*.tar.gz" \ --skip-existing \ --verbose From 76c10f53b622d06edb19660b7eaad88bd4730876 Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Sun, 21 Jun 2020 15:37:24 -0700 Subject: [PATCH 02/13] set nounset This will stop the publish script publishing if there's a variable unset --- ci/publish-tfgen-package | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/publish-tfgen-package b/ci/publish-tfgen-package index 70f77f1..83887dc 100755 --- a/ci/publish-tfgen-package +++ b/ci/publish-tfgen-package @@ -11,6 +11,7 @@ set -o errexit set -o pipefail +set -o nounset if [ "$#" -ne 1 ]; then >&2 echo "usage: $0 " From a4c56a180401c0a5250153720b8198ee05019475 Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Sun, 21 Jun 2020 15:41:01 -0700 Subject: [PATCH 03/13] better variable error checking --- ci/publish-tfgen-package | 47 +++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/ci/publish-tfgen-package b/ci/publish-tfgen-package index 83887dc..07182c8 100755 --- a/ci/publish-tfgen-package +++ b/ci/publish-tfgen-package @@ -11,13 +11,32 @@ set -o errexit set -o pipefail -set -o nounset if [ "$#" -ne 1 ]; then >&2 echo "usage: $0 " exit 1 fi +if [[ -z "$PYPI_USERNAME" ]]; then + echo "Must provide PYPI_USERNAME" 1>&2 + exit 1 +fi + +if [[ -z "$PYPI_PASSWORD" ]]; then + echo "Must provide PYPI_PASSWORD" 1>&2 + exit 1 +fi + +if [[ -z "$NUGET_PUBLISH_KEY" ]]; then + echo "Must provide NUGET_PUBLISH_KEY" 1>&2 + exit 1 +fi + +if [[ -z "$NPM_TOKEN" ]]; then + echo "Must provide NPM_TOKEN" 1>&2 + exit 1 +fi + SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" SOURCE_ROOT="$1" @@ -44,17 +63,6 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then NPM_TAG="dev" - # We use the "features/" and "feature-" prefix on branches that we want to build and publish for - # doing cross repo work. But in this case, we don't want to publish over "dev", since the bits - # could be totally busted and the dev tag tracks master. - if [[ "${TRAVIS_BRANCH:-}" == features/* ]]; then - NPM_TAG=$(echo "${TRAVIS_BRANCH}" | sed -e 's|^features/|feature-|g') - fi - - if [[ "${TRAVIS_BRANCH:-}" == feature-* ]]; then - NPM_TAG=$(echo "${TRAVIS_BRANCH}") - fi - # If the package doesn't have a pre-release tag, use the tag of latest instead of # dev. NPM uses this tag as the default version to add, so we want it to mean # the newest released version. @@ -91,17 +99,12 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then mv package.json.dev package.json popd - # Next, publish the PyPI package, if we didn't opt out - if [ -n "${NO_TFGEN_PYTHON_PACKAGE}" ] ; then - echo "Skipping publishing pip package because of NO_TFGEN_PYTHON_PACKAGE" - else - echo "Publishing Pip package to pypi:" - twine upload \ - -u "${PYPI_USERNAME}" -p "${PYPI_PASSWORD}" \ - "${SOURCE_ROOT}/sdk/python/bin/dist/*.tar.gz" \ + echo "Publishing Pip package to pypi:" + twine upload \ + -u "${PYPI_USERNAME}" -p "${PYPI_PASSWORD}" \ + "${SOURCE_ROOT}/sdk/python/bin/dist/*.tar.gz" \ --skip-existing \ - --verbose - fi + --verbose # Finally, publish the NuGet package if any exists. if [ -n "${NUGET_PUBLISH_KEY}" ]; then From c8eb8c46e065eab2909681e2005492b3912475f0 Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Tue, 4 Jan 2022 20:04:25 -0800 Subject: [PATCH 04/13] use xargs for nuget publish --- ci/publish-tfgen-package | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/publish-tfgen-package b/ci/publish-tfgen-package index 65e9147..fd4421b 100755 --- a/ci/publish-tfgen-package +++ b/ci/publish-tfgen-package @@ -121,7 +121,7 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then # Finally, publish the NuGet package if any exists. if [ -n "${NUGET_PUBLISH_KEY}" ]; then - find "${SOURCE_ROOT}/sdk/dotnet/bin/Debug/" -name 'Pulumi.*.nupkg' \ - -exec dotnet nuget push -k "${NUGET_PUBLISH_KEY}" -s https://api.nuget.org/v3/index.json {} ';' + find "${SOURCE_ROOT}/sdk/dotnet/bin/Debug/" -name 'Pulumi.*.nupkg' | \ + xargs dotnet nuget push -k "${NUGET_PUBLISH_KEY}" -s https://api.nuget.org/v3/index.json fi fi From 53e2b571f04225b5a70eea6ff88fbd12adeb4922 Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Tue, 4 Jan 2022 20:06:01 -0800 Subject: [PATCH 05/13] remove --server flag --- ci/add-plugin-installer-script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/add-plugin-installer-script.js b/ci/add-plugin-installer-script.js index 5fed515..1d75d34 100644 --- a/ci/add-plugin-installer-script.js +++ b/ci/add-plugin-installer-script.js @@ -37,7 +37,7 @@ stdin.on("close", function() { if (name.lastIndexOf("/") !== -1) { name = name.substring(name.lastIndexOf("/")+1); } - packageJSON.scripts["install"] = `node scripts/install-pulumi-plugin.js resource ${name} --server ${packageJSON.repository}/releases/download/${packageJSON.version} ${packageJSON.version}`; + packageJSON.scripts["install"] = `node scripts/install-pulumi-plugin.js resource ${name} ${packageJSON.version}`; // Now print out the result to stdout. console.log(JSON.stringify(packageJSON, null, 4)); From de8e95bb73b82bc59f4a253f16d0d466f67cf970 Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Wed, 5 Jan 2022 10:37:47 -0800 Subject: [PATCH 06/13] support 3rd party plugins --- ci/add-plugin-installer-script.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ci/add-plugin-installer-script.js b/ci/add-plugin-installer-script.js index 1d75d34..2e6fea8 100644 --- a/ci/add-plugin-installer-script.js +++ b/ci/add-plugin-installer-script.js @@ -33,11 +33,19 @@ stdin.on("close", function() { if (!packageJSON.scripts) { packageJSON.scripts = {}; } + + var args; + + if (packageJSON.pulumi.pluginDownloadURL) { + args = `resource ${name} --server ${packageJSON.pulumi.pluginDownloadURL} ${packageJSON.version}` + } else { + args = `resource ${name} ${packageJSON.version}` + } var name = packageJSON.name; if (name.lastIndexOf("/") !== -1) { name = name.substring(name.lastIndexOf("/")+1); } - packageJSON.scripts["install"] = `node scripts/install-pulumi-plugin.js resource ${name} ${packageJSON.version}`; + packageJSON.scripts["install"] = `node scripts/install-pulumi-plugin.js ${args}`; // Now print out the result to stdout. console.log(JSON.stringify(packageJSON, null, 4)); From 0b9c4b690ffd892281208ab91d33d5e666d5b25e Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Thu, 6 Jan 2022 13:22:45 -0800 Subject: [PATCH 07/13] rework order for name --- ci/add-plugin-installer-script.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ci/add-plugin-installer-script.js b/ci/add-plugin-installer-script.js index 2e6fea8..e0136ce 100644 --- a/ci/add-plugin-installer-script.js +++ b/ci/add-plugin-installer-script.js @@ -34,17 +34,18 @@ stdin.on("close", function() { packageJSON.scripts = {}; } - var args; + var name = packageJSON.name; + if (name.lastIndexOf("/") !== -1) { + name = name.substring(name.lastIndexOf("/")+1); + } + var args; if (packageJSON.pulumi.pluginDownloadURL) { args = `resource ${name} --server ${packageJSON.pulumi.pluginDownloadURL} ${packageJSON.version}` } else { args = `resource ${name} ${packageJSON.version}` } - var name = packageJSON.name; - if (name.lastIndexOf("/") !== -1) { - name = name.substring(name.lastIndexOf("/")+1); - } + packageJSON.scripts["install"] = `node scripts/install-pulumi-plugin.js ${args}`; // Now print out the result to stdout. From c16ad01d815471cfcfc085151281a20aa323f8a2 Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Thu, 6 Jan 2022 16:51:52 -0800 Subject: [PATCH 08/13] remove dashes from name --- ci/add-plugin-installer-script.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/add-plugin-installer-script.js b/ci/add-plugin-installer-script.js index e0136ce..8aca36e 100644 --- a/ci/add-plugin-installer-script.js +++ b/ci/add-plugin-installer-script.js @@ -38,6 +38,9 @@ stdin.on("close", function() { if (name.lastIndexOf("/") !== -1) { name = name.substring(name.lastIndexOf("/")+1); } + if (name.lastIndexOf("-") !== -1) { + name = name.substring(name.lastIndexOf("-")+1); + } var args; if (packageJSON.pulumi.pluginDownloadURL) { From fa8c10948ccb9cc99842b6e7c60a6434eb298b45 Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Wed, 24 Aug 2022 12:42:22 -0700 Subject: [PATCH 09/13] publish any found nuget pkg --- ci/publish-tfgen-package | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/publish-tfgen-package b/ci/publish-tfgen-package index fd4421b..bfc2c5f 100755 --- a/ci/publish-tfgen-package +++ b/ci/publish-tfgen-package @@ -121,7 +121,7 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then # Finally, publish the NuGet package if any exists. if [ -n "${NUGET_PUBLISH_KEY}" ]; then - find "${SOURCE_ROOT}/sdk/dotnet/bin/Debug/" -name 'Pulumi.*.nupkg' | \ + find "${SOURCE_ROOT}/sdk/dotnet/bin/Debug/" -name '*.*.nupkg' | \ xargs dotnet nuget push -k "${NUGET_PUBLISH_KEY}" -s https://api.nuget.org/v3/index.json fi fi From 366fb10f45d2878c3f6cc7ddb16bbc5e625f3eed Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Tue, 13 Sep 2022 08:50:32 -0700 Subject: [PATCH 10/13] add thirdparty server support --- ci/add-plugin-installer-script.js | 6 +++++- ci/publish-tfgen-package | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ci/add-plugin-installer-script.js b/ci/add-plugin-installer-script.js index 8aca36e..26f8c22 100644 --- a/ci/add-plugin-installer-script.js +++ b/ci/add-plugin-installer-script.js @@ -43,8 +43,12 @@ stdin.on("close", function() { } var args; - if (packageJSON.pulumi.pluginDownloadURL) { + + + if (packageJSON.pulumi.pluginDownloadURL) { args = `resource ${name} --server ${packageJSON.pulumi.pluginDownloadURL} ${packageJSON.version}` + } else if (packageJSON.pulumi.server) { + args = `resource ${name} --server ${packageJSON.pulumi.server} ${packageJSON.version}` } else { args = `resource ${name} ${packageJSON.version}` } diff --git a/ci/publish-tfgen-package b/ci/publish-tfgen-package index bfc2c5f..3cc975e 100755 --- a/ci/publish-tfgen-package +++ b/ci/publish-tfgen-package @@ -32,8 +32,10 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then # First, add an install script to our package.json mkdir -p "${SOURCE_ROOT}/sdk/nodejs/bin/scripts" - cp "${SCRIPT_ROOT}/install-pulumi-plugin.js" \ - "${SOURCE_ROOT}/sdk/nodejs/bin/scripts" + if [ ! "${SOURCE_ROOT}/sdk/nodejs/bin/scripts/install-pulumi-plugin.js" ]; then + cp "${SCRIPT_ROOT}/install-pulumi-plugin.js" \ + "${SOURCE_ROOT}/sdk/nodejs/bin/scripts" + fi node "${SCRIPT_ROOT}/add-plugin-installer-script.js" < \ "${SOURCE_ROOT}/sdk/nodejs/bin/package.json" > \ "${SOURCE_ROOT}/sdk/nodejs/bin/package.json.publish" From 0b6125d58de59dc5aaaf7bcbdf582f909559bcda Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Sat, 17 Sep 2022 13:26:15 -0700 Subject: [PATCH 11/13] attempt to fix publish issues --- ci/publish-tfgen-package | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/publish-tfgen-package b/ci/publish-tfgen-package index 3cc975e..3a8575b 100755 --- a/ci/publish-tfgen-package +++ b/ci/publish-tfgen-package @@ -11,6 +11,7 @@ set -o errexit set -o pipefail +set -x if [ "$#" -ne 1 ]; then >&2 echo "usage: $0 " @@ -42,6 +43,7 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then pushd "${SOURCE_ROOT}/sdk/nodejs/bin" mv package.json package.json.dev mv package.json.publish package.json + cat package.json NPM_TAG="dev" From f2e394a8d78e63e70f4397dd5de1166fe160745d Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Sat, 17 Sep 2022 13:51:43 -0700 Subject: [PATCH 12/13] debug adding installer script --- ci/publish-tfgen-package | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/publish-tfgen-package b/ci/publish-tfgen-package index 3a8575b..fc2a1c5 100755 --- a/ci/publish-tfgen-package +++ b/ci/publish-tfgen-package @@ -11,7 +11,6 @@ set -o errexit set -o pipefail -set -x if [ "$#" -ne 1 ]; then >&2 echo "usage: $0 " @@ -33,7 +32,8 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then # First, add an install script to our package.json mkdir -p "${SOURCE_ROOT}/sdk/nodejs/bin/scripts" - if [ ! "${SOURCE_ROOT}/sdk/nodejs/bin/scripts/install-pulumi-plugin.js" ]; then + if [ ! -f "${SOURCE_ROOT}/sdk/nodejs/bin/scripts/install-pulumi-plugin.js" ]; then + echo "Didn't find existing plugin plugin installer" cp "${SCRIPT_ROOT}/install-pulumi-plugin.js" \ "${SOURCE_ROOT}/sdk/nodejs/bin/scripts" fi From 0f248b03a2ecfd70ac4c9a39fb967b180ee20b45 Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Mon, 26 Sep 2022 09:59:59 -0700 Subject: [PATCH 13/13] always use public access --- ci/publish-tfgen-package | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/publish-tfgen-package b/ci/publish-tfgen-package index fc2a1c5..809eb92 100755 --- a/ci/publish-tfgen-package +++ b/ci/publish-tfgen-package @@ -88,7 +88,7 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then # We exploit the fact that `npm info @` has no output # when the package does not exist. if [ "$(npm info ${PKG_NAME}@${PKG_VERSION})" == "" ]; then - if ! npm publish -tag "${NPM_TAG}"; then + if ! npm publish --access public -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