Skip to content

Commit 6a0f8a5

Browse files
committed
Ci/trusted publishing (#244)
* chore(Directory.Package.props): nuget up bump package versions * refactor(build): Directory.Build.props Add IsAotCompatible property across projects * ci(workflow): release.yml update pipeline for OIDC-based NuGet Trusted Publishing Closes #243 * ci(workflow): develop.yml & release.yml bump action versions in release and develop pipelines * build(hydrascript): csproj improve runtime support and packaging configuration * ci(workflow): develop.yml YAMl folded multiline https://github.com/orgs/community/discussions/26105 * ci(workflow): release.yml update release pipeline to provide runtime-specific dotnet tool NuGet publishing
1 parent 1a8f52e commit 6a0f8a5

10 files changed

Lines changed: 102 additions & 53 deletions

File tree

.github/workflows/develop.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ jobs:
2121
runs-on: windows-latest
2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@v5
24+
uses: actions/checkout@v6
2525
with:
2626
fetch-depth: 0
2727
- name: Setup .NET
2828
uses: actions/setup-dotnet@v5
2929
with:
3030
dotnet-version: 10.0.x
3131
- name: Setup GitVersion
32-
uses: gittools/actions/gitversion/setup@v4.2.0
32+
uses: gittools/actions/gitversion/setup@v4.5.0
3333
with:
3434
versionSpec: '6.4.x'
3535
- name: Determine Version
3636
id: version_step
37-
uses: gittools/actions/gitversion/execute@v4.2.0
37+
uses: gittools/actions/gitversion/execute@v4.5.0
3838
- name: Push New Version Tag
3939
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
4040
run: |
@@ -48,7 +48,9 @@ jobs:
4848
- name: Restore dependencies
4949
run: dotnet restore
5050
- name: Build
51-
run: dotnet build -p:Version=${{ steps.version_step.outputs.fullSemVer }} --no-restore -c Debug -v n
51+
run: >-
52+
dotnet build -p:Version=${{ steps.version_step.outputs.fullSemVer }}
53+
--no-restore -c Debug -v n
5254
- name: Unit Tests
5355
run: dotnet test -c Debug --no-build -v n --filter-trait Category=Unit
5456
- name: Integration Tests
@@ -72,7 +74,7 @@ jobs:
7274
show_branch: true
7375
only_changed_files: true
7476
- name: ReportGenerator
75-
uses: danielpalme/ReportGenerator-GitHub-Action@5.4.15
77+
uses: danielpalme/ReportGenerator-GitHub-Action@5.5.10
7678
with:
7779
reports: './tests/HydraScript.IntegrationTests/bin/Debug/net10.0/TestResults/coverage.cobertura.xml'
7880
targetdir: './coverage-report'

.github/workflows/release.yml

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ permissions:
99
contents: write
1010
issues: write
1111
actions: write
12+
id-token: write
1213

1314
jobs:
1415
create-release:
@@ -19,7 +20,7 @@ jobs:
1920
publish_version: ${{ steps.version_step.outputs.publishVersion }}
2021
steps:
2122
- name: Checkout
22-
uses: actions/checkout@v5
23+
uses: actions/checkout@v6
2324
with:
2425
fetch-depth: 0
2526
- name: Setup .NET
@@ -31,11 +32,11 @@ jobs:
3132
echo "majorMinorPatch=$tag" >> $GITHUB_OUTPUT
3233
echo "publishVersion=${tag:1}" >> $GITHUB_OUTPUT
3334
- name: Setup GitReleaseManager
34-
uses: gittools/actions/gitreleasemanager/setup@v4.2.0
35+
uses: gittools/actions/gitreleasemanager/setup@v4.5.0
3536
with:
3637
versionSpec: '0.20.x'
3738
- name: Create release with GitReleaseManager
38-
uses: gittools/actions/gitreleasemanager/create@v4.2.0
39+
uses: gittools/actions/gitreleasemanager/create@v4.5.0
3940
with:
4041
token: ${{ secrets.GITHUB_TOKEN }}
4142
repository: 'Stepami/hydrascript'
@@ -60,23 +61,27 @@ jobs:
6061
runs-on: ${{ matrix.config.os }}
6162
steps:
6263
- name: Checkout
63-
uses: actions/checkout@v5
64+
uses: actions/checkout@v6
6465
- name: Setup .NET
6566
uses: actions/setup-dotnet@v5
6667
with:
6768
dotnet-version: 10.0.x
6869
- name: Setup GitReleaseManager
69-
uses: gittools/actions/gitreleasemanager/setup@v4.2.0
70+
uses: gittools/actions/gitreleasemanager/setup@v4.5.0
7071
with:
7172
versionSpec: '0.20.x'
7273
- name: Publish
73-
run: |
74-
mkdir output
75-
dotnet publish ./src/HydraScript/HydraScript.csproj -r ${{ matrix.config.rid }} -p:Version=${{ needs.create-release.outputs.publish_version }} -o ./output
74+
run: >-
75+
dotnet publish ./src/HydraScript/HydraScript.csproj
76+
-r ${{ matrix.config.rid }}
77+
-p:Version=${{ needs.create-release.outputs.publish_version }}
78+
-o ./output
7679
- name: Rename Executable
77-
run: mv ./output/HydraScript${{ matrix.config.rid == 'win-x64' && '.exe' || '' }} ./output/hydrascript_${{ matrix.config.rid }}${{ matrix.config.rid == 'win-x64' && '.exe' || '' }}
80+
run: >-
81+
mv ./output/HydraScript${{ matrix.config.rid == 'win-x64' && '.exe' || '' }}
82+
./output/hydrascript_${{ matrix.config.rid }}${{ matrix.config.rid == 'win-x64' && '.exe' || '' }}
7883
- name: Add asset to a release with GitReleaseManager
79-
uses: gittools/actions/gitreleasemanager/addasset@v4.2.0
84+
uses: gittools/actions/gitreleasemanager/addasset@v4.5.0
8085
with:
8186
token: ${{ secrets.GITHUB_TOKEN }}
8287
repository: 'Stepami/hydrascript'
@@ -93,17 +98,17 @@ jobs:
9398
- name: Setup .NET
9499
uses: actions/setup-dotnet@v5
95100
- name: Setup GitReleaseManager
96-
uses: gittools/actions/gitreleasemanager/setup@v4.2.0
101+
uses: gittools/actions/gitreleasemanager/setup@v4.5.0
97102
with:
98103
versionSpec: '0.20.x'
99104
- name: Publish release with GitReleaseManager
100-
uses: gittools/actions/gitreleasemanager/publish@v4.2.0
105+
uses: gittools/actions/gitreleasemanager/publish@v4.5.0
101106
with:
102107
token: ${{ secrets.GITHUB_TOKEN }}
103108
repository: 'Stepami/hydrascript'
104109
milestone: ${{ needs.upload-release-assets.outputs.determined_version }}
105110
- name: Close release with GitReleaseManager
106-
uses: gittools/actions/gitreleasemanager/close@v4.2.0
111+
uses: gittools/actions/gitreleasemanager/close@v4.5.0
107112
with:
108113
token: ${{ secrets.GITHUB_TOKEN }}
109114
repository: 'Stepami/hydrascript'
@@ -115,16 +120,63 @@ jobs:
115120
needs: publish-release
116121
steps:
117122
- name: Checkout
118-
uses: actions/checkout@v5
123+
uses: actions/checkout@v6
124+
- name: Setup .NET
125+
uses: actions/setup-dotnet@v5
126+
with:
127+
dotnet-version: 10.0.x
128+
- name: Pack
129+
run: >-
130+
dotnet pack ./src/HydraScript/HydraScript.csproj -c Release -o ./pack-output -v n
131+
-p:Version=${{ needs.publish-release.outputs.publish_version }}
132+
-p:PublishAot=false
133+
- name: NuGet login (OIDC → temp API key)
134+
uses: NuGet/login@v1
135+
id: nuget_login
136+
with:
137+
user: ${{ secrets.NUGET_USER }}
138+
- name: Publish
139+
run: >-
140+
dotnet nuget push ./pack-output/HydraScript.${{ needs.publish-release.outputs.publish_version }}.nupkg
141+
--skip-duplicate
142+
--api-key ${{ steps.nuget_login.outputs.NUGET_API_KEY }}
143+
--source "https://api.nuget.org/v3/index.json"
144+
145+
publish-rid-nuget:
146+
name: Publish as runtime-specific dotnet tool to NuGet
147+
needs: publish-release
148+
strategy:
149+
matrix:
150+
config:
151+
- os: ubuntu-latest
152+
rid: linux-x64
153+
- os: macos-latest
154+
rid: osx-arm64
155+
- os: windows-latest
156+
rid: win-x64
157+
runs-on: ${{ matrix.config.os }}
158+
steps:
159+
- name: Checkout
160+
uses: actions/checkout@v6
119161
- name: Setup .NET
120162
uses: actions/setup-dotnet@v5
121163
with:
122164
dotnet-version: 10.0.x
123-
- name: Build
124-
run: dotnet build ./src/HydraScript/HydraScript.csproj -c Release -v n `
125-
-p:Version=${{ needs.publish-release.outputs.publish_version }} `
126-
-p:PublishAot=false -p:PublishSingleFile=false
165+
- name: Pack
166+
run: >-
167+
dotnet pack ./src/HydraScript/HydraScript.csproj
168+
-c Release -o ./pack-rid-output -v n
169+
-r ${{ matrix.config.rid }}
170+
-p:Version=${{ needs.publish-release.outputs.publish_version }}
171+
- name: NuGet login (OIDC → temp API key)
172+
uses: NuGet/login@v1
173+
id: nuget_login
174+
with:
175+
user: ${{ secrets.NUGET_USER }}
127176
- name: Publish
128-
run: dotnet nuget push (ls "./src/HydraScript/bin/Release/*.nupkg") `
129-
--api-key ${{ secrets.NUGET_API_KEY }} `
177+
run: >-
178+
dotnet nuget push
179+
./pack-rid-output/HydraScript.${{ matrix.config.rid }}.${{ needs.publish-release.outputs.publish_version }}.nupkg
180+
--skip-duplicate
181+
--api-key ${{ steps.nuget_login.outputs.NUGET_API_KEY }}
130182
--source "https://api.nuget.org/v3/index.json"

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<LangVersion>latest</LangVersion>
99
<BuildInParallel>false</BuildInParallel>
1010
<IsPackable>false</IsPackable>
11+
<IsAotCompatible>true</IsAotCompatible>
1112
</PropertyGroup>
1213

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

Directory.Packages.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageVersion>
1414
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0"/>
15-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.7"/>
16-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.7"/>
17-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.7"/>
18-
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.7"/>
19-
<PackageVersion Include="System.CommandLine" Version="2.0.7"/>
15+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.8"/>
16+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.8"/>
17+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.8"/>
18+
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.8"/>
19+
<PackageVersion Include="System.CommandLine" Version="2.0.8"/>
2020
<PackageVersion Include="System.IO.Abstractions" Version="22.1.1"/>
2121
<PackageVersion Include="Visitor.NET" Version="4.2.1"/>
2222
<PackageVersion Include="Visitor.NET.AutoVisitableGen" Version="1.5.3"/>

benchmarks/HydraScript.Benchmarks/HydraScript.Benchmarks.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5+
<IsAotCompatible>false</IsAotCompatible>
56
</PropertyGroup>
67

78
<ItemGroup>

src/Domain/HydraScript.Domain.Constants/HydraScript.Domain.Constants.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5+
<IsAotCompatible>false</IsAotCompatible>
56
</PropertyGroup>
67

78
</Project>

src/HydraScript/HydraScript.csproj

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,8 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<PublishAot>true</PublishAot>
6-
<PublishSingleFile>true</PublishSingleFile>
7-
</PropertyGroup>
8-
9-
<ItemGroup>
10-
<ProjectReference Include="..\Infrastructure\HydraScript.Infrastructure\HydraScript.Infrastructure.csproj" />
11-
</ItemGroup>
12-
13-
<ItemGroup>
14-
<PackageReference Include="System.CommandLine" />
15-
</ItemGroup>
16-
17-
<PropertyGroup Condition="'$(PublishAot)' == 'false' And '$(PublishSingleFile)' == 'false'">
6+
<RuntimeIdentifiers>linux-x64;win-x64;osx-arm64;</RuntimeIdentifiers>
187
<IsPackable>true</IsPackable>
19-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
208
<PackageId>HydraScript</PackageId>
219
<Description>TypeScript &amp; Go inspired small interpreted programming language written in C#</Description>
2210
<Authors>Stepami</Authors>
@@ -35,7 +23,15 @@
3523
<PackageIcon>icon.png</PackageIcon>
3624
</PropertyGroup>
3725

38-
<ItemGroup Condition="'$(PublishAot)' == 'false' And '$(PublishSingleFile)' == 'false'">
26+
<ItemGroup>
27+
<ProjectReference Include="..\Infrastructure\HydraScript.Infrastructure\HydraScript.Infrastructure.csproj" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<PackageReference Include="System.CommandLine" />
32+
</ItemGroup>
33+
34+
<ItemGroup>
3935
<None Include="../../LICENSE" Pack="true" Visible="false" PackagePath=""/>
4036
<None Include="../../README.md" Pack="true" Visible="false" PackagePath=""/>
4137
<None Include="../../icon.png" Pack="true" Visible="false" PackagePath=""/>

src/Infrastructure/HydraScript.Infrastructure.LexerRegexGenerator/HydraScript.Infrastructure.LexerRegexGenerator.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
55
<IsRoslynComponent>true</IsRoslynComponent>
66
<TargetFramework>netstandard2.0</TargetFramework>
7+
<IsAotCompatible>false</IsAotCompatible>
78
</PropertyGroup>
89

910
<ItemGroup>

src/Infrastructure/HydraScript.Infrastructure/HydraScriptConsole.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,11 @@
66
namespace HydraScript.Infrastructure;
77

88
[ExcludeFromCodeCoverage]
9-
internal partial class HydraScriptConsole(ILogger<HydraScriptConsole> logger) : IConsole
9+
internal sealed class HydraScriptConsole(ILogger<HydraScriptConsole> logger) : IConsole
1010
{
11-
[ZLoggerMessage(Level = LogLevel.Information, Message = "{obj}")]
12-
private static partial void WriteLine(ILogger<HydraScriptConsole> logger, object? obj);
11+
public void WriteLine(object? obj) => logger.ZLogInformation($"{obj}");
1312

14-
public void WriteLine(object? obj) => WriteLine(logger, obj);
15-
16-
[ZLoggerMessage(Level = LogLevel.Error, Message = "{message}")]
17-
private static partial void WriteError(ILogger<HydraScriptConsole> logger, Exception e, string message);
18-
19-
public void WriteError(Exception e, string message) => WriteError(logger, e, message);
13+
public void WriteError(Exception e, string message) => logger.ZLogError(e, $"{message}");
2014

2115
public string ReadLine() => Console.ReadLine() ?? string.Empty;
2216
}

tests/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<OutputType>Exe</OutputType>
88
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
99
<TestingPlatformCommandLineArguments>--ignore-exit-code 8</TestingPlatformCommandLineArguments>
10+
<IsAotCompatible>false</IsAotCompatible>
1011
</PropertyGroup>
1112

1213
<ItemGroup>

0 commit comments

Comments
 (0)