Skip to content

Commit

Permalink
Use changelog to generate release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ImoutoChan committed Oct 29, 2023
1 parent f2e150a commit a994dd5
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}

- name: Pack 7ZSfx installer
run: .\Tools\NukeBuild\build.cmd Test Pack7ZSfx
run: .\Tools\NukeBuild\build.cmd Test Pack7ZSfx PrepareChangelog

- name: Upload 7ZSfx installer to github release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1.0.0
with:
files: ./Artifacts/ImoutoRebirth-*.*
body: ImoutoRebirth-*.exe is a self-extracting 7z archive. You can use it directly, or download the 7z archive itself. Please read the installation instructions in the [README](https://github.com/ImoutoChan/ImoutoRebirth#installation) for more information.
body_path: ./CHANGELOG.RESULT.md
name: ImoutoRebirth ${{ steps.gitversion.outputs.majorMinorPatch }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules/
/Source/Imouto.Extensions/chrome/src/dist/*
/Source/.vs/*
/Source/ImoutoRebirth.Hasami/appsettings.json
/CHANGELOG.RESULT.md
2 changes: 2 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"Clean",
"Compile",
"Pack7ZSfx",
"PrepareChangelog",
"Publish",
"Restore",
"Test"
Expand All @@ -94,6 +95,7 @@
"Clean",
"Compile",
"Pack7ZSfx",
"PrepareChangelog",
"Publish",
"Restore",
"Test"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ImoutoRebirth-*.exe is a self-extracting 7z archive. You can use it directly, or download the 7z archive itself.
For more information please read the installation instructions in the [README](https://github.com/ImoutoChan/ImoutoRebirth#installation).
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@

### Infrastructure
* Add changelog file
* Add build step to create release notes body based on latest changelog
1 change: 1 addition & 0 deletions Source/ImoutoRebirth.sln
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{2438D898
..\README.RU.md = ..\README.RU.md
..\.github\workflows\release.yml = ..\.github\workflows\release.yml
..\CHANGELOG.md = ..\CHANGELOG.md
..\CHANGELOG.TEMPLATE.md = ..\CHANGELOG.TEMPLATE.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NukeBuild", "..\Tools\NukeBuild\NukeBuild.csproj", "{DBC3E098-5984-4FD6-9F83-18FBE9A23683}"
Expand Down
28 changes: 28 additions & 0 deletions Tools/NukeBuild/Build.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Nuke.Common;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.IO;
Expand Down Expand Up @@ -175,4 +177,30 @@ AbsolutePath[] GetDirectoriesToDelete(string projectName, AbsolutePath projectOu
.SetOutputArchiveFile(OutputLatestDirectory.Parent / $"{VersionedName}.7z")
.SetSourceDirectory(OutputLatestDirectory));
});

Target PrepareChangelog => _ => _
.Executes(() =>
{
var changelog = RootDirectory / "CHANGELOG.md";
var changelogResult = RootDirectory / "CHANGELOG.RESULT.md";
var changelogTemplate = RootDirectory / "CHANGELOG.TEMPLATE.md";

var changelogTemplateContent = File.ReadAllText(changelogTemplate);

var changelogContent = new StringBuilder();
changelogContent.AppendLine($"# {GitVersion.NuGetVersionV2}");
foreach (var changeLogLine in File.ReadLines(changelog))
{
if (changeLogLine.StartsWith("# Unreleased"))
continue;

if (changeLogLine.StartsWith("# "))
break;

changelogContent.AppendLine(changeLogLine);
}

var newChangelogContent = changelogTemplateContent + Environment.NewLine + changelogContent;
File.WriteAllText(changelogResult, newChangelogContent);
});
}

0 comments on commit a994dd5

Please sign in to comment.