Skip to content

Commit bb90cd0

Browse files
authored
Merge pull request #75 from TheAngryByrd/40-release-gitlab
Added GitHubRelease target
2 parents 14bcf55 + aa34513 commit bb90cd0

File tree

8 files changed

+104
-12
lines changed

8 files changed

+104
-12
lines changed

Content/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ $ ./build.sh // on unix
3636
#### Environment Variables
3737

3838
* `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.
39-
40-
`CONFIGURATION=Debug ./build.sh` will result in things like `dotnet build -c Debug`
41-
39+
* `CONFIGURATION=Debug ./build.sh` will result in things like `dotnet build -c Debug`
40+
* `GITHUB_TOKEN` will be used to upload release notes and nuget packages to github.
41+
* Be sure to set this before releasing
4242

4343
### Watch Tests
4444

@@ -64,6 +64,10 @@ git push -u origin master
6464
paket config add-token "https://www.nuget.org" 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a
6565
```
6666

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

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

Content/build.fsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ let distDir = __SOURCE_DIRECTORY__ @@ "dist"
1515
let distGlob = distDir @@ "*.nupkg"
1616
let toolsDir = __SOURCE_DIRECTORY__ @@ "tools"
1717

18+
let gitOwner = "MyGithubUsername"
19+
let gitRepoName = "MyLib"
20+
1821
let configuration =
1922
EnvironmentHelper.environVarOrDefault "CONFIGURATION" "Release"
2023

@@ -242,6 +245,36 @@ Target "GitRelease" (fun _ ->
242245
Branches.pushTag "" "origin" release.NugetVersion
243246
)
244247

248+
#load "paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
249+
open Octokit
250+
251+
Target "GitHubRelease" (fun _ ->
252+
let client =
253+
match Environment.GetEnvironmentVariable "GITHUB_TOKEN" with
254+
| null ->
255+
let user =
256+
match getBuildParam "github-user" with
257+
| s when not (String.IsNullOrWhiteSpace s) -> s
258+
| _ -> getUserInput "Username: "
259+
let pw =
260+
match getBuildParam "github-pw" with
261+
| s when not (String.IsNullOrWhiteSpace s) -> s
262+
| _ -> getUserPassword "Password: "
263+
264+
createClient user pw
265+
| token -> createClientWithToken token
266+
267+
268+
client
269+
|> createDraft gitOwner gitRepoName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
270+
|> fun draft ->
271+
!! distGlob
272+
|> Seq.fold (fun draft pkg -> draft |> uploadFile pkg) draft
273+
|> releaseDraft
274+
|> Async.RunSynchronously
275+
276+
)
277+
245278
Target "Release" DoNothing
246279

247280

@@ -263,6 +296,7 @@ Target "Release" DoNothing
263296
==> "SourcelinkTest"
264297
==> "Publish"
265298
==> "GitRelease"
299+
==> "GitHubRelease"
266300
==> "Release"
267301

268302
"DotnetRestore"

Content/paket.dependencies

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ nuget SourceLink.Create.CommandLine 2.8.0 copy_local: true
1010

1111

1212
group Build
13-
source https://www.nuget.org/api/v2
14-
nuget FAKE
13+
framework: >= net45
14+
source https://www.nuget.org/api/v2
15+
nuget FAKE
16+
github fsharp/FAKE modules/Octokit/Octokit.fsx

Content/paket.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,12 @@ NUGET
13081308
System.Xml.XPath (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= net46)
13091309

13101310
GROUP Build
1311+
RESTRICTION: >= net45
13111312
NUGET
13121313
remote: https://www.nuget.org/api/v2
1313-
FAKE (4.64.4)
1314+
FAKE (4.64.11)
1315+
Octokit (0.29)
1316+
GITHUB
1317+
remote: fsharp/FAKE
1318+
modules/Octokit/Octokit.fsx (c160d4907360cfd42904008dab2bd22c0a4a9952)
1319+
Octokit (>= 0.20)

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### 0.7.1 - 2018-03-19
2-
* BUGFIX: Fixes names in gitlab PR templates (https://github.com/TheAngryByrd/MiniScaffold/pull/71)
2+
* BUGFIX: Fixes names in github PR templates (https://github.com/TheAngryByrd/MiniScaffold/pull/71)
33
* BUGFIX: Fix dotnet sdk 2.1.101 issue with dotnet-mono (https://github.com/TheAngryByrd/MiniScaffold/pull/74)
44

55
### 0.7.0 - 2018-03-15

build.fsx

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ open System.IO
99

1010
let release = LoadReleaseNotes "RELEASE_NOTES.md"
1111
let srcGlob = "*.csproj"
12-
// let testsGlob = "tests/**/*.fsproj"
1312

13+
let distDir = __SOURCE_DIRECTORY__ @@ "dist"
14+
let distGlob = distDir @@ "*.nupkg"
15+
16+
let gitOwner = "TheAngryByrd"
17+
let gitRepoName = "MiniScaffold"
1418

1519
Target "Clean" (fun _ ->
1620
[ "obj" ;"dist"]
@@ -125,7 +129,7 @@ Target "Publish" (fun _ ->
125129
)
126130
)
127131

128-
Target "Release" (fun _ ->
132+
Target "GitRelease" (fun _ ->
129133

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

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

146+
#load "paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
147+
open Octokit
148+
149+
Target "GitHubRelease" (fun _ ->
150+
let client =
151+
match Environment.GetEnvironmentVariable "GITHUB_TOKEN" with
152+
| null ->
153+
let user =
154+
match getBuildParam "github-user" with
155+
| s when not (String.IsNullOrWhiteSpace s) -> s
156+
| _ -> getUserInput "Username: "
157+
let pw =
158+
match getBuildParam "github-pw" with
159+
| s when not (String.IsNullOrWhiteSpace s) -> s
160+
| _ -> getUserPassword "Password: "
161+
162+
createClient user pw
163+
| token -> createClientWithToken token
164+
165+
166+
client
167+
|> createDraft gitOwner gitRepoName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
168+
|> fun draft ->
169+
!! distGlob
170+
|> Seq.fold (fun draft pkg -> draft |> uploadFile pkg) draft
171+
|> releaseDraft
172+
|> Async.RunSynchronously
173+
174+
)
175+
176+
Target "Release" DoNothing
177+
142178
"Clean"
143179
==> "DotnetRestore"
144180
==> "DotnetPack"
145181
==> "IntegrationTests"
146182
==> "Publish"
183+
==> "GitRelease"
184+
==> "GithubRelease"
147185
==> "Release"
148186

149187
RunTargetOrDefault "IntegrationTests"

paket.dependencies

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
source https://www.nuget.org/api/v2
22

33
group Build
4-
source https://www.nuget.org/api/v2
5-
nuget FAKE
4+
framework: >= net45
5+
source https://www.nuget.org/api/v2
6+
nuget FAKE
7+
github fsharp/FAKE modules/Octokit/Octokit.fsx

paket.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11

22

33
GROUP Build
4+
RESTRICTION: >= net45
45
NUGET
56
remote: https://www.nuget.org/api/v2
6-
FAKE (4.60)
7+
FAKE (4.64.11)
8+
Octokit (0.29)
9+
GITHUB
10+
remote: fsharp/FAKE
11+
modules/Octokit/Octokit.fsx (c160d4907360cfd42904008dab2bd22c0a4a9952)
12+
Octokit (>= 0.20)

0 commit comments

Comments
 (0)