Skip to content

Commit

Permalink
scripts: convert Push target to fsx script
Browse files Browse the repository at this point in the history
The `Default` target & common stuff has also been removed due to
its dependency on `Pack`.

Co-authored-by: webwarrior <[email protected]>
  • Loading branch information
Mersho and webwarrior-ws committed Feb 21, 2024
1 parent b56617c commit 7bcf598
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build+test+deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
env:
nuget-key: ${{ secrets.NUGET_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: dotnet fake build -t Push
run: dotnet fsi scripts/push.fsx
- name: Create Release (if tag)
if: startsWith(github.ref, 'refs/tags/')
id: create_release
Expand Down
167 changes: 0 additions & 167 deletions build.fsx

This file was deleted.

48 changes: 48 additions & 0 deletions scripts/push.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#r "nuget: Fake.Core.UserInput"
#r "nuget: Fake.DotNet.Paket"
#load "common.fsx"
#load "pack.fsx"

open System

open Fake.Core
open Fake.DotNet

open Common

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..."

0 comments on commit 7bcf598

Please sign in to comment.