mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
Add manifest version bump CI
This commit is contained in:
40
.github/workflows/bump-manifest-version.yml
vendored
Normal file
40
.github/workflows/bump-manifest-version.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
name: Bump Manifest Version
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bump-manifest-version:
|
||||||
|
if: ${{ github.actor != 'github-actions[bot]' && !contains(github.event.head_commit.message, '[skip ci]') }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
|
||||||
|
- name: Bump manifest version
|
||||||
|
run: node scripts/bump-manifest-version.mjs
|
||||||
|
|
||||||
|
- name: Commit version bump
|
||||||
|
run: |
|
||||||
|
if git diff --quiet -- manifest.json; then
|
||||||
|
echo "manifest.json version did not change."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add manifest.json
|
||||||
|
git commit -m "chore: bump manifest version [skip ci]"
|
||||||
|
git push
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"version:bump-manifest": "node scripts/bump-manifest-version.mjs",
|
||||||
"test:p0": "node tests/p0-regressions.mjs",
|
"test:p0": "node tests/p0-regressions.mjs",
|
||||||
"test:runtime-history": "node tests/runtime-history.mjs",
|
"test:runtime-history": "node tests/runtime-history.mjs",
|
||||||
"test:graph-persistence": "node tests/graph-persistence.mjs",
|
"test:graph-persistence": "node tests/graph-persistence.mjs",
|
||||||
|
|||||||
55
scripts/bump-manifest-version.mjs
Normal file
55
scripts/bump-manifest-version.mjs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import { readFile, writeFile } from "node:fs/promises";
|
||||||
|
import path from "node:path";
|
||||||
|
|
||||||
|
function incrementVersion(version) {
|
||||||
|
if (typeof version !== "string" || !version.trim()) {
|
||||||
|
throw new Error("manifest.json version is missing.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const segments = version.split(".").map((segment) => {
|
||||||
|
if (!/^\d+$/.test(segment)) {
|
||||||
|
throw new Error(`Unsupported version segment: ${segment}`);
|
||||||
|
}
|
||||||
|
return Number(segment);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!segments.length) {
|
||||||
|
throw new Error(`Unsupported version format: ${version}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
let carry = 1;
|
||||||
|
for (let index = segments.length - 1; index >= 0 && carry; index -= 1) {
|
||||||
|
segments[index] += carry;
|
||||||
|
if (index > 0 && segments[index] >= 10) {
|
||||||
|
segments[index] = 0;
|
||||||
|
carry = 1;
|
||||||
|
} else {
|
||||||
|
carry = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return segments.join(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const dryRun = process.argv.includes("--dry-run");
|
||||||
|
const manifestPath = path.resolve(process.cwd(), process.env.MANIFEST_PATH || "manifest.json");
|
||||||
|
const manifestRaw = await readFile(manifestPath, "utf8");
|
||||||
|
const manifest = JSON.parse(manifestRaw);
|
||||||
|
const currentVersion = manifest?.version;
|
||||||
|
const nextVersion = incrementVersion(currentVersion);
|
||||||
|
|
||||||
|
if (dryRun) {
|
||||||
|
console.log(`${currentVersion} -> ${nextVersion}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
manifest.version = nextVersion;
|
||||||
|
await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
||||||
|
console.log(`Updated manifest version: ${currentVersion} -> ${nextVersion}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((error) => {
|
||||||
|
console.error(error instanceof Error ? error.message : String(error));
|
||||||
|
process.exitCode = 1;
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user