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

Allow paket push set via token #215

Merged
merged 4 commits into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions Content/Console/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ let runtimes = [

let disableCodeCoverage = environVarAsBoolOrDefault "DISABLE_COVERAGE" false

let githubToken = Environment.environVarOrNone "GITHUB_TOKEN"
Option.iter(TraceSecrets.register "<GITHUB_TOKEN>")

//-----------------------------------------------------------------------------
// Helpers
Expand All @@ -113,7 +115,6 @@ let isRelease (targets : Target list) =
|> Seq.map(fun t -> t.Name)
|> Seq.exists ((=)"Release")


let isReleaseBranchCheck () =
if Git.Information.getBranchName "" <> releaseBranch then failwithf "Not on %s. If you want to release please switch to this branch." releaseBranch

Expand Down Expand Up @@ -531,8 +532,8 @@ let gitRelease _ =
let githubRelease _ =
allReleaseChecks ()
let token =
match Environment.environVarOrDefault "GITHUB_TOKEN" "" with
| s when not (String.IsNullOrWhiteSpace s) -> s
match githubToken with
| Some s -> s
| _ -> failwith "please set the github_token environment variable to a github personal access token with repo access."

let files = distGlob
Expand Down
14 changes: 9 additions & 5 deletions Content/Library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,18 @@ git remote add origin https://github.com/user/MyCoolNewLib.git
git push -u origin master
```

- [Add your NuGet API key to paket](https://fsprojects.github.io/Paket/paket-config.html#Adding-a-NuGet-API-key)
- [Create your NuGeT API key](https://docs.microsoft.com/en-us/nuget/nuget-org/publish-a-package#create-api-keys)
- [Add your NuGet API key to paket](https://fsprojects.github.io/Paket/paket-config.html#Adding-a-NuGet-API-key)

```sh
paket config add-token "https://www.nuget.org" 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a
```

- or set the environment variable `NUGET_TOKEN` to your key

```sh
paket config add-token "https://www.nuget.org" 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a
```

- [Create a GitHub OAuth Token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)
- You can then set the `GITHUB_TOKEN` to upload release notes and artifacts to github
- You can then set the environment variable `GITHUB_TOKEN` to upload release notes and artifacts to github
- Otherwise it will fallback to username/password

- Then update the `CHANGELOG.md` with an "Unreleased" section containing release notes for this version, in [KeepAChangelog](https://keepachangelog.com/en/1.1.0/) format.
Expand Down
14 changes: 12 additions & 2 deletions Content/Library/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ let docsSiteBaseUrl = sprintf "https://%s.github.io/%s" gitOwner gitRepoName

let disableCodeCoverage = environVarAsBoolOrDefault "DISABLE_COVERAGE" false

let githubToken = Environment.environVarOrNone "GITHUB_TOKEN"
Option.iter(TraceSecrets.register "<GITHUB_TOKEN>" )


let nugetToken = Environment.environVarOrNone "NUGET_TOKEN"
Option.iter(TraceSecrets.register "<NUGET_TOKEN>")

//-----------------------------------------------------------------------------
// Helpers
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -551,6 +558,9 @@ let publishToNuget _ =
ToolType = ToolType.CreateLocalTool()
PublishUrl = publishUrl
WorkingDir = "dist"
ApiKey = match nugetToken with
| Some s -> s
| _ -> c.ApiKey // assume paket-config was set properly
}
)
// If build fails after this point, we've pushed a release out with this version of CHANGELOG.md so we should keep it around
Expand Down Expand Up @@ -578,8 +588,8 @@ let gitRelease _ =
let githubRelease _ =
allReleaseChecks ()
let token =
match Environment.environVarOrDefault "GITHUB_TOKEN" "" with
| s when not (String.IsNullOrWhiteSpace s) -> s
match githubToken with
| Some s -> s
| _ -> failwith "please set the github_token environment variable to a github personal access token with repo access."

let files = !! distGlob
Expand Down
7 changes: 3 additions & 4 deletions docsSrc/Tutorials/Getting_Started_With_Libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ The release process is streamlined so you only have to start your git repository
git remote add origin https://github.com/MyGithubUsername/MyCoolNewLib.git
git push -u origin master

- [Create a NuGet API key](https://docs.microsoft.com/en-us/nuget/nuget-org/publish-a-package#create-api-keys) and [Add your NuGet API key to paket](https://fsprojects.github.io/Paket/paket-config.html#Adding-a-NuGet-API-key)
- [Create a NuGet API key](https://docs.microsoft.com/en-us/nuget/nuget-org/publish-a-package#create-api-keys)


[lang=bash]
paket config add-token "https://www.nuget.org" 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a
- [Add your NuGet API key to paket](https://fsprojects.github.io/Paket/paket-config.html#Adding-a-NuGet-API-key)
- or set the environment variable `NUGET_TOKEN` to your key

- [Create a GitHub OAuth Token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)
- You can then set the `GITHUB_TOKEN` to upload `CHANGELOG` notes and artifacts to github
Expand Down