2017-09-23 02:51:59 +02:00
|
|
|
# make_release.ps1 will create a build package ready for publishing.
|
|
|
|
Set-StrictMode -Version 2.0
|
|
|
|
$ErrorActionPreference="Stop"
|
|
|
|
|
|
|
|
$Root=Join-Path $PSScriptRoot ".."
|
|
|
|
$PublishDir=New-Item -ItemType Directory -Path "$env:TEMP\$([System.IO.Path]::GetRandomFileName())"
|
2017-11-02 23:02:43 +01:00
|
|
|
$GitHash=$(git rev-parse HEAD)
|
|
|
|
$PublishFile="$(Split-Path -Parent -Path $PublishDir)\$GitHash.zip"
|
2018-03-17 00:36:27 +01:00
|
|
|
$Version = $( & "$PSScriptRoot\get-version.cmd")
|
2017-09-23 02:51:59 +02:00
|
|
|
$Branch = $(if (Test-Path env:APPVEYOR_REPO_BRANCH) { $env:APPVEYOR_REPO_BRANCH } else { $(git rev-parse --abbrev-ref HEAD) })
|
2017-11-02 23:02:43 +01:00
|
|
|
$PublishTargets = @($GitHash, $Version, $Branch)
|
2017-09-23 02:51:59 +02:00
|
|
|
|
2020-03-27 19:59:13 +01:00
|
|
|
function RunGoBuild($goPackage, $dir, $outputName) {
|
2017-09-23 02:51:59 +02:00
|
|
|
$binRoot = New-Item -ItemType Directory -Force -Path "$PublishDir\bin"
|
2020-03-26 01:58:05 +01:00
|
|
|
Push-Location $dir
|
2020-04-14 10:30:25 +02:00
|
|
|
go build -ldflags "-X github.com/pulumi/pulumi/pkg/v2/version.Version=$Version" -o "$binRoot\$outputName" $goPackage
|
2020-03-26 01:58:05 +01:00
|
|
|
Pop-Location
|
2017-09-23 02:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function CopyPackage($pathToModule, $moduleName) {
|
|
|
|
$moduleRoot = New-Item -ItemType Directory -Force -Path "$PublishDir\node_modules\$moduleName"
|
|
|
|
Copy-Item -Recurse $pathToModule\* $moduleRoot
|
2017-12-05 01:36:12 +01:00
|
|
|
if (Test-Path "$moduleRoot\node_modules") {
|
2017-09-23 02:51:59 +02:00
|
|
|
Remove-Item -Recurse -Force "$moduleRoot\node_modules"
|
|
|
|
}
|
2017-12-05 01:36:12 +01:00
|
|
|
if (Test-Path "$moduleRoot\tests") {
|
|
|
|
Remove-Item -Recurse -Force "$moduleRoot\tests"
|
|
|
|
}
|
2017-09-23 02:51:59 +02:00
|
|
|
}
|
|
|
|
|
2020-04-14 10:30:25 +02:00
|
|
|
RunGoBuild "github.com/pulumi/pulumi/pkg/v2/cmd/pulumi" "pkg" "pulumi.exe"
|
|
|
|
RunGoBuild "github.com/pulumi/pulumi/sdk/v2/nodejs/cmd/pulumi-language-nodejs" "sdk" "pulumi-language-nodejs.exe"
|
|
|
|
RunGoBuild "github.com/pulumi/pulumi/sdk/v2/python/cmd/pulumi-language-python" "sdk" "pulumi-language-python.exe"
|
|
|
|
RunGoBuild "github.com/pulumi/pulumi/sdk/v2/dotnet/cmd/pulumi-language-dotnet" "sdk" "pulumi-language-dotnet.exe"
|
|
|
|
RunGoBuild "github.com/pulumi/pulumi/sdk/v2/go/pulumi-language-go" "sdk" "pulumi-language-go.exe"
|
2017-09-23 02:51:59 +02:00
|
|
|
CopyPackage "$Root\sdk\nodejs\bin" "pulumi"
|
|
|
|
|
2018-02-18 17:11:14 +01:00
|
|
|
Copy-Item "$Root\sdk\nodejs\dist\pulumi-resource-pulumi-nodejs.cmd" "$PublishDir\bin"
|
2020-12-08 00:58:30 +01:00
|
|
|
Copy-Item "$Root\sdk\python\dist\pulumi-python-shim.cmd" "$PublishDir\bin"
|
|
|
|
Copy-Item "$Root\sdk\python\dist\pulumi-python3-shim.cmd" "$PublishDir\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
|
|
|
Copy-Item "$Root\sdk\python\dist\pulumi-resource-pulumi-python.cmd" "$PublishDir\bin"
|
2019-08-30 02:38:40 +02:00
|
|
|
Copy-Item "$Root\sdk\nodejs\dist\pulumi-analyzer-policy.cmd" "$PublishDir\bin"
|
2020-03-19 00:15:57 +01:00
|
|
|
Copy-Item "$Root\sdk\python\dist\pulumi-analyzer-policy-python.cmd" "$PublishDir\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
|
|
|
Copy-Item "$Root\sdk\python\cmd\pulumi-language-python-exec" "$PublishDir\bin"
|
2018-02-16 01:08:06 +01:00
|
|
|
|
2017-09-23 02:51:59 +02:00
|
|
|
# By default, if the archive already exists, 7zip will just add files to it, so blow away the existing
|
|
|
|
# archive if it exists.
|
|
|
|
if (Test-Path $PublishFile) {
|
|
|
|
Remove-Item -Force $PublishFile
|
|
|
|
}
|
|
|
|
|
|
|
|
7z a "$PublishFile" "$PublishDir\." | Out-Null
|
|
|
|
|
|
|
|
Remove-Item -Recurse -Force $PublishDir
|
|
|
|
|
|
|
|
New-Object PSObject -Property @{ArchivePath=$PublishFile;Targets=$PublishTargets}
|