Skip to content

Commit db9a817

Browse files
committed
Ci: package publishing to trusted publishing
1 parent b95bc0f commit db9a817

3 files changed

Lines changed: 150 additions & 0 deletions

File tree

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Publish Packages
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: Release version without the leading "v"
8+
required: false
9+
type: string
10+
publish_nuget:
11+
description: Publish to NuGet.org
12+
required: false
13+
default: true
14+
type: boolean
15+
publish_github_packages:
16+
description: Publish to GitHub Packages
17+
required: false
18+
default: true
19+
type: boolean
20+
workflow_call:
21+
inputs:
22+
version:
23+
description: Release version without the leading "v"
24+
required: false
25+
type: string
26+
publish_nuget:
27+
description: Publish to NuGet.org
28+
required: false
29+
type: boolean
30+
publish_github_packages:
31+
description: Publish to GitHub Packages
32+
required: false
33+
type: boolean
34+
35+
permissions:
36+
contents: read
37+
packages: write
38+
39+
jobs:
40+
package:
41+
uses: ./.github/workflows/publish-artifacts.yml
42+
with:
43+
package_version: ${{ inputs.version }}
44+
45+
publish-nuget:
46+
name: Publish to NuGet.org
47+
runs-on: ubuntu-latest
48+
needs: package
49+
if: ${{ inputs.publish_nuget != false }}
50+
permissions:
51+
contents: read
52+
id-token: write
53+
54+
steps:
55+
- name: Setup .NET
56+
uses: actions/setup-dotnet@v5
57+
with:
58+
dotnet-version: 10.0.x
59+
60+
- name: Download packages
61+
uses: actions/download-artifact@v6
62+
with:
63+
pattern: ModularityKit-packages
64+
path: dist
65+
merge-multiple: true
66+
67+
- name: NuGet login
68+
id: login
69+
uses: NuGet/login@v1
70+
with:
71+
user: ${{ secrets.NUGET_USERNAME }}
72+
73+
- name: Push packages to NuGet.org
74+
run: |
75+
if [ -z "${{ secrets.NUGET_USERNAME }}" ]; then
76+
echo "NUGET_USERNAME secret is required to publish to NuGet.org with Trusted Publishing." >&2
77+
exit 1
78+
fi
79+
80+
for package in dist/*.nupkg; do
81+
dotnet nuget push "$package" \
82+
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
83+
--source https://api.nuget.org/v3/index.json \
84+
--skip-duplicate
85+
done
86+
87+
publish-github-packages:
88+
name: Publish to GitHub Packages
89+
runs-on: ubuntu-latest
90+
needs: package
91+
if: ${{ inputs.publish_github_packages != false }}
92+
93+
steps:
94+
- name: Setup .NET
95+
uses: actions/setup-dotnet@v5
96+
with:
97+
dotnet-version: 10.0.x
98+
99+
- name: Download packages
100+
uses: actions/download-artifact@v6
101+
with:
102+
pattern: ModularityKit-packages
103+
path: dist
104+
merge-multiple: true
105+
106+
- name: Push packages to GitHub Packages
107+
env:
108+
GITHUB_TOKEN: ${{ github.token }}
109+
GITHUB_OWNER: ${{ github.repository_owner }}
110+
run: |
111+
for package in dist/*.nupkg; do
112+
dotnet nuget push "$package" \
113+
--api-key "$GITHUB_TOKEN" \
114+
--source "https://nuget.pkg.github.com/${GITHUB_OWNER}/index.json" \
115+
--skip-duplicate
116+
done

src/ModularityKit.Mutator.Governance.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
<Nullable>enable</Nullable>
77
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
88
<RootNamespace>ModularityKit.Mutator</RootNamespace>
9+
<PackageId>ModularityKit.Mutator.Governance</PackageId>
10+
<Version>0.1.0</Version>
11+
<Authors>ModularityKit</Authors>
12+
<Company>ModularityKit</Company>
13+
<Description>Governance extension for ModularityKit.Mutator with request lifecycle, approval workflow, and version-aware execution.</Description>
14+
<PackageProjectUrl>https://github.com/ModularityKit/ModularityKit.Mutator</PackageProjectUrl>
15+
<RepositoryUrl>https://github.com/ModularityKit/ModularityKit.Mutator.git</RepositoryUrl>
16+
<RepositoryType>git</RepositoryType>
17+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
18+
<PackageTags>governance;approvals;requests;workflow;audit</PackageTags>
19+
<PackageReadmeFile>README.md</PackageReadmeFile>
20+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
21+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
922
</PropertyGroup>
1023

1124
<ItemGroup>
@@ -16,4 +29,8 @@
1629
<Compile Include="Governance/**/*.cs" />
1730
</ItemGroup>
1831

32+
<ItemGroup>
33+
<None Include="Governance/README.md" Pack="true" PackagePath="" Visible="false" />
34+
</ItemGroup>
35+
1936
</Project>

src/ModularityKit.Mutator.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<PackageId>ModularityKit.Mutator</PackageId>
8+
<Version>0.1.0</Version>
9+
<Authors>ModularityKit</Authors>
10+
<Company>ModularityKit</Company>
11+
<Description>Deterministic mutation engine with policy enforcement, audit logging, and execution context.</Description>
12+
<PackageProjectUrl>https://github.com/ModularityKit/ModularityKit.Mutator</PackageProjectUrl>
13+
<RepositoryUrl>https://github.com/ModularityKit/ModularityKit.Mutator.git</RepositoryUrl>
14+
<RepositoryType>git</RepositoryType>
15+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
16+
<PackageTags>mutations;policy;audit;history;governance</PackageTags>
17+
<PackageReadmeFile>README.md</PackageReadmeFile>
18+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
19+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
720
</PropertyGroup>
821

922
<ItemGroup>
@@ -14,4 +27,8 @@
1427
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.2" />
1528
</ItemGroup>
1629

30+
<ItemGroup>
31+
<None Include="../README.md" Pack="true" PackagePath="" Visible="false" />
32+
</ItemGroup>
33+
1734
</Project>

0 commit comments

Comments
 (0)