Skip to content

Commit 4fdff35

Browse files
committed
Adapt native AOT packing and CI release from dotnet-stop
Configure go as a PackAsTool global tool with native AOT publishing across all supported RIDs, plus pointer and any fallback packages. Update build and publish workflows to match the dotnet-stop release pipeline, without the secondary stopr CLI.
1 parent ace053e commit 4fdff35

7 files changed

Lines changed: 180 additions & 23 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ jobs:
6969
uses: devlooped/actions-dotnet-env@v1
7070

7171
- name: 🙏 build
72-
run: dotnet build -m:1 -bl:build.binlog
72+
run: |
73+
dotnet build -m:1 -bl:build.binlog -p:RuntimeIdentifiers=any
74+
dotnet build src/go/go.csproj -bl:runtime.binlog -p:RuntimeIdentifiers=any -r any
7375
7476
- name: 🧪 test
7577
shell: pwsh
@@ -105,4 +107,4 @@ jobs:
105107
- name: ✓ ensure format
106108
run: |
107109
dotnet format whitespace --verify-no-changes -v:diag --exclude ~/.nuget
108-
dotnet format style --verify-no-changes -v:diag --exclude ~/.nuget
110+
dotnet format style --verify-no-changes -v:diag --exclude ~/.nuget

.github/workflows/publish.yml

Lines changed: 119 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,67 @@ on:
1010
env:
1111
DOTNET_NOLOGO: true
1212
Configuration: Release
13-
PackOnBuild: true
14-
GeneratePackageOnBuild: true
15-
VersionLabel: refs/tags/${{ github.event.release.tag_name }}
13+
VersionLabel: ${{ github.ref }}
1614
GH_TOKEN: ${{ secrets.GH_TOKEN }}
1715
MSBUILDTERMINALLOGGER: auto
1816
SLEET_FEED_URL: https://api.nuget.org/v3/index.json
19-
17+
18+
defaults:
19+
run:
20+
shell: pwsh
21+
2022
jobs:
23+
native-aot:
24+
name: native-aot-${{ matrix.rid }}
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
include:
30+
- os: ubuntu-latest
31+
rid: linux-x64
32+
- os: ubuntu-24.04-arm
33+
rid: linux-arm64
34+
- os: windows-latest
35+
rid: win-x64
36+
- os: windows-11-arm
37+
rid: win-arm64
38+
- os: macos-15-intel
39+
rid: osx-x64
40+
- os: macos-latest
41+
rid: osx-arm64
42+
steps:
43+
- name: 🤘 checkout
44+
uses: actions/checkout@v4
45+
46+
- name: ⚙ dotnet
47+
uses: devlooped/actions-dotnet-env@v1
48+
49+
- name: 📦 pack
50+
run: |
51+
dotnet pack src/go/go.csproj -c $env:Configuration -r ${{ matrix.rid }} -bl:"pack-${{ matrix.rid }}.binlog"
52+
53+
- name: 📤 package
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: package-${{ matrix.rid }}
57+
path: bin/*.${{ matrix.rid }}.*.nupkg
58+
retention-days: 30
59+
if-no-files-found: error
60+
61+
- name: 🐛 logs
62+
uses: actions/upload-artifact@v4
63+
if: runner.debug && always()
64+
with:
65+
name: logs-${{ matrix.rid }}
66+
path: '*.binlog'
67+
2168
publish:
69+
needs: native-aot
2270
runs-on: ${{ vars.PUBLISH_AGENT || 'ubuntu-latest' }}
71+
env:
72+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
73+
SLEET_CONNECTION: ${{ secrets.SLEET_CONNECTION }}
2374
steps:
2475
- name: 🤘 checkout
2576
uses: actions/checkout@v4
@@ -34,27 +85,81 @@ jobs:
3485
run: dotnet build -m:1 -bl:build.binlog
3586

3687
- name: 🧪 test
37-
shell: pwsh
3888
run: dnx --yes retest -- --no-build
3989

90+
- name: 📦 pointer
91+
run: |
92+
dotnet pack src/go/go.csproj -c $env:Configuration -bl:pointer-pack.binlog
93+
94+
- name: 📦 fallback
95+
run: |
96+
dotnet pack src/go/go.csproj -c $env:Configuration -r any -bl:any-pack.binlog
97+
98+
- name: 📤 package
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: package-any
102+
path: bin/*.nupkg
103+
retention-days: 30
104+
if-no-files-found: error
105+
106+
- name: 📥 packages
107+
uses: actions/download-artifact@v4
108+
with:
109+
pattern: package-*
110+
path: bin
111+
merge-multiple: true
112+
40113
- name: 🐛 logs
41114
uses: actions/upload-artifact@v4
42115
if: runner.debug && always()
43116
with:
44-
name: logs
117+
name: logs-publish
45118
path: '*.binlog'
46119

47120
- name: 🚀 nuget
48-
env:
49-
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
50121
if: ${{ env.NUGET_API_KEY != '' && github.event.action != 'prereleased' }}
51-
working-directory: bin
52-
run: dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate
122+
run: |
123+
$packages = @(Get-ChildItem bin -Filter *.nupkg | Where-Object Name -NotLike '*.symbols.nupkg' | Sort-Object Name)
124+
$runtimePackagePattern = '^go\.(win-x64|win-arm64|linux-x64|linux-arm64|osx-x64|osx-arm64|any)\..+\.nupkg$'
125+
$runtimePackages = @($packages | Where-Object Name -Match $runtimePackagePattern)
126+
$pointerPackages = @($packages | Where-Object Name -NotMatch $runtimePackagePattern)
127+
128+
if ($runtimePackages.Count -eq 0) { throw 'No RID-specific or fallback packages found.' }
129+
if ($pointerPackages.Count -eq 0) { throw 'No top-level pointer package found.' }
130+
131+
foreach ($package in $runtimePackages) {
132+
dotnet nuget push $package.FullName -s https://api.nuget.org/v3/index.json -k $env:NUGET_API_KEY --skip-duplicate
133+
}
134+
135+
foreach ($package in $pointerPackages) {
136+
dotnet nuget push $package.FullName -s https://api.nuget.org/v3/index.json -k $env:NUGET_API_KEY --skip-duplicate
137+
}
53138
54139
- name: 🚀 sleet
55-
env:
56-
SLEET_CONNECTION: ${{ secrets.SLEET_CONNECTION }}
57140
if: env.SLEET_CONNECTION != ''
58141
run: |
59-
dotnet tool update sleet -g --allow-downgrade --version $(curl -s --compressed ${{ vars.SLEET_FEED_URL }} | jq '.["sleet:version"]' -r)
60-
sleet push bin --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" || echo "No packages found"
142+
$packages = @(Get-ChildItem bin -Filter *.nupkg | Where-Object Name -NotLike '*.symbols.nupkg' | Sort-Object Name)
143+
$runtimePackagePattern = '^go\.(win-x64|win-arm64|linux-x64|linux-arm64|osx-x64|osx-arm64|any)\..+\.nupkg$'
144+
$runtimePackages = @($packages | Where-Object Name -Match $runtimePackagePattern)
145+
$pointerPackages = @($packages | Where-Object Name -NotMatch $runtimePackagePattern)
146+
147+
if ($runtimePackages.Count -eq 0) { throw 'No RID-specific or fallback packages found.' }
148+
if ($pointerPackages.Count -eq 0) { throw 'No top-level pointer package found.' }
149+
150+
$runtimePath = Join-Path $env:RUNNER_TEMP runtime-packages
151+
$pointerPath = Join-Path $env:RUNNER_TEMP pointer-package
152+
New-Item -ItemType Directory -Force -Path $runtimePath, $pointerPath | Out-Null
153+
154+
Copy-Item -Path $runtimePackages.FullName -Destination $runtimePath
155+
Copy-Item -Path $pointerPackages.FullName -Destination $pointerPath
156+
157+
$sleetVersion = (Invoke-RestMethod -Uri $env:SLEET_FEED_URL).'sleet:version'
158+
if ($sleetVersion) {
159+
dotnet tool update sleet -g --allow-downgrade --version $sleetVersion
160+
} else {
161+
dotnet tool update sleet -g --allow-downgrade
162+
}
163+
164+
sleet push $runtimePath --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=$env:SLEET_CONNECTION" -p "SLEET_FEED_TYPE=azure"
165+
sleet push $pointerPath --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=$env:SLEET_CONNECTION" -p "SLEET_FEED_TYPE=azure"

src/Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<NuGetBuildTasksPackTargets Condition="'$(NuGetBuildTasksPackTargets)' == ''">$(MSBuildSDKsPath)\..\NuGet.Build.Tasks.Pack.targets</NuGetBuildTasksPackTargets>
4040
</PropertyGroup>
4141

42-
<Import Project="$(NuGetBuildTasksPackTargets)" Condition="Exists('$(NuGetBuildTasksPackTargets)') And '$(NuGetize)' != 'true'" />
42+
<Import Project="$(NuGetBuildTasksPackTargets)" Condition="Exists('$(NuGetBuildTasksPackTargets)')"/>
4343

4444
<PropertyGroup>
4545
<!-- Revert the forced PackageId by the NuGet SDK targets for non-packable projects, see https://github.com/NuGet/Home/issues/14928 -->

src/go/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if (args is ["--help" or "-h" or "-?"])
2+
{
3+
Console.WriteLine("go");
4+
return 0;
5+
}
6+
7+
return 0;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"profiles": {
3+
"go": {
4+
"commandName": "Project",
5+
"commandLineArgs": "-?"
6+
}
7+
}
8+
}

src/go/go.csproj

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
33
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
45
<TargetFramework>net10.0</TargetFramework>
6+
7+
<AssemblyName>go</AssemblyName>
8+
<RootNamespace>Devlooped</RootNamespace>
9+
<SignAssembly>false</SignAssembly>
10+
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
11+
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
12+
13+
<Description>A dotnet global tool.</Description>
514
<PackageId>go</PackageId>
15+
<PackAsTool>true</PackAsTool>
16+
<PackBuildOutput>false</PackBuildOutput>
17+
<PackageReadmeFile>readme.md</PackageReadmeFile>
18+
<PackageTags>dotnet dotnet-tool</PackageTags>
19+
<PackageProjectUrl>https://github.com/devlooped/go</PackageProjectUrl>
20+
21+
<!-- Allow running on whatever latest version users have. See https://docs.microsoft.com/en-us/dotnet/core/versions/selection#framework-dependent-apps-roll-forward -->
22+
<!-- Useful for RID=any -->
23+
<RollForward>LatestMajor</RollForward>
24+
<RuntimeIdentifiers>win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64;any</RuntimeIdentifiers>
25+
26+
<PublishAot>true</PublishAot>
27+
<StripSymbols>true</StripSymbols>
628
</PropertyGroup>
29+
30+
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'any'">
31+
<PublishAot>false</PublishAot>
32+
</PropertyGroup>
33+
734
<ItemGroup>
8-
<PackageReference Include="NuGetizer" Version="1.4.9">
9-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
10-
<PrivateAssets>all</PrivateAssets>
11-
</PackageReference>
35+
<None Include="readme.md" PackagePath="readme.md" Pack="true" />
36+
<None Include="Properties\*.*" />
1237
</ItemGroup>
38+
39+
<Target Name="RenderHelp" AfterTargets="Build" Condition="$(NoHelp) != 'true' and $(DesignTimeBuild) != 'true' and '$(PublishAot)' != 'true' and '$(RuntimeIdentifier)' == ''">
40+
<WriteLinesToFile Lines="```shell" Overwrite="true" Encoding="UTF-8" File="$(MSBuildProjectDirectory)\help.md" />
41+
<Exec Command="dotnet &quot;$(TargetPath)&quot; --help &gt;&gt; &quot;$(MSBuildProjectDirectory)\help.md&quot;" StdOutEncoding="UTF-8" EnvironmentVariables="NO_COLOR=true" />
42+
<WriteLinesToFile Lines="```" Overwrite="false" Encoding="UTF-8" File="$(MSBuildProjectDirectory)\help.md" />
43+
</Target>
44+
1345
</Project>

src/go/help.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```shell
2+
go
3+
```

0 commit comments

Comments
 (0)