Skip to content

Commit 00e8561

Browse files
committed
Readme & changelog files in build folders
1 parent a31a188 commit 00e8561

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

Editor/BuildManager/BuildPipeline/BuildManager.cs

+78
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,65 @@ static void Build(BuildManagerSettings settings, BuildSequence sequence) {
9696
}
9797

9898
static void PostBuild(BuildSequence sequence) {
99+
bool isNeedChangelogFile = usedChangelog.versions.Count != 0;
100+
bool isNeedReadmeFile = !string.IsNullOrEmpty(usedChangelog.readme);
101+
string changelogContent = "";
102+
string readmeContent = usedChangelog.readme;
103+
104+
if (isNeedChangelogFile) {
105+
StringBuilder sb = new StringBuilder();
106+
107+
ChangelogData.ChangelogEntryType lastType;
108+
ChangelogData.ChangelogEntryScope lastScope;
109+
110+
111+
for (int i = usedChangelog.versions.Count - 1; i >= 0; --i) {
112+
lastType = (ChangelogData.ChangelogEntryType)255;
113+
lastScope = (ChangelogData.ChangelogEntryScope)255;
114+
ChangelogData.ChangelogVersionEntry version = usedChangelog.versions[i];
115+
116+
if(i != usedChangelog.versions.Count - 1) {
117+
sb.Append("---------- \n");
118+
119+
}
120+
sb.Append("# ");
121+
sb.Append(version.GetVersionHeader());
122+
sb.Append("\n");
123+
124+
sb.Append(version.descriptionText);
125+
sb.Append("\n\n");
126+
127+
for (int j = 0; j < version.notes.Count; ++j) {
128+
ChangelogData.ChangelogNoteEntry note = version.notes[j];
129+
130+
if(lastType != note.type) {
131+
if(lastType != (ChangelogData.ChangelogEntryType)255)
132+
sb.Append("\n");
133+
lastType = note.type;
134+
lastScope = (ChangelogData.ChangelogEntryScope)255;
135+
sb.Append("## ");
136+
sb.Append(note.type);
137+
sb.Append(": \n");
138+
}
139+
140+
if (lastScope != note.scope) {
141+
lastScope = note.scope;
142+
sb.Append("### ");
143+
sb.Append(note.scope);
144+
sb.Append(": \n");
145+
}
146+
147+
sb.Append(" * ");
148+
sb.Append(note.text);
149+
sb.Append("\n");
150+
}
151+
152+
sb.Append("\n");
153+
}
154+
155+
changelogContent = sb.ToString();
156+
}
157+
99158
for (byte i = 0; i < sequence.builds.Count; ++i) {
100159
if (!sequence.builds[i].isEnabled)
101160
continue;
@@ -125,6 +184,25 @@ static void PostBuild(BuildSequence sequence) {
125184
process.Start();
126185
}
127186
#endif
187+
188+
if(sequence.builds[i].targetGroup == BuildTargetGroup.Standalone) {
189+
string path = Path.Combine(sequence.builds[i].outputRoot + GetPathWithVars(sequence.builds[i], sequence.builds[i].middlePath)).Replace(@"/", @"\");
190+
path = path.Substring(0, path.LastIndexOf("\\"));
191+
192+
if (isNeedChangelogFile) {
193+
File.WriteAllText(
194+
Path.Combine(path, "Changelog.txt"),
195+
changelogContent
196+
);
197+
}
198+
199+
if (isNeedReadmeFile) {
200+
File.WriteAllText(
201+
Path.Combine(path, "Readme.txt"),
202+
readmeContent
203+
);
204+
}
205+
}
128206
}
129207
}
130208
}

Editor/Changelog/ChangelogData.cs

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
public class ChangelogData {
1010

1111
public List<ChangelogVersionEntry> versions = new List<ChangelogVersionEntry>() { new ChangelogVersionEntry() };
12+
[TextArea(3, 10)] public string readme;
1213

1314
public ChangelogVersionEntry GetLastVersion() {
1415
if (versions.Count == 0)
@@ -68,6 +69,8 @@ public class ChangelogVersionEntry {
6869
public string date;
6970
public string updateName;
7071

72+
public string descriptionText;
73+
7174
public List<ChangelogNoteEntry> notes = new List<ChangelogNoteEntry>();
7275

7376
public string GetVersionHeader() {

Editor/Window/BuildManagerWindow.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ void DrawChangelogInfo() {
137137
scrollPosChangelog = EditorGUILayout.BeginScrollView(scrollPosChangelog/*, GUILayout.Height(800f)*/);
138138
++EditorGUI.indentLevel;
139139

140-
140+
EditorGUILayout.LabelField("Readme");
141+
changelog.readme = EditorGUILayout.TextArea(changelog.readme);
141142
GUILayout.Space(10f);
143+
142144
EditorGUILayout.BeginHorizontal();
143145
EditorGUILayout.LabelField("Changelog file:", GUILayout.Width(100));
144146
if (GUILayout.Button($"Add version"))
@@ -178,6 +180,7 @@ void DrawChangelogInfo() {
178180
EditorGUILayout.EndHorizontal();
179181

180182
version.updateName = EditorGUILayout.TextField("Update name", version.updateName);
183+
version.descriptionText = EditorGUILayout.TextField("Description", version.descriptionText);
181184

182185
EditorGUILayout.LabelField("Notes: ");
183186

0 commit comments

Comments
 (0)