-
I want to create a NukeBuild script that is capable of creating a GitHub Release for me (the
For reference, consider this the code I'm executing within my Target: var productInformation = new ProductHeaderValue("MyApp-NukeBuildScript");
GitHubTasks.GitHubClient = new GitHubClient(productInformation)
{
Credentials = new Credentials(GitHubUser, GitHubPassword) // My GitHub credentials I provide as command line arguments when executing the script
};
var releaseData = new NewRelease(Version)
{
Prerelease = true,
Draft = true,
Body = "Test"
};
Release release = await GitHubTasks.GitHubClient.Repository.Release
.Create(Repository.GetGitHubOwner(), Repository.GetGitHubName(), releaseData); where [GitRepository] readonly GitRepository Repository; I suspected I might have a typo in the string branchName = await GitHubTasks.GetDefaultBranch(Repository); which is a piece of Code I pulled from the NukeBuild source code within the GitHubTasks source. And when I run this code, I successfully get the name of my repository. So it seems that my problem is not related to the Why is my piece of code unable to create a Github Release? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
If a working example helps, here is a public repo where I do it: |
Beta Was this translation helpful? Give feedback.
-
The github token is a token generate for a single run of a github action. I set it up like this to let github know to provide it to me https://github.com/DNNCommunity/dnn-elements/blob/22b35de3b21e7975309d9968b7b5df5d65cfc33f/_build/Build.cs#L34 Then we capture its value in a parameter like so: https://github.com/DNNCommunity/dnn-elements/blob/22b35de3b21e7975309d9968b7b5df5d65cfc33f/_build/Build.cs#L67-L68 Which allows us to do git operations that require authentication according to the permissions of that token generated for us by github. In the repository settings for actions, you will need read/write permissions for that token to be able to publish releases. |
Beta Was this translation helpful? Give feedback.
-
I have not been able to make it work with the 'username + password' overload of the I did manage to get the intergration to work with a Github Personal Access Token.
|
Beta Was this translation helpful? Give feedback.
I have not been able to make it work with the 'username + password' overload of the
Credentials
class.I did manage to get the intergration to work with a Github Personal Access Token.