Skip to content

Commit

Permalink
Fixes release script with tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
Richiban committed Nov 19, 2024
1 parent a8937f3 commit 528801e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
filter: tree:0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
Expand Down
20 changes: 9 additions & 11 deletions Consolo/Writers/ProgramClassFileGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ private void WriteHelp(
.Append(("-?, -h, --help", "Show help and usage information", None));

var longestParameter = helpNames.MaxOrDefault(x => x.Item1.Length);
var leadingWhitespace = new string(' ', longestParameter);

foreach (var (helpName, description, allowedValues) in helpNames)
{
Expand All @@ -531,17 +532,14 @@ private void WriteHelp(
{
var valueName = allowedValue.HelpName;
var valueDescription = allowedValue.Description;

if (valueDescription.HasValue)
{
_codeBuilder.AppendLine(
$"Console.WriteLine(\" {new string(' ', longestParameter)}- {valueName}: {valueDescription}\");");
}
else
{
_codeBuilder.AppendLine(
$"Console.WriteLine(\" {new string(' ', longestParameter)}- {valueName}\");");
}

var valueHelpText =
valueDescription.HasValue
? $"{valueName}: {valueDescription}"
: $"{valueName}";

_codeBuilder.AppendLine(
$"Console.WriteLine(\"{leadingWhitespace} - {valueHelpText}\");");
}

_codeBuilder.AppendLine("Console.ForegroundColor = consoleColor;");
Expand Down
20 changes: 12 additions & 8 deletions release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ dotnet build

dotnet test

dotnet pack Consolo -o .

$projectXml = [xml](Get-Content .\Consolo\Consolo.csproj)

$version = $projectXml.Project.PropertyGroup[1].version
Expand All @@ -19,18 +17,18 @@ Write-Host "Version: $version"

$tagName = "release/$version"

write-host "Debug: git tags"

git tag -l

$versionAlreadyTagged = git tag -l $tagName

if ($versionAlreadyTagged) {
Write-Host "Version $version already tagged"
exit 0
}

Write-Host "Creating tag $tagName"

git tag $tagName

git push origin tag $tagName
dotnet pack Consolo -o .

$nupkg = get-item Consolo.$version.nupkg

Expand All @@ -44,4 +42,10 @@ write-host $nupkg
dotnet nuget push `
$nupkg `
--api-key $env:NUGET_API_KEY_CONSOLO_CI `
--source https://api.nuget.org/v3/index.json
--source https://api.nuget.org/v3/index.json

Write-Host "Creating tag $tagName"

git tag $tagName

git push origin tag $tagName

0 comments on commit 528801e

Please sign in to comment.