Skip to content

Commit 055ae35

Browse files
hahn-kevcursoragentcoderabbitai[bot]
authored
Enable NuGet.org publishing (#74)
* Enable NuGet.org publishing and add package metadata. Publish RC builds on main merges and stable releases on version tags. Co-authored-by: Cursor <cursoragent@cursor.com> * Add NuGet version badge to README.md * Fail the run if there's no nuget packages Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent bfb23a1 commit 055ae35

7 files changed

Lines changed: 61 additions & 17 deletions

File tree

.github/workflows/nuget-ci-cd.yml

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,47 @@ jobs:
4040
- name: Pack
4141
shell: bash
4242
run: |
43-
dotnet pack --include-symbols /p:PackageVersion="$PACKAGE_VERSION" /p:AssemblyVersion="$ASSEMBLY_VERSION" /p:FileVersion="$FILE_VERSION"
43+
dotnet pack /p:PackageVersion="$PACKAGE_VERSION" /p:AssemblyVersion="$ASSEMBLY_VERSION" /p:FileVersion="$FILE_VERSION"
4444
4545
- name: Upload packages to build artifacts
4646
uses: actions/upload-artifact@v4
4747
with:
4848
name: nuget-packages
4949
path: src/artifacts/package/release/*nupkg
5050

51-
# Not using the GitHub package registry right now, since it doesn't allow anonymous access so it's a hassle to use
51+
- name: Publish package to NuGet.org
52+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
53+
shell: bash
54+
run: |
55+
shopt -s nullglob
56+
packages=(src/artifacts/package/release/*.nupkg)
57+
symbols=(src/artifacts/package/release/*.snupkg)
5258
53-
# - name: Publish package to GitHub
54-
# if: github.event_name == 'pull_request' || (github.event_name == 'push' && startsWith(github.ref, 'refs/heads'))
55-
# shell: bash
56-
# run: |
57-
# dotnet nuget push "src/artifacts/package/release/*.symbols.nupkg" -s https://nuget.pkg.github.com/sillsdev/index.json -k "$NUGET_API_KEY" --skip-duplicate
58-
# env:
59-
# NUGET_API_KEY: ${{ secrets.GITHUB_TOKEN }}
59+
if ((${`#packages`[@]} == 0)); then
60+
echo "No NuGet packages were produced." >&2
61+
exit 1
62+
fi
63+
if ((${`#symbols`[@]} == 0)); then
64+
echo "No symbol packages were produced." >&2
65+
exit 1
66+
fi
6067
61-
# - name: Publish package to NuGet.org
62-
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
63-
# shell: bash
64-
# run: |
65-
# echo Would run the following:
66-
# echo dotnet nuget push "src/artifacts/package/release/*nupkg" --skip-duplicate --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json
67-
# env:
68-
# NUGET_API_KEY: ${{ secrets.SILLSDEV_PUBLISH_NUGET_ORG }}
68+
for pkg in "${packages[@]}"; do
69+
case "$pkg" in
70+
*.symbols.nupkg|*.snupkg) continue ;;
71+
esac
72+
echo "Publishing $pkg"
73+
dotnet nuget push "$pkg" \
74+
--skip-duplicate \
75+
--api-key "$NUGET_API_KEY" \
76+
--source https://api.nuget.org/v3/index.json
77+
done
78+
for sym in "${symbols[@]}"; do
79+
echo "Publishing symbols $sym"
80+
dotnet nuget push "$sym" \
81+
--skip-duplicate \
82+
--api-key "$NUGET_API_KEY" \
83+
--source https://api.nuget.org/v3/index.json
84+
done
85+
env:
86+
NUGET_API_KEY: ${{ secrets.SILLSDEV_PUBLISH_NUGET_ORG }}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# harmony
22

3+
[![NuGet version](https://img.shields.io/nuget/v/SIL.Harmony.svg?style=flat-square)](https://www.nuget.org/packages/SIL.Harmony/)
4+
35
A CRDT application library for C#, use it to build offline first applications.
46

57
## Install

harmony.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ EndProject
1818
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{321635F9-11D9-4B45-A2F8-F3B70E9A4196}"
1919
ProjectSection(SolutionItems) = preProject
2020
src\Directory.Build.props = src\Directory.Build.props
21+
src\Directory.Build.targets = src\Directory.Build.targets
2122
src\.editorconfig = src\.editorconfig
2223
EndProjectSection
2324
EndProject

src/Directory.Build.targets

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project>
2+
<PropertyGroup Condition="'$(IsPackable)' == 'true'">
3+
<Authors>SIL Global</Authors>
4+
<Company>SIL Global</Company>
5+
<Copyright>Copyright © SIL Global</Copyright>
6+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
7+
<PackageProjectUrl>https://github.com/sillsdev/harmony</PackageProjectUrl>
8+
<RepositoryUrl>https://github.com/sillsdev/harmony</RepositoryUrl>
9+
<RepositoryType>git</RepositoryType>
10+
<PackageReadmeFile>README.md</PackageReadmeFile>
11+
<PackageTags>CRDT;offline-first;Entity Framework Core;synchronization;collaboration</PackageTags>
12+
<IncludeSymbols>true</IncludeSymbols>
13+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
14+
</PropertyGroup>
15+
16+
<ItemGroup Condition="'$(IsPackable)' == 'true'">
17+
<None Include="$(MSBuildThisFileDirectory)../README.md" Pack="true" PackagePath="\" />
18+
</ItemGroup>
19+
</Project>

src/SIL.Harmony.Core/SIL.Harmony.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<RootNamespace>SIL.Harmony.Core</RootNamespace>
55
<IsPackable>true</IsPackable>
6+
<Description>Core types and interfaces for the Harmony CRDT library.</Description>
67
</PropertyGroup>
78
<ItemGroup>
89
<InternalsVisibleTo Include="SIL.Harmony"/>

src/SIL.Harmony.Linq2db/SIL.Harmony.Linq2db.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<PropertyGroup>
44
<RootNamespace>SIL.Harmony.Linq2db</RootNamespace>
55
<IsPackable>true</IsPackable>
6+
<Description>linq2db integration for the Harmony CRDT library.</Description>
7+
<PackageTags>$(PackageTags);linq2db</PackageTags>
68
</PropertyGroup>
79

810
<ItemGroup>

src/SIL.Harmony/SIL.Harmony.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<RootNamespace>SIL.Harmony</RootNamespace>
55
<IsPackable>true</IsPackable>
6+
<Description>CRDT application library for building offline-first apps with Entity Framework Core.</Description>
67
</PropertyGroup>
78

89
<ItemGroup>

0 commit comments

Comments
 (0)