Skip to content

Commit 9fe5406

Browse files
committed
Add publish workflow
1 parent e23ee1a commit 9fe5406

File tree

4 files changed

+68
-11
lines changed

4 files changed

+68
-11
lines changed

.github/workflows/publish.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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_publish --host GitHubActions
13+
#
14+
# </auto-generated>
15+
# ------------------------------------------------------------------------------
16+
17+
name: publish
18+
19+
on:
20+
push:
21+
tags:
22+
- 'v[0-9]+.[0-9]+.[0-9]+'
23+
24+
jobs:
25+
ubuntu-latest:
26+
name: ubuntu-latest
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
31+
uses: actions/cache@v3
32+
with:
33+
path: |
34+
.nuke/temp
35+
~/.nuget/packages
36+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
37+
- name: 'Run: Publish'
38+
run: ./build.cmd Publish
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
- name: 'Publish: TestResults'
42+
uses: actions/upload-artifact@v3
43+
if: always()
44+
with:
45+
name: TestResults
46+
path: tests/TestResults

.github/workflows/tests.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
ubuntu-latest:
2626
name: ubuntu-latest
2727
runs-on: ubuntu-latest
28+
concurrency:
29+
group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.run_id }}
30+
cancel-in-progress: true
2831
steps:
2932
- uses: actions/checkout@v3
3033
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
@@ -34,8 +37,8 @@ jobs:
3437
.nuke/temp
3538
~/.nuget/packages
3639
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
37-
- name: 'Run: Publish'
38-
run: ./build.cmd Publish
40+
- name: 'Run: Test'
41+
run: ./build.cmd Test
3942
env:
4043
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4144
- name: 'Publish: TestResults'

build/Build.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@
2222
[GitHubActions("tests",
2323
GitHubActionsImage.UbuntuLatest,
2424
OnPushBranches = new[] { "main" },
25+
InvokedTargets = new[] { nameof(Test) },
26+
PublishCondition = "always()",
27+
EnableGitHubToken = true,
28+
JobConcurrencyCancelInProgress = true
29+
)]
30+
[GitHubActions("publish",
31+
GitHubActionsImage.UbuntuLatest,
2532
InvokedTargets = new[] { nameof(Publish) },
2633
PublishCondition = "always()",
27-
EnableGitHubToken = true
34+
EnableGitHubToken = true,
35+
OnPushTags = new[] { "v[0-9]+.[0-9]+.[0-9]+" }
2836
)]
2937
class Build : NukeBuild, ICheckForUnityMetaFiles, IUnityPackageVersionMatchesGitTagVersion, IChangelogVersionMatchesGitTagVersion, IPublishGitHubRelease
3038
{
31-
public static int Main() => Execute<Build>(x => x.Publish);
39+
public static int Main() => Execute<Build>(x => x.Test);
3240

3341
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
3442
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;

build/IPublishGitHubRelease.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ interface IPublishGitHubRelease : INukeBuild
1919
[Parameter] AbsolutePath ChangelogFile => TryGetValue(() => ChangelogFile);
2020

2121
Target PublishGitHubRelease => _ => _
22-
// .OnlyWhenStatic(() => GitRepository.CurrentCommitHasVersionTag())
23-
// .OnlyWhenStatic(() => IsServerBuild)
24-
// .DependsOn<IUnityPackageVersionMatchesGitTagVersion>()
25-
// .DependsOn<IChangelogVersionMatchesGitTagVersion>()
22+
.OnlyWhenStatic(() => GitRepository.CurrentCommitHasVersionTag())
23+
.OnlyWhenStatic(() => IsServerBuild)
24+
.DependsOn<IUnityPackageVersionMatchesGitTagVersion>()
25+
.DependsOn<IChangelogVersionMatchesGitTagVersion>()
2626
.Executes(async () =>
2727
{
2828
Assert.True(ChangelogFile != null, "No path has been provided!");
@@ -35,7 +35,7 @@ interface IPublishGitHubRelease : INukeBuild
3535

3636
SemanticVersion version = GitRepository.GetLatestVersionTagOnCurrentCommit();
3737

38-
var release = new NewRelease($"v{version}")
38+
var releaseDraft = new NewRelease($"v{version}")
3939
{
4040
Draft = true,
4141
Name = $"v{version}",
@@ -51,8 +51,8 @@ interface IPublishGitHubRelease : INukeBuild
5151

5252
Log.Information("Creating GitHub release...");
5353

54-
Release createdRelease = await GitHubTasks.GitHubClient.Repository.Release.Create(owner, name, release);
54+
Release release = await GitHubTasks.GitHubClient.Repository.Release.Create(owner, name, releaseDraft);
5555

56-
// await GitHubTasks.GitHubClient.Repository.Release.Edit(owner, name, createdRelease.Id, new ReleaseUpdate { Draft = false });
56+
await GitHubTasks.GitHubClient.Repository.Release.Edit(owner, name, release.Id, new ReleaseUpdate { Draft = false });
5757
});
5858
}

0 commit comments

Comments
 (0)