-
Notifications
You must be signed in to change notification settings - Fork 328
Expand file tree
/
Copy pathGithubRelease.fs
More file actions
81 lines (66 loc) · 2.62 KB
/
Copy pathGithubRelease.fs
File metadata and controls
81 lines (66 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
module Build.GithubRelease
open System
open System.IO
open Build.Workspace
open SimpleExec
open BlackFox.CommandLine
open EasyBuild.Tools.Git
let createGithubRelease (version: LastVersionFinder.Version) =
let versionText = version.Version.ToString()
let releaseExists =
try
Command.Run("gh", $"release view {versionText}")
true
with :? ExitCodeException ->
false
// Only create a Github release if the tag doesn't exist
// It can happens that we trigger a release where Fable.Cli
// is already up to date.
if not releaseExists then
Command.Run(
"gh",
CmdLine.empty
|> CmdLine.appendRaw "release"
|> CmdLine.appendRaw "create"
|> CmdLine.appendRaw versionText
|> CmdLine.appendPrefix "--title" versionText
|> CmdLine.appendPrefix "--notes" version.Body
|> CmdLine.appendIf version.Version.IsPrerelease "--prerelease"
|> CmdLine.toString
)
// Creating the release above with the default GITHUB_TOKEN does not
// trigger the `release: published` event in other workflows (GitHub
// suppresses it to avoid recursive runs). `workflow_dispatch` is one of
// the two exceptions that CAN be triggered by GITHUB_TOKEN, so we
// explicitly dispatch the PyPI publish workflow for the freshly created tag.
Command.Run(
"gh",
CmdLine.empty
|> CmdLine.appendRaw "workflow"
|> CmdLine.appendRaw "run"
|> CmdLine.appendRaw "publish-pypi.yml"
|> CmdLine.appendPrefix "--ref" versionText
|> CmdLine.toString
)
let private createReleaseCommitAndPush (version: LastVersionFinder.Version) =
let versionText = version.Version.ToString()
Git.addAll ()
Git.commit ($"Release %s{versionText}")
Git.push ()
let handle (args: string list) =
let struct (currentBranch, _) =
Command.ReadAsync("git", "rev-parse --abbrev-ref HEAD")
|> Async.AwaitTask
|> Async.RunSynchronously
if currentBranch.Trim() <> "main" then
failwith "You must be on the main branch to release"
Command.Run("gh", "auth status")
let skipPublish = args |> List.contains "--skip-publish"
if not skipPublish then
Publish.handle args
let changelogContent = File.ReadAllText(Changelog.fableCLi)
match LastVersionFinder.tryFindLastVersion changelogContent with
| Ok version ->
// createReleaseCommitAndPush version
createGithubRelease version
| Error err -> err.ToText() |> failwith