Skip to content

Commit dcbbdd3

Browse files
suhdevclaude
andcommitted
Add NuGet publish workflow + shared package metadata
The publish job runs on `v*.*.*` tag pushes (or via manual workflow_dispatch with a version input). It restores, builds Release with the resolved version threaded through `-p:Version=`, runs unit tests as a release-gate sanity check, packs all six src projects with symbol packages (.snupkg), and pushes to nuget.org with --skip-duplicate so re-runs are idempotent. Directory.Build.props now carries the shared NuGet metadata (Authors, Repository*, license expression, readme, source-link config). Each .csproj keeps its Description / RootNamespace; Cel.Parser was missing both, so add them. Local pack smoke-tested with -p:Version=0.1.0-dev — produces six nupkgs + snupkgs with the expected inter-package dependencies (Cel depends on Cel.Checker, Cel.Core, Cel.Parser, Cel.Runtime). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2a80e2a commit dcbbdd3

3 files changed

Lines changed: 108 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Publish to NuGet
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
# Manual fallback — pick a version when running:
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: 'Package version (e.g. 0.1.0). Leave blank to derive from current tag.'
12+
required: false
13+
default: ''
14+
15+
# A publish run is a release event — never let two race for the same tag.
16+
concurrency:
17+
group: nuget-publish-${{ github.ref }}
18+
cancel-in-progress: false
19+
20+
jobs:
21+
publish:
22+
name: Pack & push to nuget.org
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 15
25+
steps:
26+
- name: Check out
27+
uses: actions/checkout@v4
28+
with:
29+
# Source linking embeds the commit hash; full history isn't needed.
30+
fetch-depth: 1
31+
32+
- name: Resolve package version
33+
id: version
34+
# Tag push: strip the leading 'v' from refs/tags/v0.1.0 → 0.1.0.
35+
# Manual dispatch: trust the input verbatim. Reject anything else.
36+
run: |
37+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref_type }}" == "tag" ]]; then
38+
v="${GITHUB_REF#refs/tags/v}"
39+
elif [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.version }}" ]]; then
40+
v="${{ inputs.version }}"
41+
else
42+
echo "Cannot determine version: not a v*.*.* tag and no input.version given." >&2
43+
exit 1
44+
fi
45+
echo "Version: $v"
46+
echo "version=$v" >> "$GITHUB_OUTPUT"
47+
48+
- name: Setup .NET
49+
uses: actions/setup-dotnet@v4
50+
with:
51+
global-json-file: global.json
52+
53+
- name: Restore
54+
run: dotnet restore
55+
56+
- name: Build
57+
run: dotnet build --configuration Release --no-restore -p:Version=${{ steps.version.outputs.version }}
58+
59+
- name: Test (sanity)
60+
# Treat a failing test on a release as a hard stop — better to refuse a
61+
# broken release than to publish it.
62+
run: dotnet test tests/Cel.UnitTests --configuration Release --no-build
63+
64+
- name: Pack
65+
run: dotnet pack --configuration Release --no-build -p:Version=${{ steps.version.outputs.version }} --output artifacts
66+
67+
- name: Push to nuget.org
68+
# --skip-duplicate so re-running the workflow on a tag that's been
69+
# partially published doesn't fail; nuget.org is the source of truth.
70+
run: dotnet nuget push 'artifacts/*.nupkg' --api-key ${{ secrets.NUGET }} --source https://api.nuget.org/v3/index.json --skip-duplicate
71+
72+
- name: Upload nupkgs as run artifacts
73+
# Keep the built nupkgs around for a week so they're easy to inspect
74+
# if the push fails at the nuget.org side.
75+
if: always()
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: nupkgs-${{ steps.version.outputs.version }}
79+
path: artifacts/*.nupkg
80+
retention-days: 7

Directory.Build.props

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@
1616
<NoWarn>$(NoWarn);CA1014;CA1062;CA1303;CA1716;CA1720;CA1724;CA2225;CA1034;CA1859;CA1725</NoWarn>
1717
</PropertyGroup>
1818

19+
<!-- Shared NuGet package metadata. Per-project Description / PackageId stay
20+
in each .csproj. Version is set on the publish workflow via -p:Version=
21+
so this file doesn't need to be edited per release. -->
22+
<PropertyGroup>
23+
<Authors>suhdev</Authors>
24+
<Company>suhdev</Company>
25+
<Product>Cel for .NET</Product>
26+
<Copyright>Copyright (c) suhdev</Copyright>
27+
<PackageProjectUrl>https://github.com/suhdev/csharp-cel</PackageProjectUrl>
28+
<RepositoryUrl>https://github.com/suhdev/csharp-cel.git</RepositoryUrl>
29+
<RepositoryType>git</RepositoryType>
30+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
31+
<PackageReadmeFile>README.md</PackageReadmeFile>
32+
<PackageTags>cel;expression-language;policy;rule-engine;cel-spec;dotnet</PackageTags>
33+
<!-- Embed source + symbols so consumers can step through into the package. -->
34+
<IncludeSymbols>true</IncludeSymbols>
35+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
36+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
37+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
38+
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
39+
</PropertyGroup>
40+
41+
<ItemGroup Condition="'$(IsPackable)' != 'false'">
42+
<None Include="$(MSBuildThisFileDirectory)README.md" Pack="true" PackagePath="\" />
43+
</ItemGroup>
44+
1945
<PropertyGroup Condition="$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('Tests')) or '$(MSBuildProjectName)' == 'Cel.Conformance'">
2046
<IsPackable>false</IsPackable>
2147
<NoWarn>$(NoWarn);CA1707;CA1822;CA2007;CA1515</NoWarn>

src/Cel.Parser/Cel.Parser.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<TargetFramework>net10.0</TargetFramework>
99
<ImplicitUsings>enable</ImplicitUsings>
1010
<Nullable>enable</Nullable>
11+
<Description>CEL parser: hand-written lexer and Pratt parser, with macro expansion.</Description>
12+
<RootNamespace>Cel</RootNamespace>
1113
</PropertyGroup>
1214

1315
</Project>

0 commit comments

Comments
 (0)