Skip to content
Merged
Changes from 1 commit
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
24 changes: 19 additions & 5 deletions dotnet/private/nuget_push.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def _nuget_push_impl(ctx):
else:
script = _create_unix_script(ctx, dotnet, nupkg_files)

runfiles = ctx.runfiles(files = nupkg_files).merge(toolchain.runtime.default_runfiles)
runfiles = ctx.runfiles(files = nupkg_files + [dotnet])
runfiles = runfiles.merge(toolchain.runtime.default_runfiles)

return [
DefaultInfo(
Expand All @@ -27,15 +28,28 @@ def _create_unix_script(ctx, dotnet, nupkg_files):
push_commands = []
for nupkg in nupkg_files:
push_commands.append(
'"$DOTNET" nuget push "%s" --api-key "$NUGET_API_KEY" --source "$NUGET_SOURCE"' % nupkg.short_path,
'"$DOTNET" nuget push "$RUNFILES_DIR/_main/{nupkg}" --api-key "$NUGET_API_KEY" --source "$NUGET_SOURCE" --skip-duplicate --no-symbols'.format(nupkg = nupkg.short_path),
Comment thread
titusfortner marked this conversation as resolved.
Outdated
Comment thread
titusfortner marked this conversation as resolved.
Outdated
)

# External repos in bzlmod have paths like ../repo_name/path, which in runfiles becomes repo_name/path
dotnet_runfiles_path = dotnet.short_path.lstrip("../")
Comment thread
titusfortner marked this conversation as resolved.
Outdated

script_content = """#!/usr/bin/env bash
set -euo pipefail
Comment thread
titusfortner marked this conversation as resolved.
DOTNET="$(cd "$(dirname "$0")" && pwd)/{dotnet}"

# Locate runfiles directory
if [[ -d "$0.runfiles/_main" ]]; then
RUNFILES_DIR="$0.runfiles"
elif [[ -n "${{RUNFILES_DIR:-}}" ]]; then
RUNFILES_DIR="$RUNFILES_DIR"
else
RUNFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
Comment thread
titusfortner marked this conversation as resolved.
Outdated
fi

DOTNET="$RUNFILES_DIR/{dotnet}"
{push_commands}
""".format(
dotnet = dotnet.short_path,
dotnet = dotnet_runfiles_path,
push_commands = "\n".join(push_commands),
)

Expand All @@ -53,7 +67,7 @@ def _create_windows_script(ctx, dotnet, nupkg_files):
for nupkg in nupkg_files:
nupkg_path = nupkg.short_path.replace("/", "\\")
push_commands.append(
'"%%DOTNET%%" nuget push "%s" --api-key "%%NUGET_API_KEY%%" --source "%%NUGET_SOURCE%%"' % nupkg_path,
'"%%DOTNET%%" nuget push "%s" --api-key "%%NUGET_API_KEY%%" --source "%%NUGET_SOURCE%%" --skip-duplicate --no-symbols' % nupkg_path,
Comment thread
titusfortner marked this conversation as resolved.
Outdated
)
push_commands.append("if %%ERRORLEVEL%% neq 0 exit /b %%ERRORLEVEL%%")

Expand Down