Skip to content

Commit

Permalink
fixup! feat(ci): implement ability to push to GitHub packages
Browse files Browse the repository at this point in the history
  • Loading branch information
xperiandri committed Nov 17, 2024
1 parent 5b6467c commit f397398
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/publish_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,7 @@ jobs:
8.x
- name: Add the GitHub source
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"

- name: Set Build Version
run: |
$documentName = "src\FSharp.Control.R3\FSharp.Control.R3.fsproj"
$File = (
Select-Xml -XPath "/Project/PropertyGroup[@Label='NuGet']/Version" -Path $documentName
)[0].Node
$version = "$($File.InnerText)-ci-$Env:GITHUB_RUN_ID"
$File.InnerText = $version
$File.OwnerDocument.Save((Join-Path $PWD.ProviderPath $documentName))
echo "VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
run: dotnet nuget add source --username USERNAME --password ${{secrets.GITHUB_TOKEN}} --name "github.com" "https://nuget.pkg.github.com/fsprojects/index.json"

- name: publish
env:
Expand Down
18 changes: 14 additions & 4 deletions build/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,18 @@ let deleteChangelogBackupFile _ =
if String.isNotNullOrEmpty Changelog.changelogBackupFilename then
Shell.rm Changelog.changelogBackupFilename

let getPackageVersionProperty publishToGitHub =
if publishToGitHub then
let runId = Environment.environVar "GITHUB_RUN_ID"
$"/p:PackageVersion=%s{latestEntry.NuGetVersion}-ci-%s{runId}"
else
$"/p:PackageVersion=%s{latestEntry.NuGetVersion}"

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

let embedAll = ctx.Context.FinalTarget = "PublishToGitHub"
let publishToGitHub = ctx.Context.FinalTarget = "PublishToGitHub"

let args = [ getPackageVersionProperty publishToGitHub; "--no-restore" ]

DotNet.build
(fun c -> {
Expand All @@ -291,7 +298,7 @@ let dotnetBuild ctx =
MSBuildParams = {
(disableBinLog c.MSBuildParams) with
Properties = [
if embedAll then
if publishToGitHub then
("DebugType", "embedded")
("EmbedAllSources", "true")
]
Expand Down Expand Up @@ -440,7 +447,10 @@ let dotnetPack ctx =
// Get release notes with properly-linked version number
let releaseNotes = Changelog.mkReleaseNotes changelog latestEntry gitHubRepoUrl

let args = [ $"/p:PackageVersion={latestEntry.NuGetVersion}"; $"/p:PackageReleaseNotes=\"{releaseNotes}\"" ]
let args = [
getPackageVersionProperty (ctx.Context.FinalTarget = "PublishToGitHub")
$"/p:PackageReleaseNotes=\"{releaseNotes}\""
]

DotNet.pack
(fun c -> {
Expand Down
1 change: 0 additions & 1 deletion src/FSharp.Control.R3/FSharp.Control.R3.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<PropertyGroup Label="NuGet">
<Title>FSharp.Control.R3</Title>
<Description>Extensions and wrappers for using R3 with F#</Description>
<Version>0.1.0</Version>
</PropertyGroup>

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

0 comments on commit f397398

Please sign in to comment.