Skip to content

Commit f397398

Browse files
committed
fixup! feat(ci): implement ability to push to GitHub packages
1 parent 5b6467c commit f397398

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

.github/workflows/publish_ci.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,7 @@ jobs:
2525
8.x
2626
2727
- name: Add the GitHub source
28-
run: dotnet nuget add source --username USERNAME --password ${{secrets.GITHUB_TOKEN}} --store-password-in-clear-text --name "github.com" "https://nuget.pkg.github.com/fsprojects/index.json"
29-
30-
- name: Set Build Version
31-
run: |
32-
$documentName = "src\FSharp.Control.R3\FSharp.Control.R3.fsproj"
33-
$File = (
34-
Select-Xml -XPath "/Project/PropertyGroup[@Label='NuGet']/Version" -Path $documentName
35-
)[0].Node
36-
$version = "$($File.InnerText)-ci-$Env:GITHUB_RUN_ID"
37-
$File.InnerText = $version
38-
$File.OwnerDocument.Save((Join-Path $PWD.ProviderPath $documentName))
39-
echo "VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
40-
shell: pwsh
28+
run: dotnet nuget add source --username USERNAME --password ${{secrets.GITHUB_TOKEN}} --name "github.com" "https://nuget.pkg.github.com/fsprojects/index.json"
4129

4230
- name: publish
4331
env:

build/build.fs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,18 @@ let deleteChangelogBackupFile _ =
277277
if String.isNotNullOrEmpty Changelog.changelogBackupFilename then
278278
Shell.rm Changelog.changelogBackupFilename
279279

280+
let getPackageVersionProperty publishToGitHub =
281+
if publishToGitHub then
282+
let runId = Environment.environVar "GITHUB_RUN_ID"
283+
$"/p:PackageVersion=%s{latestEntry.NuGetVersion}-ci-%s{runId}"
284+
else
285+
$"/p:PackageVersion=%s{latestEntry.NuGetVersion}"
280286

281287
let dotnetBuild ctx =
282-
let args = [ sprintf "/p:PackageVersion=%s" latestEntry.NuGetVersion; "--no-restore" ]
283288

284-
let embedAll = ctx.Context.FinalTarget = "PublishToGitHub"
289+
let publishToGitHub = ctx.Context.FinalTarget = "PublishToGitHub"
290+
291+
let args = [ getPackageVersionProperty publishToGitHub; "--no-restore" ]
285292

286293
DotNet.build
287294
(fun c -> {
@@ -291,7 +298,7 @@ let dotnetBuild ctx =
291298
MSBuildParams = {
292299
(disableBinLog c.MSBuildParams) with
293300
Properties = [
294-
if embedAll then
301+
if publishToGitHub then
295302
("DebugType", "embedded")
296303
("EmbedAllSources", "true")
297304
]
@@ -440,7 +447,10 @@ let dotnetPack ctx =
440447
// Get release notes with properly-linked version number
441448
let releaseNotes = Changelog.mkReleaseNotes changelog latestEntry gitHubRepoUrl
442449

443-
let args = [ $"/p:PackageVersion={latestEntry.NuGetVersion}"; $"/p:PackageReleaseNotes=\"{releaseNotes}\"" ]
450+
let args = [
451+
getPackageVersionProperty (ctx.Context.FinalTarget = "PublishToGitHub")
452+
$"/p:PackageReleaseNotes=\"{releaseNotes}\""
453+
]
444454

445455
DotNet.pack
446456
(fun c -> {

src/FSharp.Control.R3/FSharp.Control.R3.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<PropertyGroup Label="NuGet">
88
<Title>FSharp.Control.R3</Title>
99
<Description>Extensions and wrappers for using R3 with F#</Description>
10-
<Version>0.1.0</Version>
1110
</PropertyGroup>
1211

1312
<PropertyGroup Condition="'$(Configuration)'=='Release'">

0 commit comments

Comments
 (0)