Skip to content

Commit

Permalink
Attempt to fix gitversion info based on the branch being detached (#1645
Browse files Browse the repository at this point in the history
)
  • Loading branch information
david-driscoll authored Nov 12, 2023
1 parent 920b7cb commit 6e738cb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
25 changes: 20 additions & 5 deletions .build/Build.CI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,33 @@ public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware(RocketS

public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(RocketSurgeonGitHubActionsConfiguration configuration)
{
configuration
.ExcludeRepositoryConfigurationFiles()
.AddNugetPublish()
.Jobs.OfType<RocketSurgeonsGithubActionsJob>()
.First(z => z.Name.Equals("build", StringComparison.OrdinalIgnoreCase))
var job = configuration
.ExcludeRepositoryConfigurationFiles()
.AddNugetPublish()
.Jobs.OfType<RocketSurgeonsGithubActionsJob>()
.First(z => z.Name.Equals("build", StringComparison.OrdinalIgnoreCase));
job
.UseDotNetSdks("6.0", "7.0")
.AddNuGetCache()
// .ConfigureForGitVersion()
.ConfigureStep<CheckoutStep>(step => step.FetchDepth = 0)
.PublishLogs<Pipeline>()
.FailFast = false;

job.Steps.Insert(
GetCheckStepIndex(job), new RunStep("Create branch for tag (gitversion)")
{
If = "(github.ref_type == 'tag')",
Run = "git checkout -b ci/${{ github.ref }}"
}
);

return configuration;
}

private static int GetCheckStepIndex(RocketSurgeonsGithubActionsJob job)
{
var checkoutStep = job.Steps.OfType<CheckoutStep>().SingleOrDefault();
return checkoutStep is null ? 1 : job.Steps.IndexOf(checkoutStep);
}
}
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ jobs:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Create branch for tag (gitversion)
if: (github.ref_type == 'tag')
run: |
git checkout -b ci/${{ github.ref }}
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
Expand Down

0 comments on commit 6e738cb

Please sign in to comment.