pulumi/scripts/make_release.sh

72 lines
2.4 KiB
Bash
Raw Normal View History

#!/bin/bash
# make_release.sh will create a build package ready for publishing.
2018-09-03 18:49:57 +02:00
set -o nounset
set -o errexit
set -o pipefail
2018-09-03 18:49:57 +02:00
readonly ROOT=$(dirname "${0}")/..
readonly PUBDIR=$(mktemp -d)
2018-09-03 18:49:57 +02:00
readonly GITHASH=$(git rev-parse HEAD)
readonly PUBFILE=$(dirname "${PUBDIR})/${GITHASH}.tgz")
readonly VERSION=$("${ROOT}/scripts/get-version" HEAD)
# Figure out which branch we're on. Prefer $TRAVIS_BRANCH, if set, since
# Travis leaves us at detached HEAD and `git rev-parse` just returns "HEAD".
2018-09-03 18:49:57 +02:00
readonly BRANCH=${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}
declare -a PUBTARGETS=(${GITHASH} ${VERSION} ${BRANCH})
# usage: run_go_build <path-to-package-to-build>
2018-09-03 18:49:57 +02:00
run_go_build() {
local bin_suffix=""
2018-09-03 18:49:57 +02:00
local -r output_name=$(basename $(cd "${1}" ; pwd))
if [ "$(go env GOOS)" = "windows" ]; then
bin_suffix=".exe"
fi
mkdir -p "${PUBDIR}/bin"
pushd "$2" > /dev/null && go build \
-ldflags "-X github.com/pulumi/pulumi/pkg/version.Version=${VERSION}" \
-o "${PUBDIR}/bin/${output_name}${bin_suffix}" \
"$1"
popd > /dev/null
}
# usage: copy_package <path-to-module> <module-name>
copy_package() {
2018-09-03 18:49:57 +02:00
local -r module_root="${PUBDIR}/node_modules/${2}"
2018-09-12 02:14:58 +02:00
mkdir -p "${module_root}"
cp -r "${1}" "${module_root}/"
2018-09-03 18:49:57 +02:00
if [[ -e "${module_root}/node_modules" ]]; then
rm -rf "${module_root}/node_modules"
fi
2018-09-03 18:49:57 +02:00
if [[ -e "${module_root}/tests" ]]; then
rm -rf "${module_root}/tests"
fi
}
readonly PULUMI_ROOT=$PWD
# Build binaries
run_go_build "${PULUMI_ROOT}/pkg/cmd/pulumi" "pkg"
run_go_build "${PULUMI_ROOT}/sdk/nodejs/cmd/pulumi-language-nodejs" "sdk"
run_go_build "${PULUMI_ROOT}/sdk/python/cmd/pulumi-language-python" "sdk"
run_go_build "${PULUMI_ROOT}/sdk/dotnet/cmd/pulumi-language-dotnet" "sdk"
run_go_build "${PULUMI_ROOT}/sdk/go/pulumi-language-go" "sdk"
2018-03-17 18:41:37 +01:00
# Copy over the language and dynamic resource providers.
2018-09-03 18:49:57 +02:00
cp "${ROOT}/sdk/nodejs/dist/pulumi-resource-pulumi-nodejs" "${PUBDIR}/bin/"
Python Dynamic Providers (#2900) Dynamic providers in Python. This PR uses [dill](https://pypi.org/project/dill/) for code serialization, along with a customization to help ensure deterministic serialization results. One notable limitation - which I believe is a general requirement of Python - is that any serialization of Python functions must serialize byte code, and byte code is not safely versioned across Python versions. So any resource created with Python `3.x.y` can only be updated by exactly the same version of Python. This is very constraining, but it's not clear there is any other option within the realm of what "dynamic providers" are as a feature. It is plausible that we could ensure that updates which only update the serialized provider can avoid calling the dynamic provider operations, so that version updates could still be accomplished. We can explore this separately. ```py from pulumi import ComponentResource, export, Input, Output from pulumi.dynamic import Resource, ResourceProvider, CreateResult, UpdateResult from typing import Optional from github import Github, GithubObject auth = "<auth token>" g = Github(auth) class GithubLabelArgs(object): owner: Input[str] repo: Input[str] name: Input[str] color: Input[str] description: Optional[Input[str]] def __init__(self, owner, repo, name, color, description=None): self.owner = owner self.repo = repo self.name = name self.color = color self.description = description class GithubLabelProvider(ResourceProvider): def create(self, props): l = g.get_user(props["owner"]).get_repo(props["repo"]).create_label( name=props["name"], color=props["color"], description=props.get("description", GithubObject.NotSet)) return CreateResult(l.name, {**props, **l.raw_data}) def update(self, id, _olds, props): l = g.get_user(props["owner"]).get_repo(props["repo"]).get_label(id) l.edit(name=props["name"], color=props["color"], description=props.get("description", GithubObject.NotSet)) return UpdateResult({**props, **l.raw_data}) def delete(self, id, props): l = g.get_user(props["owner"]).get_repo(props["repo"]).get_label(id) l.delete() class GithubLabel(Resource): name: Output[str] color: Output[str] url: Output[str] description: Output[str] def __init__(self, name, args: GithubLabelArgs, opts = None): full_args = {'url':None, 'description':None, 'name':None, 'color':None, **vars(args)} super().__init__(GithubLabelProvider(), name, full_args, opts) label = GithubLabel("foo", GithubLabelArgs("lukehoban", "todo", "mylabel", "d94f0b")) export("label_color", label.color) export("label_url", label.url) ``` Fixes https://github.com/pulumi/pulumi/issues/2902.
2019-07-19 19:18:25 +02:00
cp "${ROOT}/sdk/python/dist/pulumi-resource-pulumi-python" "${PUBDIR}/bin/"
cp "${ROOT}/sdk/nodejs/dist/pulumi-analyzer-policy" "${PUBDIR}/bin/"
cp "${ROOT}/sdk/python/dist/pulumi-analyzer-policy-python" "${PUBDIR}/bin/"
2018-09-03 18:49:57 +02:00
cp "${ROOT}/sdk/python/cmd/pulumi-language-python-exec" "${PUBDIR}/bin/"
# Copy packages
copy_package "${ROOT}/sdk/nodejs/bin/." "@pulumi/pulumi"
# Tar up the file and then print it out for use by the caller or script.
2018-09-03 18:49:57 +02:00
tar -czf "${PUBFILE}" -C ${PUBDIR} .
echo ${PUBFILE} ${PUBTARGETS[@]}
2018-09-03 18:49:57 +02:00
exit 0