Skip to content

Commit aac76ae

Browse files
authored
Merge pull request #16 from taj54/develop-changelog-add-process
Develop changelog add process
2 parents 599cb29 + ef8b55f commit aac76ae

11 files changed

Lines changed: 1789 additions & 538 deletions

File tree

.github/workflows/version-bump.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ on:
1717
- minor
1818
- major
1919

20-
21-
2220
jobs:
2321
bump:
2422
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ All notable changes for each version of the Ambient Music extension.
1010

1111
- Bumped version to v0.9.1.
1212

13+
### Fixed
14+
15+
- **changelog:** Strip prefixes like `feat:` and `fix:` from changelog entries.
16+
1317
## v0.9.0 2025 08 25
1418

1519
### Added
@@ -316,4 +320,4 @@ All notable changes for each version of the Ambient Music extension.
316320
- CI: Keep the versions up-to-date.
317321
- Updated.
318322
- Build: Update build script.
319-
- Updated readme.
323+
- Updated readme.

README.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ This action will automatically detect the version file and bump the version acco
1414

1515
The action will first try to detect the platform of the project by looking for common version files in the root directory. The following files are supported:
1616

17-
| Platform | Version File |
18-
| --- | --- |
19-
| Docker | `Dockerfile` |
20-
| Go | `go.mod` |
21-
| Node | `package.json` |
22-
| PHP | `composer.json` |
23-
| Python | `pyproject.toml`, `setup.py` |
24-
| Rust | `Cargo.toml` |
17+
| Platform | Version File |
18+
| -------- | ---------------------------- |
19+
| Docker | `Dockerfile` |
20+
| Go | `go.mod` |
21+
| Node | `package.json` |
22+
| PHP | `composer.json` |
23+
| Python | `pyproject.toml`, `setup.py` |
24+
| Rust | `Cargo.toml` |
2525

2626
If a version file is found, the action will bump the version in that file. If no version file is found, the action will fail.
2727

@@ -64,19 +64,19 @@ To explicitly target a platform, use the `target_platform` input:
6464

6565
## Inputs
6666

67-
| Name | Description | Default |
68-
| --- | --- | --- |
69-
| `release_type` | Select the version bump type (patch, minor, major) | `patch` |
70-
| `git_tag` | Whether to create a Git tag after bump | `true` |
71-
| `target_platform` | Explicitly specify the platform to update (e.g., `node`, `python`). If not provided, the platform will be detected automatically. | `''` |
72-
| `target_path` | The target path where the version bump should be applied. If not provided, the action will run in the root directory. | `.` |
67+
| Name | Description | Default |
68+
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------- |
69+
| `release_type` | Select the version bump type (patch, minor, major) | `patch` |
70+
| `git_tag` | Whether to create a Git tag after bump | `true` |
71+
| `target_platform` | Explicitly specify the platform to update (e.g., `node`, `python`). If not provided, the platform will be detected automatically. | `''` |
72+
| `target_path` | The target path where the version bump should be applied. If not provided, the action will run in the root directory. | `.` |
7373

7474
## Outputs
7575

76-
| Name | Description |
77-
| --- | --- |
78-
| `new_version` | The new bumped version |
79-
| `tag` | The created Git tag (if enabled) |
76+
| Name | Description |
77+
| ------------- | -------------------------------- |
78+
| `new_version` | The new bumped version |
79+
| `tag` | The created Git tag (if enabled) |
8080

8181
## Example Workflow
8282

@@ -100,8 +100,6 @@ on:
100100
- minor
101101
- major
102102
103-
104-
105103
jobs:
106104
bump:
107105
runs-on: ubuntu-latest
@@ -118,7 +116,6 @@ jobs:
118116
git_tag: false
119117
env:
120118
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121-
122119
```
123120

124121
## Development
@@ -135,4 +132,4 @@ This project is governed by the [Code of Conduct](CODE_OF_CONDUCT.md).
135132

136133
## License
137134

138-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
135+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

dist/index.js

Lines changed: 141 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* universal-version-bump v0.9.0
2+
* universal-version-bump v0.9.1
33
* Universal Version Bump
44
*
55
* Description: A GitHub Action to automatically bump versions across any app (Node, Python, PHP, Docker, etc.)
66
* Author: Taj <[email protected]>
77
* Homepage: https://github.com/taj54/universal-version-bump#readme
88
* License: MIT
9-
* Generated on Mon, 25 Aug 2025 10:58:18 GMT
9+
* Generated on Tue, 26 Aug 2025 10:10:42 GMT
1010
*/
1111
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
1212
/******/ var __webpack_modules__ = ({
@@ -32756,6 +32756,7 @@ var __importStar = (this && this.__importStar) || (function () {
3275632756
})();
3275732757
Object.defineProperty(exports, "__esModule", ({ value: true }));
3275832758
const services_1 = __nccwpck_require__(5234);
32759+
const utils_1 = __nccwpck_require__(9499);
3275932760
const updaters_1 = __nccwpck_require__(1384);
3276032761
const registry_1 = __nccwpck_require__(8378);
3276132762
const errors_1 = __nccwpck_require__(4830);
@@ -32775,10 +32776,17 @@ async function run() {
3277532776
updaterRegistry.registerUpdater(new updaters_1.PHPUpdater());
3277632777
const updaterService = new services_1.UpdaterService(updaterRegistry);
3277732778
const gitService = new services_1.GitService();
32779+
const fileHandler = new utils_1.FileHandler();
32780+
const changelogService = new services_1.ChangelogService(fileHandler);
3277832781
const platform = updaterService.getPlatform(targetPlatform);
3277932782
core.info(`Detected platform: ${platform}`);
3278032783
const version = updaterService.updateVersion(platform, releaseType);
3278132784
core.setOutput('new_version', version);
32785+
// Generate and update changelog
32786+
const latestTag = await changelogService.getLatestTag();
32787+
const commits = await changelogService.getCommitsSinceTag(latestTag);
32788+
const changelogContent = changelogService.generateChangelog(commits, version);
32789+
await changelogService.updateChangelog(changelogContent);
3278232790
// Git Commit & Tag
3278332791
const gitTag = config_1.GIT_TAG;
3278432792
await gitService.configureGitUser();
@@ -32867,6 +32875,135 @@ class UpdaterRegistry {
3286732875
exports.UpdaterRegistry = UpdaterRegistry;
3286832876

3286932877

32878+
/***/ }),
32879+
32880+
/***/ 5417:
32881+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
32882+
32883+
"use strict";
32884+
32885+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
32886+
if (k2 === undefined) k2 = k;
32887+
var desc = Object.getOwnPropertyDescriptor(m, k);
32888+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32889+
desc = { enumerable: true, get: function() { return m[k]; } };
32890+
}
32891+
Object.defineProperty(o, k2, desc);
32892+
}) : (function(o, m, k, k2) {
32893+
if (k2 === undefined) k2 = k;
32894+
o[k2] = m[k];
32895+
}));
32896+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
32897+
Object.defineProperty(o, "default", { enumerable: true, value: v });
32898+
}) : function(o, v) {
32899+
o["default"] = v;
32900+
});
32901+
var __importStar = (this && this.__importStar) || (function () {
32902+
var ownKeys = function(o) {
32903+
ownKeys = Object.getOwnPropertyNames || function (o) {
32904+
var ar = [];
32905+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32906+
return ar;
32907+
};
32908+
return ownKeys(o);
32909+
};
32910+
return function (mod) {
32911+
if (mod && mod.__esModule) return mod;
32912+
var result = {};
32913+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32914+
__setModuleDefault(result, mod);
32915+
return result;
32916+
};
32917+
})();
32918+
Object.defineProperty(exports, "__esModule", ({ value: true }));
32919+
exports.ChangelogService = void 0;
32920+
const exec = __importStar(__nccwpck_require__(8872));
32921+
/**
32922+
* Service for managing the changelog file.
32923+
*/
32924+
class ChangelogService {
32925+
constructor(fileHandler) {
32926+
this.fileHandler = fileHandler;
32927+
}
32928+
/**
32929+
* Get the latest git tag.
32930+
* @returns The latest tag as a string.
32931+
*/
32932+
async getLatestTag() {
32933+
let latestTag = '';
32934+
const options = {
32935+
listeners: {
32936+
stdout: (data) => {
32937+
latestTag += data.toString();
32938+
},
32939+
},
32940+
};
32941+
await exec.exec('git', ['describe', '--tags', '--abbrev=0'], options);
32942+
return latestTag.trim();
32943+
}
32944+
/**
32945+
* Get the commits since a specific tag.
32946+
* @param tag The tag to get commits since.
32947+
* @returns An array of commit messages.
32948+
*/
32949+
async getCommitsSinceTag(tag) {
32950+
let commits = '';
32951+
const options = {
32952+
listeners: {
32953+
stdout: (data) => {
32954+
commits += data.toString();
32955+
},
32956+
},
32957+
};
32958+
await exec.exec('git', ['log', `${tag}..HEAD`, '--oneline'], options);
32959+
return commits.split('\n').filter(Boolean);
32960+
}
32961+
/**
32962+
* Generate a changelog from the given commits.
32963+
* @param commits The list of commits to include in the changelog.
32964+
* @param newVersion The new version number.
32965+
* @returns The generated changelog as a string.
32966+
*/
32967+
generateChangelog(commits, newVersion) {
32968+
const changelogDate = new Date().toISOString().split('T')[0];
32969+
let changelogContent = `## v${newVersion} ${changelogDate}\n\n`;
32970+
const categorizedCommits = { Added: [], Changed: [], Fixed: [] };
32971+
for (const commit of commits) {
32972+
const commitMessage = commit.split(' ').slice(1).join(' ');
32973+
const messageParts = commitMessage.split(':');
32974+
const message = messageParts.length > 1 ? messageParts.slice(1).join(':').trim() : commitMessage;
32975+
if (commitMessage.startsWith('feat') || commitMessage.startsWith('Added')) {
32976+
categorizedCommits.Added.push(`- ${message}`);
32977+
}
32978+
else if (commitMessage.startsWith('fix') || commitMessage.startsWith('Fixed')) {
32979+
categorizedCommits.Fixed.push(`- ${message}`);
32980+
}
32981+
else {
32982+
categorizedCommits.Changed.push(`- ${message}`);
32983+
}
32984+
}
32985+
for (const category in categorizedCommits) {
32986+
if (categorizedCommits[category].length > 0) {
32987+
changelogContent += `### ${category}\n\n`;
32988+
changelogContent += categorizedCommits[category].join('\n') + '\n\n';
32989+
}
32990+
}
32991+
return changelogContent;
32992+
}
32993+
/**
32994+
* Update the changelog file with the new content.
32995+
* @param changelogContent The new changelog content to add.
32996+
*/
32997+
async updateChangelog(changelogContent) {
32998+
const changelogPath = 'CHANGELOG.md';
32999+
const existingChangelog = await this.fileHandler.readFile(changelogPath);
33000+
const newChangelog = changelogContent + existingChangelog;
33001+
await this.fileHandler.writeFile(changelogPath, newChangelog);
33002+
}
33003+
}
33004+
exports.ChangelogService = ChangelogService;
33005+
33006+
3287033007
/***/ }),
3287133008

3287233009
/***/ 8743:
@@ -32995,6 +33132,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
3299533132
Object.defineProperty(exports, "__esModule", ({ value: true }));
3299633133
__exportStar(__nccwpck_require__(9104), exports);
3299733134
__exportStar(__nccwpck_require__(8743), exports);
33135+
__exportStar(__nccwpck_require__(5417), exports);
3299833136

3299933137

3300033138
/***/ }),
@@ -33105,7 +33243,7 @@ class GoUpdater {
3310533243
if (!this.manifestPath)
3310633244
return null;
3310733245
return this.manifestParser.getVersion(this.manifestPath, 'regex', {
33108-
regex: /module\s+.*\n.*v(\d+\.\d+\.\d+)/,
33246+
regex: /^module\s+[^\s]+\s+v?(\d+\.\d+\.\d+)/m,
3310933247
});
3311033248
}
3311133249
bumpVersion(releaseType) {

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@
5353
"vitest": "^3.2.4",
5454
"yaml": "^2.8.1"
5555
}
56-
}
56+
}

0 commit comments

Comments
 (0)