diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e73abfc..75f433b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,13 +45,13 @@ jobs: - name: ⚙ dotnet uses: devlooped/actions-dotnet-env@v1 - - name: 📦 GitHub.Cli + - name: 📦 gh.cli run: | $ErrorActionPreference = 'Stop' dotnet pack src/GitHub.Cli/GitHub.Cli.csproj -c $env:Configuration -p:GeneratePackageOnBuild=false -bl:pointer-pack.binlog - if ($LASTEXITCODE -ne 0) { throw "GitHub.Cli pointer pack failed with exit code $LASTEXITCODE." } + if ($LASTEXITCODE -ne 0) { throw "gh.cli pointer pack failed with exit code $LASTEXITCODE." } dotnet pack src/GitHub.Cli/GitHub.Cli.csproj -c $env:Configuration -r linux-x64 -p:GeneratePackageOnBuild=false -bl:pack-linux-x64.binlog - if ($LASTEXITCODE -ne 0) { throw "GitHub.Cli linux-x64 pack failed with exit code $LASTEXITCODE." } + if ($LASTEXITCODE -ne 0) { throw "gh.cli linux-x64 pack failed with exit code $LASTEXITCODE." } - name: 🙏 build run: dotnet build -m:1 -bl:build.binlog @@ -71,9 +71,9 @@ jobs: run: | $ErrorActionPreference = 'Stop' $script = Join-Path $pwd 'src/GitHub.Cli/unix-exec.ps1' - $cli = Get-ChildItem bin -Filter "GitHub.Cli.linux-x64.*.nupkg" | Where-Object Name -notlike '*.symbols.*' | Select-Object -First 1 + $cli = Get-ChildItem bin -Filter "gh.cli.linux-x64.*.nupkg" | Where-Object Name -notlike '*.symbols.*' | Select-Object -First 1 $tool = Get-ChildItem bin -Filter "gh.linux-x64.*.nupkg" | Where-Object Name -notlike '*.symbols.*' | Select-Object -First 1 - if (-not $cli) { throw "GitHub.Cli.linux-x64 nupkg not found" } + if (-not $cli) { throw "gh.cli.linux-x64 nupkg not found" } if (-not $tool) { throw "gh.linux-x64 nupkg not found" } foreach ($pkg in @($cli, $tool)) { & pwsh -NoProfile -File $script -Nupkg $pkg.FullName -Assert diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9ded75f..c136553 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -53,9 +53,9 @@ jobs: $version = "-p:Version=$env:Version" # Pointer packs restore the host RID Payload; RID packs reuse that tree. dotnet pack src/GitHub.Cli/GitHub.Cli.csproj -c $env:Configuration $version -p:GeneratePackageOnBuild=false -bl:pointer-pack.binlog - if ($LASTEXITCODE -ne 0) { throw "GitHub.Cli pointer pack failed with exit code $LASTEXITCODE." } + if ($LASTEXITCODE -ne 0) { throw "gh.cli pointer pack failed with exit code $LASTEXITCODE." } dotnet pack src/GitHub.Cli/GitHub.Cli.csproj -c $env:Configuration -r $rid $version -p:GeneratePackageOnBuild=false -bl:"pack-$rid.binlog" - if ($LASTEXITCODE -ne 0) { throw "GitHub.Cli $rid pack failed with exit code $LASTEXITCODE." } + if ($LASTEXITCODE -ne 0) { throw "gh.cli $rid pack failed with exit code $LASTEXITCODE." } dotnet pack src/gh/gh.csproj -c $env:Configuration $version -p:GeneratePackageOnBuild=false -bl:pointer-pack-gh.binlog if ($LASTEXITCODE -ne 0) { throw "gh pointer pack failed with exit code $LASTEXITCODE." } dotnet pack src/gh/gh.csproj -c $env:Configuration -r $rid $version -p:GeneratePackageOnBuild=false -bl:"pack-gh-$rid.binlog" @@ -66,9 +66,9 @@ jobs: run: | $ErrorActionPreference = 'Stop' $script = Join-Path $pwd 'src/GitHub.Cli/unix-exec.ps1' - $cli = Get-ChildItem bin -Filter "GitHub.Cli.${{ matrix.rid }}.*.nupkg" | Where-Object Name -notlike '*.symbols.*' | Select-Object -First 1 + $cli = Get-ChildItem bin -Filter "gh.cli.${{ matrix.rid }}.*.nupkg" | Where-Object Name -notlike '*.symbols.*' | Select-Object -First 1 $tool = Get-ChildItem bin -Filter "gh.${{ matrix.rid }}.*.nupkg" | Where-Object Name -notlike '*.symbols.*' | Select-Object -First 1 - if (-not $cli) { throw "GitHub.Cli.${{ matrix.rid }} nupkg not found" } + if (-not $cli) { throw "gh.cli.${{ matrix.rid }} nupkg not found" } if (-not $tool) { throw "gh.${{ matrix.rid }} nupkg not found" } foreach ($pkg in @($cli, $tool)) { & pwsh -NoProfile -File $script -Nupkg $pkg.FullName -Assert @@ -80,9 +80,9 @@ jobs: with: name: package-${{ matrix.rid }} # Only RID nupkgs. Pointer nupkgs are produced on every OS; merging them - # into one GitHub.Cli.{version}.nupkg corrupts the zip (NUGET 400 / sleet EOCD). + # into one gh.cli.{version}.nupkg corrupts the zip (NUGET 400 / sleet EOCD). path: | - bin/GitHub.Cli.${{ matrix.rid }}.*.nupkg + bin/gh.cli.${{ matrix.rid }}.*.nupkg bin/gh.${{ matrix.rid }}.*.nupkg retention-days: 30 if-no-files-found: error @@ -93,7 +93,7 @@ jobs: with: name: package-pointer path: | - bin/GitHub.Cli.${{ env.Version }}.nupkg + bin/gh.cli.${{ env.Version }}.nupkg bin/gh.${{ env.Version }}.nupkg retention-days: 30 if-no-files-found: error @@ -157,12 +157,12 @@ jobs: } $names = Get-ChildItem -File -Filter *.nupkg | ForEach-Object Name foreach ($need in @( - "GitHub.Cli.$env:Version.nupkg", - "GitHub.Cli.win-x64.$env:Version.nupkg", - "GitHub.Cli.linux-x64.$env:Version.nupkg", - "GitHub.Cli.linux-arm64.$env:Version.nupkg", - "GitHub.Cli.osx-x64.$env:Version.nupkg", - "GitHub.Cli.osx-arm64.$env:Version.nupkg", + "gh.cli.$env:Version.nupkg", + "gh.cli.win-x64.$env:Version.nupkg", + "gh.cli.linux-x64.$env:Version.nupkg", + "gh.cli.linux-arm64.$env:Version.nupkg", + "gh.cli.osx-x64.$env:Version.nupkg", + "gh.cli.osx-arm64.$env:Version.nupkg", "gh.$env:Version.nupkg", "gh.win-x64.$env:Version.nupkg", "gh.linux-x64.$env:Version.nupkg", diff --git a/CONTEXT.md b/CONTEXT.md index c6a7d3f..a439918 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -5,11 +5,11 @@ NuGet pointer and per-RID payloads that put a working GitHub CLI next to a .NET ## Language **Pointer**: -The `GitHub.Cli` nupkg: `Cli` plus `runtime.json` mapping each supported RID to a RID package. +The `gh.cli` nupkg: `Cli` plus `runtime.json` mapping each supported RID to a RID package. _Avoid_: metapackage, tool package, native package **RID package**: -`GitHub.Cli.{rid}` — one nupkg, one RID, one Payload. +`gh.cli.{rid}` — one nupkg, one RID, one Payload. _Avoid_: native package, runtime pack, sidecar package **Payload**: diff --git a/docs/adr/0002-nupkg-version-is-upstream.md b/docs/adr/0002-nupkg-version-is-upstream.md index fda587f..347828b 100644 --- a/docs/adr/0002-nupkg-version-is-upstream.md +++ b/docs/adr/0002-nupkg-version-is-upstream.md @@ -1,3 +1,3 @@ # Nupkg version is Upstream -`GitHub.Cli` and the `gh` tool use the GitHub CLI version (`2.98.0`) so `ndnx gh@2.98.0` is that CLI. The pin is `github-cli.version`. CI dogfood stays `42.42.*`. Packaging-only republishes of the same CLI use a SemVer label, not a different major. +`gh.cli` and the `gh` tool use the GitHub CLI version (`2.98.0`) so `ndnx gh@2.98.0` is that CLI. The pin is `github-cli.version`. CI dogfood stays `42.42.*`. Packaging-only republishes of the same CLI use a SemVer label, not a different major. diff --git a/readme.md b/readme.md index 2eff4f5..cd8e65f 100644 --- a/readme.md +++ b/readme.md @@ -33,7 +33,7 @@ dotnet tool install gh && dotnet gh --version `dnx`/`ndnx` use the package id `gh`. An installed tool is `dotnet gh` (`ToolCommandName` `dotnet-gh`) so it does not replace GitHub's native `gh` on PATH. -`PackageReference` `GitHub.Cli` and pack/publish for your RID to copy `gh/` next to the app. `GitHub.Cli.ResolvePath()` is the Payload `gh` executable. +`PackageReference` `gh.cli` and pack/publish for your RID to copy `gh/` next to the app. `GitHub.Cli.ResolvePath()` is the Payload `gh` executable. --- diff --git a/src/GitHub.Cli/Cli.cs b/src/GitHub.Cli/Cli.cs index c8be7b5..693d77c 100644 --- a/src/GitHub.Cli/Cli.cs +++ b/src/GitHub.Cli/Cli.cs @@ -17,7 +17,7 @@ public static string ResolvePath(string? baseDirectory = null) if (!File.Exists(path)) { throw new FileNotFoundException( - $"GitHub CLI payload was not found at '{path}'. PackageReference GitHub.Cli and publish/pack for your RID.", + $"GitHub CLI payload was not found at '{path}'. PackageReference gh.cli and publish/pack for your RID.", path); } diff --git a/src/GitHub.Cli/GitHub.Cli.csproj b/src/GitHub.Cli/GitHub.Cli.csproj index 8a1eba6..1004a1a 100644 --- a/src/GitHub.Cli/GitHub.Cli.csproj +++ b/src/GitHub.Cli/GitHub.Cli.csproj @@ -1,10 +1,10 @@ net10.0 - GitHub.Cli + gh.cli GitHub GitHub.Cli - GitHub CLI payload for .NET: PackageReference GitHub.Cli and publish/pack for your RID to get gh/ plus GitHub.Cli.ResolvePath. + GitHub CLI payload for .NET: PackageReference gh.cli and publish/pack for your RID to get gh/ plus GitHub.Cli.ResolvePath. true true win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64 @@ -33,7 +33,7 @@ - - + + diff --git a/src/GitHub.Cli/GitHub.Cli.pack.targets b/src/GitHub.Cli/GitHub.Cli.pack.targets index a6a3a72..968eff0 100644 --- a/src/GitHub.Cli/GitHub.Cli.pack.targets +++ b/src/GitHub.Cli/GitHub.Cli.pack.targets @@ -40,7 +40,7 @@ <_GitHubCliRid Include="$(RuntimeIdentifiers)" /> - + @@ -69,7 +69,7 @@ - + gh/%(RecursiveDir)%(Filename)%(Extension) diff --git a/src/GitHub.Cli/build/GitHub.Cli.targets b/src/GitHub.Cli/build/GitHub.Cli.targets index 2739519..95d1875 100644 --- a/src/GitHub.Cli/build/GitHub.Cli.targets +++ b/src/GitHub.Cli/build/GitHub.Cli.targets @@ -1,3 +1,3 @@ - + diff --git a/src/GitHub.Cli/buildTransitive/GitHub.Cli.targets b/src/GitHub.Cli/buildTransitive/GitHub.Cli.targets index 6d64c7f..939aba1 100644 --- a/src/GitHub.Cli/buildTransitive/GitHub.Cli.targets +++ b/src/GitHub.Cli/buildTransitive/GitHub.Cli.targets @@ -14,7 +14,7 @@ <_GitHubCliVersion>$([System.IO.Path]::GetFileName($([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..')))) - <_GitHubCliPackageFolder>$([System.String]::Copy('github.cli.$(_GitHubCliRid)').ToLowerInvariant()) + <_GitHubCliPackageFolder>$([System.String]::Copy('gh.cli.$(_GitHubCliRid)').ToLowerInvariant()) $(NuGetPackageRoot)$(_GitHubCliPackageFolder)\$(_GitHubCliVersion)\gh @@ -23,7 +23,7 @@ Condition="'$(GitHubCliPayloadRoot)' != ''"> + Text="gh.cli payload not found at '$(GitHubCliPayloadRoot)'. Pack gh.cli -r $(RuntimeIdentifier) first and restore from $(PackageOutputPath)." /> <_GitHubCliPayloadFiles Include="$(GitHubCliPayloadRoot)\**\*" /> diff --git a/src/Tests/CliTests.cs b/src/Tests/CliTests.cs index cc0aa75..859c469 100644 --- a/src/Tests/CliTests.cs +++ b/src/Tests/CliTests.cs @@ -31,6 +31,7 @@ public void ResolvePath_throws_when_missing() { var ex = Assert.Throws(() => GitHub.Cli.ResolvePath(root)); Assert.Contains("gh", ex.FileName, StringComparison.OrdinalIgnoreCase); + Assert.Contains("gh.cli", ex.Message, StringComparison.Ordinal); } finally { diff --git a/src/Tests/PackTests.cs b/src/Tests/PackTests.cs index 160769e..b1224bb 100644 --- a/src/Tests/PackTests.cs +++ b/src/Tests/PackTests.cs @@ -23,14 +23,17 @@ public void Pointer_and_rid_csproj_use_pack_split() Assert.Contains("src/gh/gh.csproj", slnx); var githubCli = File.ReadAllText(Path.Combine(repo, "src", "GitHub.Cli", "GitHub.Cli.csproj")); - Assert.Contains("GitHub.Cli", githubCli); + Assert.Contains("gh.cli", githubCli); Assert.Contains("GitHub", githubCli); + Assert.Contains("PackageReference gh.cli", githubCli); Assert.Contains("GitHub.Cli.ResolvePath", githubCli); Assert.Contains("win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64", githubCli); Assert.DoesNotContain("NuGetizer", githubCli, StringComparison.OrdinalIgnoreCase); Assert.DoesNotContain("gh\", consumer.Replace('/', '\\')); Assert.DoesNotContain("runtimes/$(RuntimeIdentifier)/native/", consumer); @@ -79,13 +86,14 @@ public void Pointer_and_rid_csproj_use_pack_split() Assert.Contains("dotnet-gh", tool); Assert.Contains("dotnet-gh", tool); Assert.Contains("win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64", tool); - Assert.Contains("""""", tool); + Assert.Contains("""""", tool); Assert.DoesNotContain("NuGetizer", tool, StringComparison.OrdinalIgnoreCase); Assert.Contains("Readme", tool); var nuget = File.ReadAllText(Path.Combine(repo, "src", "gh", "nuget.config")); Assert.Contains("key=\"local\"", nuget); Assert.Contains("../../bin", nuget); - Assert.Contains("GitHub.Cli", nuget); + Assert.Contains("package pattern=\"gh.cli\"", nuget); + Assert.Contains("package pattern=\"gh.cli.*\"", nuget); Assert.Contains("package pattern=\"gh\"", nuget); Assert.DoesNotContain("win-arm64", tool); Assert.DoesNotContain("gh.$(RuntimeIdentifier)", tool); @@ -139,8 +147,8 @@ public void WriteGitHubCliRuntimeJson_maps_five_rids() { var range = runtimes .GetProperty(rid) - .GetProperty("GitHub.Cli") - .GetProperty("GitHub.Cli." + rid) + .GetProperty("gh.cli") + .GetProperty("gh.cli." + rid) .GetString(); Assert.False(string.IsNullOrWhiteSpace(range)); Assert.StartsWith("[", range); @@ -157,7 +165,7 @@ public void Packed_nupkgs_have_pointer_and_rid_layout() if (!Directory.Exists(bin)) return; - var nupkgs = Directory.GetFiles(bin, "GitHub.Cli*.nupkg") + var nupkgs = Directory.GetFiles(bin, "gh.cli*.nupkg") .Where(f => !f.Contains(".symbols.", StringComparison.OrdinalIgnoreCase)) .ToArray(); if (nupkgs.Length == 0) @@ -170,7 +178,8 @@ public void Packed_nupkgs_have_pointer_and_rid_layout() var names = ZipNames(pointer); Assert.Contains(names, n => n == "runtime.json" || n == "runtime.json/"); Assert.Contains(names, n => n.Replace('\\', '/').StartsWith("lib/", StringComparison.Ordinal)); - Assert.Contains(names, n => n.Replace('\\', '/').Contains("buildTransitive/GitHub.Cli.targets", StringComparison.Ordinal)); + Assert.Contains(names, n => n.Replace('\\', '/').Contains("buildTransitive/gh.cli.targets", StringComparison.Ordinal)); + Assert.Contains(names, n => n.Replace('\\', '/').Contains("build/gh.cli.targets", StringComparison.Ordinal)); Assert.DoesNotContain(names, n => n.Replace('\\', '/').StartsWith("gh/", StringComparison.Ordinal)); } @@ -188,9 +197,14 @@ public void Packed_nupkgs_have_pointer_and_rid_layout() } foreach (var toolRid in Directory.GetFiles(bin, "gh.*.nupkg") - .Where(f => !f.Contains(".symbols.", StringComparison.OrdinalIgnoreCase) - && SupportedRids.Any(r => Path.GetFileName(f).Contains("." + r + ".", StringComparison.Ordinal) - && !Path.GetFileName(f).Contains(".win-", StringComparison.Ordinal)))) + .Where(f => + { + var name = Path.GetFileName(f); + return !name.Contains(".symbols.", StringComparison.OrdinalIgnoreCase) + && !name.StartsWith("gh.cli.", StringComparison.OrdinalIgnoreCase) + && SupportedRids.Any(r => name.Contains("." + r + ".", StringComparison.Ordinal) + && !name.Contains(".win-", StringComparison.Ordinal)); + })) { AssertUnixExecuteBits(toolRid); } diff --git a/src/Tests/ReleaseTests.cs b/src/Tests/ReleaseTests.cs index 722ef89..3f6cfa2 100644 --- a/src/Tests/ReleaseTests.cs +++ b/src/Tests/ReleaseTests.cs @@ -56,7 +56,7 @@ public void Publish_version_does_not_double_append_preview() Assert.DoesNotContain("Expand-Archive", publish); Assert.DoesNotContain("tar -xf $nupkg", publish); Assert.Contains("package-pointer", publish); - Assert.Contains("bin/GitHub.Cli.${{ matrix.rid }}.*.nupkg", publish); + Assert.Contains("bin/gh.cli.${{ matrix.rid }}.*.nupkg", publish); Assert.DoesNotContain("python3-pip", publish); Assert.DoesNotContain("apt-get install -y python3-pip", publish); } diff --git a/src/gh/gh.csproj b/src/gh/gh.csproj index 3d85624..a830334 100644 --- a/src/gh/gh.csproj +++ b/src/gh/gh.csproj @@ -20,12 +20,12 @@ - + diff --git a/src/gh/nuget.config b/src/gh/nuget.config index fc2c5d8..d700f11 100644 --- a/src/gh/nuget.config +++ b/src/gh/nuget.config @@ -17,8 +17,8 @@ - - + +