Skip to content
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

Support nuget snupkg artifacts #458

Merged
merged 4 commits into from
Feb 8, 2023
Merged
Changes from 2 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
17 changes: 16 additions & 1 deletion src/targets/nuget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const DEFAULT_NUGET_SERVER_URL = 'https://api.nuget.org/v3/index.json';

/** A regular expression used to find the package tarball */
const DEFAULT_NUGET_REGEX = /^.*\d\.\d.*\.nupkg$/;
const SYMBOLS_NUGET_REGEX = /^.*\d\.\d.*\.snupkg$/;

/** Nuget target configuration options */
export interface NugetTargetOptions {
Expand Down Expand Up @@ -87,6 +88,9 @@ export class NugetTarget extends BaseTarget {
const packageFiles = await this.getArtifactsForRevision(revision, {
includeNames: DEFAULT_NUGET_REGEX,
});
const symbolFiles = await this.getArtifactsForRevision(revision, {
includeNames: SYMBOLS_NUGET_REGEX,
});

if (!packageFiles.length) {
reportError(
Expand All @@ -106,8 +110,19 @@ export class NugetTarget extends BaseTarget {
await Promise.all(
packageFiles.map(async (file: RemoteArtifact) => {
const path = await this.artifactProvider.downloadArtifact(file);

// If an artifact containing a .snupkg file exists with the same base
// name as the .nupkg file, then download it to the same location.
// It will be picked up automatically when pushing the .nupkg.
const symbolFileName = file.filename.replace('.nupkg', '.snupkg');
mattjohnsonpint marked this conversation as resolved.
Show resolved Hide resolved
const symbolFile = symbolFiles.find(f => f.filename === symbolFileName);
if (symbolFile) {
await this.artifactProvider.downloadArtifact(symbolFile);
}

this.logger.info(
`Uploading file "${file.filename}" via "dotnet nuget"`
`Uploading file "${file.filename}" via "dotnet nuget"` +
(symbolFile ? `, including symbol file "${symbolFile.filename}"` : '')
);
return this.uploadAsset(path);
})
Expand Down