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

nuget does not appear in "additional release links" #679

Open
davhdavh opened this issue Oct 4, 2023 · 7 comments
Open

nuget does not appear in "additional release links" #679

davhdavh opened this issue Oct 4, 2023 · 7 comments

Comments

@davhdavh
Copy link

davhdavh commented Oct 4, 2023

semantic-release/github#282

https://github.com/droidsolutions/semantic-release-nuget/blob/main/src/publish.ts should return a

    return {
        name: 'Nuget',
        url: `the url to the nuget pkg`,
    }
@davhdavh
Copy link
Author

davhdavh commented Oct 4, 2023

I would make the PR for it, but there are 3 issues:

  1. What is the actual url to return?

On github the url to the released nupkg is https://github.com/xxx/yyy/pkgs/nuget/ppp/nnn with xxx/yyy being the standard org/repo and ppp is the nuget package name, and nnn is some id I have no idea where to find.

On nuget.org, link is a bit easier https://www.nuget.org/packages/ppp/vvv with ppp being package name and vvv being release tag.

In both cases however, the actual url to use has little to do with the registry url.

  1. It is only possible to return 1 link, and the publish can actually release 2 files. My suggestion is it should just give a warning if both publish options are used that only 1 link is returned.

  2. The build might create multiple nupkg files, but just 1 can be linked. Again, I think a warning is suitable.

npm just returns 1 url and only if using npmjs.org: https://github.com/semantic-release/npm/blob/master/lib/get-release-info.js

@Kampfmoehre
Copy link
Member

Kampfmoehre commented Oct 5, 2023

I guess returning an url is relatively straight forward, since we don't support GitHub package registry yet. But if we want to support #627 we get a problem and need to decide which url to return.

So for your questions:

  1. As we can assume or require that publishing to GitHub can only be done from GitHub actions (as we do with GitLab already) we could use the GITHUB_REPOSITORY environment variable which is containing both orga and repo name as stated in the docs. We probably would need that to publish the package in GitHub registry anyway and there we should also get the missing package id.
    The nuget.org link is pretty fixed, we can probably hard code this, but the package name we have to extract somehow. As with GitLab releases being done from GitLab CI we can probably ignore that case for now.
  2. The link should point to the NuGet package and ignore the symbol package
  3. I am not sure how we could handle that apart from a warning. As far as I can see the GitHub plugin is iterating over all releases and filters that to the ones with the current release name which is basically only the current release. The image of the PR indicates that there can be multiple releases (maybe from multiple plugins) so there could be a way to add more than one release somehow.
    Otherwise we could raise an issue there that we can return an array of links instead?

This may also be relevant: semantic-release/semantic-release#2123

@Kampfmoehre
Copy link
Member

Kampfmoehre commented Oct 5, 2023

I need to dig around a little bit more, maybe we can parse the output of dotnet pack somehow, extracting package name from lines that start with Successfully created package

@davhdavh
Copy link
Author

davhdavh commented Oct 6, 2023

The "cheap" workaround is simply just to make it a config setting. e.g. releaseUrl, and the user can set it to https://github.com/xxx/yyy/pkgs/nuget/ppp/${nextRelease.version} (assuming they ever add that feature it would also just work)

@Kampfmoehre
Copy link
Member

The cheap workaround is probably the only one for now, parsing the package name from dotnet pack output is doable but I am not sure if it is possible to pass this to the publish step.
The workflow would be:

  • prepare step calls dotnet pack on every given project
  • the output of dotnet pack contains the generated NuGet package files which contain Package Name and Version
  • this output could be parsed to extract the names of the packages (e.g. with Regex)
  • the parsed list must then somehow be passed to the publish step
  • the publish step publishes the packages
  • after publishing it should return url to the package, for this we would need parsed package names and versions

I am unsure if this is possible at all with Semantic Release, the prepare step could return the list of parsed packages but how/where would that be accessible in the publish step I don't know. An alternative would be to load the file list in the publish step and then parse the file names instead of dotnet pack output.

Currently no information is passed between the two steps, this relies solely on the hardcoded out directory. Prepare step passes -o out to dotnet pack which results in all packages being generated in a new created out directory. Publish step then passes out/*.nupkg to dotnet nuget push which works since dotnet nuget resolves the paths and pushes all found NuGet package files. Generally it would be nice to have that information and pass it directly from prepare to publish but I haven't found any documentation if this is possible at all and the Semantic Release code is really hard to find the correct place. I figured this may be the place where each plugin step is called: https://github.com/semantic-release/semantic-release/blob/v22.0.5/lib/plugins/pipeline.js#L38

@BinToss
Copy link

BinToss commented Apr 2, 2024

Currently no information is passed between the two steps, this relies solely on the hardcoded out directory.

dotnet msbuild -getProperty:PackageOutputPath for each project would statically evaluate the property. It would fall apart if the property is redefined in a Target.
dotnet msbuild -target:Pack -getProperty:PackageOutputPath

@BinToss
Copy link

BinToss commented Jun 24, 2024

I still don't know how to get that seemingly unique ID at the end of a package version's URL, but it should be possible to parse URLs from the Recent Versions on the package's page (e.g. https://github.com/HaloSPV3/HXE/pkgs/nuget/HXE).

<div data-view-component="true" class="Box">
	<div id="header-ef480081-b7b1-4581-ade7-b3088c7642c9" data-view-component="true" class="Box-header">
		<h3 class="f5">Recent Versions</h3>
	</div>
	<ul aria-labelledby="header-ef480081-b7b1-4581-ade7-b3088c7642c9" data-view-component="true">
		<li data-view-component="true" class="Box-row">
			<div class="d-flex">
				<div class="col-10 d-flex flex-auto flex-column" style="overflow: hidden;">
					<div class="d-inline-flex flex-auto">
						<a class="Link--primary text-bold f4" style="text-overflow: ellipsis" href="/orgs/HaloSPV3/packages/nuget/HXE/50453270">2.1.3-ci.1</a>
						<div class="flex-self-center">
							<span data-view-component="true" class="Label Label--success mx-2">Latest</span>
						</div>
					</div>
					<div class="css-truncate css-truncate-target d-block" style="max-width: 540px;">
						<div class="f6 color-fg-muted">
							Published over 2 years ago
						</div>
					</div>
				</div>
				<div class="ml-3 flex-self-center">
					<span class="color-fg-muted overflow-hidden no-wrap f6 ml-1" style="text-overflow: ellipsis; display: inline-block">
						<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-download d-inline-block v-align-bottom">
							<path d="M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"/>
							<path d="M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.969a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.78a.749.749 0 1 1 1.06-1.06l1.97 1.969Z"/>
						</svg>
          0
					</span>
				</div>
			</div>
		</li>
		<li data-view-component="true" class="Box-row">
			<div class="d-flex">
				<div class="col-10 d-flex flex-auto flex-column" style="overflow: hidden;">
					<div class="d-inline-flex flex-auto">
						<a class="Link--primary text-bold f4" style="text-overflow: ellipsis" href="/orgs/HaloSPV3/packages/nuget/HXE/50454063">2.0.1</a>
					</div>
					<div class="css-truncate css-truncate-target d-block" style="max-width: 540px;">
						<div class="f6 color-fg-muted">
							Published almost 3 years ago
						</div>
					</div>
				</div>
				<div class="ml-3 flex-self-center">
					<span class="color-fg-muted overflow-hidden no-wrap f6 ml-1" style="text-overflow: ellipsis; display: inline-block">
						<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-download d-inline-block v-align-bottom">
							<path d="M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"/>
							<path d="M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.969a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.78a.749.749 0 1 1 1.06-1.06l1.97 1.969Z"/>
						</svg>
          0
					</span>
				</div>
			</div>
		</li>
		<li data-view-component="true" class="Box-row">
			<div class="d-flex">
				<div class="col-10 d-flex flex-auto flex-column" style="overflow: hidden;">
					<div class="d-inline-flex flex-auto">
						<a class="Link--primary text-bold f4" style="text-overflow: ellipsis" href="/orgs/HaloSPV3/packages/nuget/HXE/50453268">1.1.1-ci.16</a>
					</div>
					<div class="css-truncate css-truncate-target d-block" style="max-width: 540px;">
						<div class="f6 color-fg-muted">
							Published almost 3 years ago
						</div>
					</div>
				</div>
				<div class="ml-3 flex-self-center">
					<span class="color-fg-muted overflow-hidden no-wrap f6 ml-1" style="text-overflow: ellipsis; display: inline-block">
						<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-download d-inline-block v-align-bottom">
							<path d="M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"/>
							<path d="M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.969a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.78a.749.749 0 1 1 1.06-1.06l1.97 1.969Z"/>
						</svg>
          0
					</span>
				</div>
			</div>
		</li>
		<li data-view-component="true" class="Box-row">
			<div class="d-flex">
				<div class="col-10 d-flex flex-auto flex-column" style="overflow: hidden;">
					<div class="d-inline-flex flex-auto">
						<a class="Link--primary text-bold f4" style="text-overflow: ellipsis" href="/orgs/HaloSPV3/packages/nuget/HXE/50456820">1.1.1-ci.15</a>
					</div>
					<div class="css-truncate css-truncate-target d-block" style="max-width: 540px;">
						<div class="f6 color-fg-muted">
							Published almost 3 years ago
						</div>
					</div>
				</div>
				<div class="ml-3 flex-self-center">
					<span class="color-fg-muted overflow-hidden no-wrap f6 ml-1" style="text-overflow: ellipsis; display: inline-block">
						<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-download d-inline-block v-align-bottom">
							<path d="M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"/>
							<path d="M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.969a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.78a.749.749 0 1 1 1.06-1.06l1.97 1.969Z"/>
						</svg>
          0
					</span>
				</div>
			</div>
		</li>
		<li data-view-component="true" class="Box-row">
			<div class="d-flex">
				<div class="col-10 d-flex flex-auto flex-column" style="overflow: hidden;">
					<div class="d-inline-flex flex-auto">
						<a class="Link--primary text-bold f4" style="text-overflow: ellipsis" href="/orgs/HaloSPV3/packages/nuget/HXE/50456816">1.1.1-ci.14</a>
					</div>
					<div class="css-truncate css-truncate-target d-block" style="max-width: 540px;">
						<div class="f6 color-fg-muted">
							Published almost 3 years ago
						</div>
					</div>
				</div>
				<div class="ml-3 flex-self-center">
					<span class="color-fg-muted overflow-hidden no-wrap f6 ml-1" style="text-overflow: ellipsis; display: inline-block">
						<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-download d-inline-block v-align-bottom">
							<path d="M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"/>
							<path d="M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.969a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.78a.749.749 0 1 1 1.06-1.06l1.97 1.969Z"/>
						</svg>
          0
					</span>
				</div>
			</div>
		</li>
	</ul>
	<div data-view-component="true" class="Box-footer">
		<a href="/orgs/HaloSPV3/packages/nuget/HXE/versions">View and manage all versions</a>
	</div>
</div>

This page will need to be parsed after the publish step, during success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants