Skip to content

Commit

Permalink
Merge pull request #75 from TheAngryByrd/40-release-gitlab
Browse files Browse the repository at this point in the history
Added GitHubRelease target
  • Loading branch information
TheAngryByrd authored Mar 20, 2018
2 parents 14bcf55 + aa34513 commit bb90cd0
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 12 deletions.
10 changes: 7 additions & 3 deletions Content/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ $ ./build.sh // on unix
#### Environment Variables

* `CONFIGURATION` will set the [configuration](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x#options) of the dotnet commands. If not set it will default to Release.

`CONFIGURATION=Debug ./build.sh` will result in things like `dotnet build -c Debug`

* `CONFIGURATION=Debug ./build.sh` will result in things like `dotnet build -c Debug`
* `GITHUB_TOKEN` will be used to upload release notes and nuget packages to github.
* Be sure to set this before releasing

### Watch Tests

Expand All @@ -64,6 +64,10 @@ git push -u origin master
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
* Otherwise it will fallback to username/password


* Then update the `RELEASE_NOTES.md` with a new version, date, and release notes [ReleaseNotesHelper](https://fsharp.github.io/FAKE/apidocs/fake-releasenoteshelper.html)

Expand Down
34 changes: 34 additions & 0 deletions Content/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ let distDir = __SOURCE_DIRECTORY__ @@ "dist"
let distGlob = distDir @@ "*.nupkg"
let toolsDir = __SOURCE_DIRECTORY__ @@ "tools"

let gitOwner = "MyGithubUsername"
let gitRepoName = "MyLib"

let configuration =
EnvironmentHelper.environVarOrDefault "CONFIGURATION" "Release"

Expand Down Expand Up @@ -242,6 +245,36 @@ Target "GitRelease" (fun _ ->
Branches.pushTag "" "origin" release.NugetVersion
)

#load "paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
open Octokit

Target "GitHubRelease" (fun _ ->
let client =
match Environment.GetEnvironmentVariable "GITHUB_TOKEN" with
| null ->
let user =
match getBuildParam "github-user" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserInput "Username: "
let pw =
match getBuildParam "github-pw" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserPassword "Password: "

createClient user pw
| token -> createClientWithToken token


client
|> createDraft gitOwner gitRepoName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> fun draft ->
!! distGlob
|> Seq.fold (fun draft pkg -> draft |> uploadFile pkg) draft
|> releaseDraft
|> Async.RunSynchronously

)

Target "Release" DoNothing


Expand All @@ -263,6 +296,7 @@ Target "Release" DoNothing
==> "SourcelinkTest"
==> "Publish"
==> "GitRelease"
==> "GitHubRelease"
==> "Release"

"DotnetRestore"
Expand Down
6 changes: 4 additions & 2 deletions Content/paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ nuget SourceLink.Create.CommandLine 2.8.0 copy_local: true


group Build
source https://www.nuget.org/api/v2
nuget FAKE
framework: >= net45
source https://www.nuget.org/api/v2
nuget FAKE
github fsharp/FAKE modules/Octokit/Octokit.fsx
8 changes: 7 additions & 1 deletion Content/paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,12 @@ NUGET
System.Xml.XPath (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= net46)

GROUP Build
RESTRICTION: >= net45
NUGET
remote: https://www.nuget.org/api/v2
FAKE (4.64.4)
FAKE (4.64.11)
Octokit (0.29)
GITHUB
remote: fsharp/FAKE
modules/Octokit/Octokit.fsx (c160d4907360cfd42904008dab2bd22c0a4a9952)
Octokit (>= 0.20)
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### 0.7.1 - 2018-03-19
* BUGFIX: Fixes names in gitlab PR templates (https://github.com/TheAngryByrd/MiniScaffold/pull/71)
* BUGFIX: Fixes names in github PR templates (https://github.com/TheAngryByrd/MiniScaffold/pull/71)
* BUGFIX: Fix dotnet sdk 2.1.101 issue with dotnet-mono (https://github.com/TheAngryByrd/MiniScaffold/pull/74)

### 0.7.0 - 2018-03-15
Expand Down
42 changes: 40 additions & 2 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ open System.IO

let release = LoadReleaseNotes "RELEASE_NOTES.md"
let srcGlob = "*.csproj"
// let testsGlob = "tests/**/*.fsproj"

let distDir = __SOURCE_DIRECTORY__ @@ "dist"
let distGlob = distDir @@ "*.nupkg"

let gitOwner = "TheAngryByrd"
let gitRepoName = "MiniScaffold"

Target "Clean" (fun _ ->
[ "obj" ;"dist"]
Expand Down Expand Up @@ -125,7 +129,7 @@ Target "Publish" (fun _ ->
)
)

Target "Release" (fun _ ->
Target "GitRelease" (fun _ ->

if Git.Information.getBranchName "" <> "master" then failwith "Not on master"

Expand All @@ -139,11 +143,45 @@ Target "Release" (fun _ ->
Branches.pushTag "" "origin" release.NugetVersion
)

#load "paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
open Octokit

Target "GitHubRelease" (fun _ ->
let client =
match Environment.GetEnvironmentVariable "GITHUB_TOKEN" with
| null ->
let user =
match getBuildParam "github-user" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserInput "Username: "
let pw =
match getBuildParam "github-pw" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserPassword "Password: "

createClient user pw
| token -> createClientWithToken token


client
|> createDraft gitOwner gitRepoName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> fun draft ->
!! distGlob
|> Seq.fold (fun draft pkg -> draft |> uploadFile pkg) draft
|> releaseDraft
|> Async.RunSynchronously

)

Target "Release" DoNothing

"Clean"
==> "DotnetRestore"
==> "DotnetPack"
==> "IntegrationTests"
==> "Publish"
==> "GitRelease"
==> "GithubRelease"
==> "Release"

RunTargetOrDefault "IntegrationTests"
6 changes: 4 additions & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
source https://www.nuget.org/api/v2

group Build
source https://www.nuget.org/api/v2
nuget FAKE
framework: >= net45
source https://www.nuget.org/api/v2
nuget FAKE
github fsharp/FAKE modules/Octokit/Octokit.fsx
8 changes: 7 additions & 1 deletion paket.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@


GROUP Build
RESTRICTION: >= net45
NUGET
remote: https://www.nuget.org/api/v2
FAKE (4.60)
FAKE (4.64.11)
Octokit (0.29)
GITHUB
remote: fsharp/FAKE
modules/Octokit/Octokit.fsx (c160d4907360cfd42904008dab2bd22c0a4a9952)
Octokit (>= 0.20)

0 comments on commit bb90cd0

Please sign in to comment.