Skip to content

Commit 374b44c

Browse files
committed
👷‍♀️ extract release into new github action
1 parent f884d90 commit 374b44c

File tree

4 files changed

+60
-17
lines changed

4 files changed

+60
-17
lines changed

.github/workflows/continuous.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ jobs:
3131
.nuke/temp
3232
~/.nuget/packages
3333
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
34-
- name: 'Run: Publish'
35-
run: ./build.cmd Publish
36-
env:
37-
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
34+
- name: 'Run: Test, Pack'
35+
run: ./build.cmd Test Pack
3836
- name: 'Publish: artifacts'
3937
uses: actions/upload-artifact@v4
4038
with:

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# ------------------------------------------------------------------------------
2+
# <auto-generated>
3+
#
4+
# This code was generated.
5+
#
6+
# - To turn off auto-generation set:
7+
#
8+
# [GitHubActions (AutoGenerate = false)]
9+
#
10+
# - To trigger manual generation invoke:
11+
#
12+
# nuke --generate-configuration GitHubActions_release --host GitHubActions
13+
#
14+
# </auto-generated>
15+
# ------------------------------------------------------------------------------
16+
17+
name: release
18+
19+
on:
20+
push:
21+
branches:
22+
- main
23+
tags:
24+
- '[0-9]+.[0-9]+.[0-9]+'
25+
26+
jobs:
27+
ubuntu-latest:
28+
name: ubuntu-latest
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
33+
uses: actions/cache@v4
34+
with:
35+
path: |
36+
.nuke/temp
37+
~/.nuget/packages
38+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
39+
- name: 'Run: Publish'
40+
run: ./build.cmd Publish
41+
env:
42+
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
43+
- name: 'Publish: artifacts'
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: artifacts
47+
path: artifacts

.nuke/build.schema.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"enum": [
2727
"Clean",
2828
"Compile",
29-
"Info",
3029
"Pack",
3130
"Publish",
3231
"Test"

build/Build.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
"continuous",
1616
GitHubActionsImage.UbuntuLatest,
1717
On = [GitHubActionsTrigger.Push],
18+
InvokedTargets = [nameof(Test), nameof(Pack)])]
19+
[GitHubActions(
20+
"release",
21+
GitHubActionsImage.UbuntuLatest,
22+
OnPushBranches = ["main"],
23+
OnPushTags = ["[0-9]+.[0-9]+.[0-9]+"],
1824
ImportSecrets = [nameof(NuGetApiKey)],
1925
InvokedTargets = [nameof(Publish)])]
2026
[GitHubActions(
@@ -32,27 +38,21 @@ class Build : NukeBuild {
3238
[Parameter($"NuGet API key - Required for target {nameof(Publish)}"), Secret]
3339
readonly string NuGetApiKey = null!;
3440

35-
string? CurrSemVer => Repository.Tags.SingleOrDefault();
41+
bool IsRelease => Version.TryParse(Repository.Tags.SingleOrDefault(), out _);
42+
43+
string CurrSemVer => Repository.Tags.Single();
3644

3745
string? prevSemVer;
3846
string PrevSemVer => prevSemVer ??= Git($"describe --tags --abbrev=0 HEAD^").Single().Text;
3947

40-
string SemVer => CurrSemVer ?? $"{PrevSemVer}-{Repository.Branch}-{Repository.Commit[..7]}";
48+
string SemVer => IsRelease ? CurrSemVer : $"{PrevSemVer}-{Repository.Branch}-{Repository.Commit[..7]}";
4149

4250
string? releaseNotes;
4351
string ReleaseNotes => releaseNotes ??= Git($"log {PrevSemVer}.. --format=%s").Select(o => o.Text).Join(Environment.NewLine);
4452

4553
AbsolutePath ArtifactsDir => RootDirectory / "artifacts";
4654
AbsolutePath PackagePath => ArtifactsDir / $"{Solution.Json5.Name}.{SemVer}.nupkg";
4755

48-
Target Info => t => t
49-
.Executes(() => {
50-
Log.Information("CurrSemVer {0}", CurrSemVer);
51-
Log.Information("PrevSemVer {0}", PrevSemVer);
52-
Log.Information("SemVer {0}", SemVer);
53-
Log.Information("ReleaseNotes {0}", ReleaseNotes);
54-
});
55-
5656
Target Clean => t => t
5757
.Executes(() => ArtifactsDir.DeleteDirectory());
5858

@@ -90,9 +90,8 @@ class Build : NukeBuild {
9090

9191
Target Publish => t => t
9292
.DependsOn(Test, Pack)
93-
.Requires(() => Repository.IsOnMainBranch())
9493
.Requires(() => NuGetApiKey)
95-
.OnlyWhenDynamic(() => Repository.Tags.Count != 0)
94+
.Requires(() => Repository.IsOnMainBranch() && IsRelease)
9695
.Executes(() => /*DotNetNuGetPush(opts => opts
9796
.SetTargetPath(PackagePath)
9897
.SetSource("https://api.nuget.org/v3/index.json")

0 commit comments

Comments
 (0)