Skip to content

Commit d084087

Browse files
committed
Added changelog system and made default version 0.0.0.0
1 parent 3f3512b commit d084087

6 files changed

Lines changed: 171 additions & 4 deletions

File tree

.github/workflows/build.yaml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,46 @@ jobs:
3535
echo "Last modified file version: $version"
3636
echo "version=$version" >> $GITHUB_OUTPUT
3737
38+
- name: Extract changelog for version
39+
id: changelog
40+
run: |
41+
if [ -f "CHANGELOG.json" ]; then
42+
version="${{ steps.getfile.outputs.version }}"
43+
# Extract changelog for this version from JSON
44+
changelog=$(node -e "
45+
const fs = require('fs');
46+
const data = JSON.parse(fs.readFileSync('CHANGELOG.json', 'utf-8'));
47+
if (data['$version']) {
48+
const v = data['$version'];
49+
let output = [];
50+
if (v.added) output.push('**Added:**\\n' + v.added);
51+
if (v.changed) output.push('**Changed:**\\n' + v.changed);
52+
if (v.fixed) output.push('**Fixed:**\\n' + v.fixed);
53+
console.log(output.join('\\n\\n'));
54+
}
55+
")
56+
if [ -n "$changelog" ]; then
57+
echo "Found changelog for version ${{ steps.getfile.outputs.version }}"
58+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
59+
echo "$changelog" >> $GITHUB_OUTPUT
60+
echo "EOF" >> $GITHUB_OUTPUT
61+
echo "has_changelog=true" >> $GITHUB_OUTPUT
62+
else
63+
echo "No changelog entry found for this version"
64+
echo "has_changelog=false" >> $GITHUB_OUTPUT
65+
fi
66+
else
67+
echo "No CHANGELOG.json file found"
68+
echo "has_changelog=false" >> $GITHUB_OUTPUT
69+
fi
70+
3871
- name: Create Release
3972
id: create_release
4073
uses: ncipollo/release-action@v1
4174
with:
4275
artifacts: "dist/${{ steps.getfile.outputs.filename }}"
43-
omitBody: true
76+
body: ${{ steps.changelog.outputs.has_changelog == 'true' && steps.changelog.outputs.changelog || '' }}
77+
omitBody: ${{ steps.changelog.outputs.has_changelog != 'true' }}
4478
tag: ${{ steps.getfile.outputs.filename }}
4579
name: v${{ steps.getfile.outputs.version }}
4680
allowUpdates: true
@@ -80,10 +114,15 @@ jobs:
80114
- name: Publish to Construct 3
81115
if: steps.check.outputs.publish == 'true'
82116
run: |
117+
if [ "${{ steps.changelog.outputs.has_changelog }}" = "true" ]; then
118+
release_notes="${{ steps.changelog.outputs.changelog }}"
119+
else
120+
release_notes="Released via GitHub Actions"
121+
fi
83122
c3addon publish \
84123
--addonUrl '${{steps.url.outputs.url}}' \
85124
--authUser ${{ secrets.C3_AUTH_USER }} \
86125
--authPassword ${{ secrets.C3_AUTH_PASSWORD }} \
87126
--uploadFile dist/${{ steps.getfile.outputs.filename }} \
88127
--version ${{ steps.getfile.outputs.version }} \
89-
--releaseNotes 'Released via GitHub Actions'
128+
--releaseNotes "$release_notes"

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"javascript.updateImportsOnFileMove.enabled": "never",
3-
"files.exclude": {
3+
".files.exclude": {
44
"build": true,
55
"generated": true,
66
"template": true,

CHANGELOG.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"0.0.0.0": {
3+
"added": "Scaffolded project setup with basic structure and dependencies.",
4+
"changed": "",
5+
"fixed": ""
6+
}
7+
}

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
<br>
88
<sub> [See all releases](https://github.com/ConstructFund/construct-addon-wizard-scaffold/releases) </sub> <br>
99

10+
#### What's New in 1.0.0.0
11+
**Added:**
12+
Initial release with example actions, conditions, and expressions. Support for async actions and trigger conditions.
13+
14+
15+
<sub>[View full changelog](#changelog)</sub>
16+
1017
---
1118
<b><u>Author:</u></b> skymen <br>
1219
<sub>Made using [CAW](https://marketplace.visualstudio.com/items?itemName=skymen.caw) </sub><br>
@@ -69,3 +76,14 @@ npm run dev
6976
| Expression2 | Sample Expression | string | |
7077
| Expression | Sample Expression | number | |
7178
| SampleExpression | This is a sample expression | string | |
79+
80+
81+
---
82+
## Changelog
83+
84+
### Version 1.0.0.0
85+
86+
**Added:**
87+
Initial release with example actions, conditions, and expressions. Support for async actions and trigger conditions.
88+
89+
---

build/generateDocumentation.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,78 @@ function getFileExtension(filename) {
3030
return filename.slice(((filename.lastIndexOf(".") - 1) >>> 0) + 2);
3131
}
3232

33+
function formatChangelogEntry(versionData) {
34+
const changes = [];
35+
36+
if (versionData.added) {
37+
changes.push(`**Added:**`);
38+
changes.push(versionData.added);
39+
changes.push("");
40+
}
41+
42+
if (versionData.changed) {
43+
changes.push(`**Changed:**`);
44+
changes.push(versionData.changed);
45+
changes.push("");
46+
}
47+
48+
if (versionData.fixed) {
49+
changes.push(`**Fixed:**`);
50+
changes.push(versionData.fixed);
51+
}
52+
53+
return changes;
54+
}
55+
56+
function getLatestChangelog(version) {
57+
const changelogPath = path.join(__dirname, "CHANGELOG.json");
58+
if (!fs.existsSync(changelogPath)) {
59+
return null;
60+
}
61+
62+
try {
63+
const changelogContent = fs.readFileSync(changelogPath, "utf-8");
64+
const changelog = JSON.parse(changelogContent);
65+
66+
if (!changelog[version]) {
67+
return null;
68+
}
69+
70+
const changes = formatChangelogEntry(changelog[version]);
71+
return changes.length > 0 ? changes.join("\n") : null;
72+
} catch (e) {
73+
return null;
74+
}
75+
}
76+
77+
function getAllChangelogs() {
78+
const changelogPath = path.join(__dirname, "CHANGELOG.json");
79+
if (!fs.existsSync(changelogPath)) {
80+
return null;
81+
}
82+
83+
try {
84+
const changelogContent = fs.readFileSync(changelogPath, "utf-8");
85+
const changelog = JSON.parse(changelogContent);
86+
87+
// Sort versions in descending order (newest first)
88+
const versions = Object.keys(changelog).sort((a, b) => {
89+
const aParts = a.split(".").map(Number);
90+
const bParts = b.split(".").map(Number);
91+
for (let i = 0; i < 4; i++) {
92+
if (aParts[i] !== bParts[i]) {
93+
return bParts[i] - aParts[i];
94+
}
95+
}
96+
return 0;
97+
});
98+
99+
return { changelog, versions };
100+
} catch (e) {
101+
return null;
102+
}
103+
}
104+
33105
const __dirname = path.resolve("../");
34106

35107
function getCoverImage() {
@@ -85,6 +157,16 @@ export default async function generateDocumentation() {
85157
readme.push("<br>");
86158
readme.push(`<sub> [See all releases](${githubUrl}/releases) </sub> <br>`);
87159

160+
// Add changelog section if CHANGELOG.json exists
161+
const latestChangelog = getLatestChangelog(config.version);
162+
if (latestChangelog) {
163+
readme.push("");
164+
readme.push(`#### What's New in ${config.version}`);
165+
readme.push(latestChangelog);
166+
readme.push("");
167+
readme.push(`<sub>[View full changelog](#changelog)</sub>`);
168+
}
169+
88170
readme.push("");
89171
readme.push("---");
90172
readme.push(`<b><u>Author:</u></b> ${config.author} <br>`);
@@ -269,6 +351,27 @@ export default async function generateDocumentation() {
269351
});
270352
readme.push(``);
271353

354+
// Add full changelog section if CHANGELOG.json exists
355+
const allChangelogs = getAllChangelogs();
356+
if (allChangelogs) {
357+
readme.push(``);
358+
readme.push(`---`);
359+
readme.push(`## Changelog`);
360+
readme.push(``);
361+
362+
allChangelogs.versions.forEach((version) => {
363+
const versionData = allChangelogs.changelog[version];
364+
readme.push(`### Version ${version}`);
365+
readme.push(``);
366+
367+
const formattedChanges = formatChangelogEntry(versionData);
368+
formattedChanges.forEach((line) => readme.push(line));
369+
370+
readme.push(`---`);
371+
readme.push(``);
372+
});
373+
}
374+
272375
fs.writeFileSync(path.join(__dirname, "README.md"), readme.join("\n"));
273376

274377
chalkUtils.success("README.md generated successfully");

version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default "1.0.0.0";
1+
export default "0.0.0.0";

0 commit comments

Comments
 (0)