Skip to content

Commit 3abf483

Browse files
authored
Merge pull request #14 from fsprojects/switch-from-myget-to-github
2 parents 72fed38 + 9c67ee6 commit 3abf483

File tree

3 files changed

+57
-34
lines changed

3 files changed

+57
-34
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v3
1616
- name: Setup .NET Core
17-
uses: actions/setup-dotnet@v1
17+
uses: actions/setup-dotnet@v3
1818
- name: Build with dotnet
1919
run: |
2020
DOTNET_CLI_TELEMETRY_OPTOUT=1

.github/workflows/publish_ci.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
1-
name: publish to MyGet
1+
name: publish to GitHub
22

33
on:
44
push:
55
branches:
66
- develop
77

88
jobs:
9-
build:
9+
publish:
1010

1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
15-
- name: Setup .NET Core
16-
uses: actions/setup-dotnet@v1
17-
- name: Build with dotnet
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Set Build Version
18+
run: |
19+
$File = (
20+
Select-Xml -XPath "/Project/PropertyGroup/Version" -Path "src/FSharp.Collections.Immutable/FSharp.Collections.Immutable.fsproj"
21+
)[0].Node
22+
$version = "$($File.InnerText)-ci-$Env:GITHUB_RUN_ID"
23+
$File.InnerText = $version
24+
$File.OwnerDocument.Save((Join-Path $PWD.ProviderPath src/FSharp.Collections.Immutable/FSharp.Collections.Immutable.fsproj))
25+
echo "VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
26+
shell: pwsh
27+
28+
- name: Install .NET Core
29+
uses: actions/setup-dotnet@v3
30+
31+
- name: Add the GitHub source
32+
run: dotnet nuget add source --username USERNAME --password ${{secrets.GITHUB_TOKEN}} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/fsprojects/index.json"
33+
34+
- name: Pack FSharp.Collections.Immutable project
1835
run: |
19-
sed -i "s|<Version>\(.*\)</Version>|<Version>\1-ci-$GITHUB_RUN_ID</Version>|" src/FSharp.Collections.Immutable/FSharp.Collections.Immutable.fsproj
2036
dotnet pack --nologo --configuration Release -o nuget
21-
- name: MyGet push
37+
38+
- name: Publish FSharp.Collections.Immutable project to GitHub
2239
run: |
23-
source=https://www.myget.org/F/fsharp-collections-immutable/api/v3/index.json
24-
key=${{secrets.MyGet_Key}}
25-
dotnet nuget push -s $source -k $key nuget/*.nupkg
40+
dotnet nuget push nuget/FSharp.Collections.Immutable*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}

.github/workflows/publish_release.yml

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,39 @@ name: publish to NuGet
22

33
on:
44
push:
5-
branches:
6-
- master
5+
tags:
6+
- 'releases/*'
77

88
jobs:
99
publish:
1010

1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
15-
16-
# Required for a specific dotnet version that doesn't come with ubuntu-latest / windows-latest
17-
# Visit bit.ly/2synnZl to see the list of SDKs that are pre-installed with ubuntu-latest / windows-latest
18-
# - name: Setup dotnet
19-
# uses: actions/setup-dotnet@v1
20-
# with:
21-
# dotnet-version: 3.1.100
22-
23-
# Publish
24-
- name: publish on version change
25-
uses: rohith/publish-nuget@v2
26-
with:
27-
PROJECT_FILE_PATH: src/FSharp.Collections.Immutable/FSharp.Collections.Immutable.fsproj # Relative to repository root
28-
# VERSION_FILE_PATH: Directory.Build.props # Filepath with version info, relative to repository root. Defaults to project file
29-
# VERSION_REGEX: <Version>(.*)<\/Version> # Regex pattern to extract version info in a capturing group
30-
# TAG_COMMIT: true # Flag to enable / disalge git tagging
31-
# TAG_FORMAT: v* # Format of the git tag, [*] gets replaced with version
32-
NUGET_KEY: ${{secrets.NuGet_Key}}
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
with:
17+
# This is necessary so that we have the tags.
18+
fetch-depth: 0
19+
20+
- name: Set Build Version
21+
run: |
22+
$version = "$env:GITHUB_REF_NAME"
23+
$File = (
24+
Select-Xml -XPath "/Project/PropertyGroup/Version" -Path "src/FSharp.Collections.Immutable/FSharp.Collections.Immutable.fsproj"
25+
)[0].Node
26+
$File.InnerText = $version
27+
$File.OwnerDocument.Save((Join-Path $PWD.ProviderPath src/FSharp.Collections.Immutable/FSharp.Collections.Immutable.fsproj))
28+
echo "VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
29+
shell: pwsh
30+
31+
- name: Install .NET Core
32+
uses: actions/setup-dotnet@v3
33+
34+
- name: Pack FSharp.Collections.Immutable project
35+
run: |
36+
dotnet pack --nologo --configuration Release -o nuget
37+
38+
- name: Publish FSharp.Collections.Immutable project to GitHub
39+
run: |
40+
dotnet nuget push nuget/FSharp.Collections.Immutable*.nupkg -k ${{secrets.NUGET_SECRET}}

0 commit comments

Comments
 (0)