Skip to content

Makefile migration: make publish-sdks #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,23 @@ lint::
--path-prefix $(pkg)) \
&&) true

# Publish SDKs to NuGet
publish-sdks::
@echo "Publishing Pulumi SDKs to NuGet"
@if [ -z "$$NUGET_PUBLISH_KEY" ]; then echo "Missing NUGET_PUBLISH_KEY" && exit 1; fi
@if [ -z "$$PULUMI_VERSION" ]; then echo "Missing PULUMI_VERSION" && exit 1; fi
$(eval SDK_VERSION := $(shell cd pulumi-language-dotnet && grep -oP 'github.com/pulumi/pulumi/sdk/v3 v\K[0-9.]+' go.mod))
for project in Pulumi Pulumi.Automation Pulumi.FSharp; do \
PKG_EXISTS=$$(curl -s "https://api.nuget.org/v3-flatcontainer/$$project/index.json" | jq -e ".versions | index(\"$$PULUMI_VERSION\")" > /dev/null 2>&1 && echo yes || echo no); \
if [ "$$PKG_EXISTS" = "yes" ]; then \
echo "$$project $$PULUMI_VERSION already published, skipping"; \
else \
echo "Publishing $$project $$PULUMI_VERSION"; \
cd sdk/$$project && dotnet build --configuration Release -p:Version=$$PULUMI_VERSION -p:PulumiSdkVersion=$(SDK_VERSION); \
PKG_FILE=$$(ls bin/Release/*.nupkg | head -n1); \
dotnet nuget push $$PKG_FILE -s https://api.nuget.org/v3/index.json -k $$NUGET_PUBLISH_KEY; \
cd -; \
fi; \
done

.PHONY: install build
38 changes: 0 additions & 38 deletions build/Nuget.fs

This file was deleted.

36 changes: 5 additions & 31 deletions build/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -107,37 +107,11 @@ let buildSdk() =
/// When publishing, we check whether the package we are about to publish already exists on Nuget
/// and if that is the case, we skip it.
let publishSdks() =
// prepare
cleanSdk()
restoreSdk()
let projectDirs = [
pulumiSdk;
pulumiAutomationSdk;
pulumiFSharp;
]
// perform the publishing (idempotent)
let publishResults = publishSdks projectDirs pulumiLanguageDotnet

match publishResults with
| Error errorMsg -> printfn $"{errorMsg}"
| Ok results ->
for result in results do
match result with
| PublishResult.Ok project ->
printfn $"Project '{projectName project}' has been published"
| PublishResult.Failed(project, error) ->
printfn $"Project '{projectName project}' failed to publish the nuget package: {error}"
| PublishResult.AlreadyPublished project ->
printfn $"Project '{projectName project}' has already been published"

let anyProjectFailed = results |> List.exists (fun result -> result.HasErrored())
if anyProjectFailed then
let failedProjectsAtPublishing =
results
|> List.where (fun result -> result.HasErrored())
|> List.map (fun result -> result.ProjectName())

failwith $"Some nuget packages were not published: {failedProjectsAtPublishing}"
printfn "Deprecated: calling `make publish-sdks` instead"
let cmd = Cli.Wrap("make").WithArguments("publish-sdks").WithWorkingDirectory(repositoryRoot)
let output = cmd.ExecuteAsync().GetAwaiter().GetResult()
if output.ExitCode <> 0 then
failwith "publish-sdks failed"

let cleanLanguagePlugin() =
let plugin = Path.Combine(pulumiLanguageDotnet, "pulumi-language-dotnet")
Expand Down
Loading