Skip to content

Commit f6fe7b3

Browse files
committed
Make it so
1 parent db6ed46 commit f6fe7b3

File tree

3 files changed

+37
-70
lines changed

3 files changed

+37
-70
lines changed

Makefile

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ SDK_VERSION := $(shell cd pulumi-language-dotnet && sed -n 's/^.*github\.com\/pu
66

77
GO_TEST_FILTER_FLAG := $(if $(TEST_FILTER),-run $(TEST_FILTER))
88
DOTNET_TEST_FILTER_FLAG := $(if $(TEST_FILTER),--filter $(TEST_FILTER))
9+
RELEASE_VERSION_FLAG := $(if $(PULUMI_VERSION),-p:Version=$(PULUMI_VERSION))
10+
911

1012
.PHONY: install
1113
install:
@@ -17,7 +19,7 @@ build: build_sdk build_language_host
1719

1820
.PHONY: build_sdk
1921
build_sdk:
20-
cd sdk && dotnet build --configuration Release -p:PulumiSdkVersion=$(SDK_VERSION)
22+
cd sdk && dotnet build --configuration Release -p:PulumiSdkVersion=$(SDK_VERSION) $(RELEASE_VERSION_FLAG)
2123

2224
.PHONY: build_language_host
2325
build_language_host:
@@ -98,6 +100,25 @@ lint_integration_tests: format_integration_tests_check
98100
lint_integration_tests_fix: format_integration_tests
99101
cd integration_tests && golangci-lint run $(GOLANGCI_LINT_ARGS) --fix --config ../.golangci.yml --timeout 5m --path-prefix integration_tests
100102

103+
.PHONY: publish
104+
publish: check_publish_credentials build
105+
$(MAKE) publish_package PACKAGE=Pulumi
106+
$(MAKE) publish_package PACKAGE=Pulumi.Automation
107+
$(MAKE) publish_package PACKAGE=Pulumi.FSharp
108+
109+
.PHONY: publish_package
110+
publish_package: check_publish_credentials build
111+
if nuget list $(PACKAGE) -AllVersions | grep -q '^$(PACKAGE) $(PULUMI_VERSION)$$'; then \
112+
echo "$(PACKAGE) $(PULUMI_VERSION) already published, skipping..."; \
113+
exit 0; \
114+
else \
115+
cd sdk/$(PACKAGE); \
116+
PKG_FILE=$$(ls bin/Release/*.nupkg | head -n1); \
117+
dotnet nuget push $$PKG_FILE \
118+
-s https://api.nuget.org/v3/index.json \
119+
-k $(NUGET_PUBLISH_KEY); \
120+
fi
121+
101122
.PHONY: test
102123
test: test_conformance test_integration test_sdk test_sdk_automation
103124

@@ -139,3 +160,13 @@ test_sdk_automation_coverage: clean
139160
-p:CollectCoverage=true \
140161
-p:CoverletOutputFormat=cobertura \
141162
-p:CoverletOutput=./coverage/coverage.pulumi.automation.xml
163+
164+
.PHONY: check_publish_credentials
165+
check_publish_credentials:
166+
if [ -z "$$NUGET_PUBLISH_KEY" ]; then \
167+
echo "Missing NUGET_PUBLISH_KEY" && exit 1; \
168+
fi
169+
if [ -z "$$PULUMI_VERSION" ]; then \
170+
echo "Missing PULUMI_VERSION" && exit 1; \
171+
fi
172+

build/Nuget.fs

Lines changed: 0 additions & 38 deletions
This file was deleted.

build/Program.fs

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -90,37 +90,11 @@ let buildSdk() =
9090
/// When publishing, we check whether the package we are about to publish already exists on Nuget
9191
/// and if that is the case, we skip it.
9292
let publishSdks() =
93-
// prepare
94-
cleanSdk()
95-
restoreSdk()
96-
let projectDirs = [
97-
pulumiSdk;
98-
pulumiAutomationSdk;
99-
pulumiFSharp;
100-
]
101-
// perform the publishing (idempotent)
102-
let publishResults = publishSdks projectDirs pulumiLanguageDotnet
103-
104-
match publishResults with
105-
| Error errorMsg -> printfn $"{errorMsg}"
106-
| Ok results ->
107-
for result in results do
108-
match result with
109-
| PublishResult.Ok project ->
110-
printfn $"Project '{projectName project}' has been published"
111-
| PublishResult.Failed(project, error) ->
112-
printfn $"Project '{projectName project}' failed to publish the nuget package: {error}"
113-
| PublishResult.AlreadyPublished project ->
114-
printfn $"Project '{projectName project}' has already been published"
115-
116-
let anyProjectFailed = results |> List.exists (fun result -> result.HasErrored())
117-
if anyProjectFailed then
118-
let failedProjectsAtPublishing =
119-
results
120-
|> List.where (fun result -> result.HasErrored())
121-
|> List.map (fun result -> result.ProjectName())
122-
123-
failwith $"Some nuget packages were not published: {failedProjectsAtPublishing}"
93+
printfn "Deprecated: calling `make publish-sdks` instead"
94+
let cmd = Cli.Wrap("make").WithArguments("publish-sdks").WithWorkingDirectory(repositoryRoot)
95+
let output = cmd.ExecuteAsync().GetAwaiter().GetResult()
96+
if output.ExitCode <> 0 then
97+
failwith "publish-sdks failed"
12498

12599
let cleanLanguagePlugin() =
126100
let plugin = Path.Combine(pulumiLanguageDotnet, "pulumi-language-dotnet")

0 commit comments

Comments
 (0)