Skip to content

Commit

Permalink
Merge PR #647 from knocte/avoidPreReleaseForReleaseNotesCommit
Browse files Browse the repository at this point in the history
build.fsx,RELEASE.md: don't push prereleases for relNotes commits.
  • Loading branch information
knocte committed Dec 24, 2023
2 parents bb15542 + fa788db commit 237280f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build+test+publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
env:
nuget-key: ${{ secrets.NUGET_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'push' && env.nuget-key != null
run: dotnet fake build -t Push
- name: Create Release (if tag)
if: startsWith(github.ref, 'refs/tags/')
Expand Down
50 changes: 44 additions & 6 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ let exec cmd args dir =
|> Proc.run
|> ignore

let getBuildParam = Environment.environVar
let getBuildParam var =
let value = Environment.environVar var
if String.IsNullOrWhiteSpace value then
None
else
Some value
let DoNothing = ignore

// --------------------------------------------------------------------------------------
Expand Down Expand Up @@ -163,11 +168,44 @@ Target.create "Pack" (fun _ ->
)

Target.create "Push" (fun _ ->
let key =
match getBuildParam "nuget-key" with
| s when not (isNullOrWhiteSpace s) -> s
| _ -> UserInput.getUserPassword "NuGet Key: "
Paket.push (fun p -> { p with WorkingDir = nugetDir; ApiKey = key; ToolType = ToolType.CreateLocalTool() }))
let push key =
Paket.push (fun p -> { p with WorkingDir = nugetDir; ApiKey = key; ToolType = ToolType.CreateLocalTool() })

let key = getBuildParam "nuget-key"
match getBuildParam "GITHUB_EVENT_NAME" with
| None ->
match key with
| None ->
let key = UserInput.getUserPassword "NuGet Key: "
push key
| Some key ->
push key

| Some "push" ->
match key with
| None ->
Console.WriteLine "No nuget-key env var found, skipping..."
| Some key ->
if isTag then
push key
else
match getBuildParam "GITHUB_SHA" with
| None ->
failwith "GITHUB_SHA should have been populated"
| Some commitHash ->
let gitArgs = sprintf "describe --exact-match --tags %s" commitHash
let proc =
CreateProcess.fromRawCommandLine "git" gitArgs
|> Proc.run
if proc.ExitCode <> 0 then
// commit is not a tag, so go ahead pushing a prerelease
push key
else
Console.WriteLine "Commit mapped to a tag, skipping pushing prerelease..."
| _ ->
Console.WriteLine "Github event name not 'push', skipping..."

)


Target.create "SelfCheck" (fun _ ->
Expand Down

0 comments on commit 237280f

Please sign in to comment.