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

Only publish to Gitlab registry #203

Closed
fbjerggaard opened this issue Jul 13, 2022 · 9 comments
Closed

Only publish to Gitlab registry #203

fbjerggaard opened this issue Jul 13, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@fbjerggaard
Copy link

fbjerggaard commented Jul 13, 2022

I have a need for publishing a package only to the GitLab registry, therefore I suggest adding a variable publishToNuget which defaults to true but allows the user to specify where to publish the package to.

The way I see it, it should just be wrapping the following in an if-statement to check if the package should be published there.
Alternatively it could check whether pluginConfig.nugetServer is null - but that would break the current implementation.

try {
const cliArgs = [...baseCliArgs, "-s", registry, "-k", token];
cliArgs.push(`${packagePath}/*.nupkg`);
context.logger.log(`running command "${dotnet} ${cliArgs.join(" ")}" ...`);
await execa(dotnet, cliArgs, { stdio: "inherit" });
} catch (error) {
context.logger.error(`${dotnet} push failed: ${(error as Error).message}`);
if (typeof error === "object" && (error as ExecaReturnBase<void>).exitCode) {
const err = error as ExecaReturnBase<void>;
let description = err.command;
// hide token from SR output
if (err.command && err.command.includes(token)) {
description = description.replace(token, "[redacted]");
}
throw new SemanticReleaseError(`publish to registry ${registry} failed`, err.exitCode, description);
}
}

I am happy to provide a PR if this is a feature that is wanted.

@Kampfmoehre
Copy link
Member

You could just overwrite nugetServer in config like described in the Readme but I guess that would not work with environment variables like CI_SERVER_URL.

@fbjerggaard
Copy link
Author

Yeah, I did think about that, but that would require a lot of workarounds to get it to work as smoothly and easily as just setting publishToGitlab to true :)

@Kampfmoehre Kampfmoehre added the enhancement New feature or request label Jul 13, 2022
Kampfmoehre added a commit that referenced this issue Jul 13, 2022
adds a flag that will skip publishing to NuGet server and only publish to (private) GitLab instance
Contributes to #203
@Kampfmoehre
Copy link
Member

@fbjerggaard I think I managed to implement it, are you able to test it directly from the branch (by replacing package name with a git Url in package-json) or do you need a published NPM package?

Kampfmoehre added a commit that referenced this issue Jul 13, 2022
adds a flag that will skip publishing to NuGet server and only publish to (private) GitLab instance
Contributes to #203
@fbjerggaard
Copy link
Author

@Kampfmoehre Seems like I would need a published NPM package since npm install https://github.com/droidsolutions/semantic-release-nuget.git#gitlab_only doesn't build the files

@Kampfmoehre
Copy link
Member

Kampfmoehre commented Jul 13, 2022

I see, let's just publish it then as beta

Edit: @fbjerggaard please try https://www.npmjs.com/package/@droidsolutions-oss/semantic-release-nuget/v/1.2.0-beta.1

@fbjerggaard
Copy link
Author

Seems to work perfectly - the only issue I ran into was that it still required the NUGET_TOKEN variable to be set even though it is not neccessary.

@Kampfmoehre
Copy link
Member

This will be resolved in the final version, I'll wait a little bit until another issue that is also in the beta branch is resolved then I'll merge to release a final version.

@fbjerggaard
Copy link
Author

Awesome - thanks a lot for the prompt responses!

@Kampfmoehre
Copy link
Member

This is included in v1.2.0.

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

No branches or pull requests

2 participants