Skip to content
Open
18 changes: 17 additions & 1 deletion ci/add-plugin-installer-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,27 @@ stdin.on("close", function() {
if (!packageJSON.scripts) {
packageJSON.scripts = {};
}

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}`;
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 if (packageJSON.pulumi.server) {
args = `resource ${name} --server ${packageJSON.pulumi.server} ${packageJSON.version}`
} else {
args = `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));
Expand Down
14 changes: 9 additions & 5 deletions ci/publish-tfgen-package
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ 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 [ ! -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
node "${SCRIPT_ROOT}/add-plugin-installer-script.js" < \
"${SOURCE_ROOT}/sdk/nodejs/bin/package.json" > \
"${SOURCE_ROOT}/sdk/nodejs/bin/package.json.publish"
pushd "${SOURCE_ROOT}/sdk/nodejs/bin"
mv package.json package.json.dev
mv package.json.publish package.json
cat package.json

NPM_TAG="dev"

Expand Down Expand Up @@ -84,7 +88,7 @@ if [[ "${TRAVIS_OS_NAME:-}" == "linux" ]]; then
# We exploit the fact that `npm info <package-name>@<package-version>` 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
Expand Down Expand Up @@ -121,7 +125,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 '*.*.nupkg' | \
xargs dotnet nuget push -k "${NUGET_PUBLISH_KEY}" -s https://api.nuget.org/v3/index.json
fi
fi