mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-13 13:23:31 +08:00
fix: harden manual release path
This commit is contained in:
@@ -44,8 +44,8 @@ if [[ "$CURRENT_BRANCH" != "main" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check working tree is clean
|
# Check working tree is clean, including untracked files
|
||||||
if ! git diff --quiet || ! git diff --cached --quiet; then
|
if [[ -n "$(git status --porcelain --untracked-files=all)" ]]; then
|
||||||
echo "Error: Working tree is not clean. Commit or stash changes first."
|
echo "Error: Working tree is not clean. Commit or stash changes first."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -193,6 +193,10 @@ update_version "$OPENCODE_PACKAGE_JSON" "s|\"version\": *\"[^\"]*\"|\"version\":
|
|||||||
update_package_lock_version "$OPENCODE_PACKAGE_LOCK_JSON"
|
update_package_lock_version "$OPENCODE_PACKAGE_LOCK_JSON"
|
||||||
update_readme_version_row
|
update_readme_version_row
|
||||||
|
|
||||||
|
# Verify the bumped release surface is still internally consistent before
|
||||||
|
# writing a release commit, tag, or push.
|
||||||
|
node tests/plugin-manifest.test.js
|
||||||
|
|
||||||
# Stage, commit, tag, and push
|
# Stage, commit, tag, and push
|
||||||
git add "$ROOT_PACKAGE_JSON" "$PACKAGE_LOCK_JSON" "$ROOT_AGENTS_MD" "$AGENT_YAML" "$VERSION_FILE" "$PLUGIN_JSON" "$MARKETPLACE_JSON" "$CODEX_MARKETPLACE_JSON" "$CODEX_PLUGIN_JSON" "$OPENCODE_PACKAGE_JSON" "$OPENCODE_PACKAGE_LOCK_JSON" "$README_FILE"
|
git add "$ROOT_PACKAGE_JSON" "$PACKAGE_LOCK_JSON" "$ROOT_AGENTS_MD" "$AGENT_YAML" "$VERSION_FILE" "$PLUGIN_JSON" "$MARKETPLACE_JSON" "$CODEX_MARKETPLACE_JSON" "$CODEX_PLUGIN_JSON" "$OPENCODE_PACKAGE_JSON" "$OPENCODE_PACKAGE_LOCK_JSON" "$README_FILE"
|
||||||
git commit -m "chore: bump plugin version to $VERSION"
|
git commit -m "chore: bump plugin version to $VERSION"
|
||||||
|
|||||||
53
tests/scripts/release.test.js
Normal file
53
tests/scripts/release.test.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* Source-level tests for scripts/release.sh
|
||||||
|
*/
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const scriptPath = path.join(__dirname, '..', '..', 'scripts', 'release.sh');
|
||||||
|
const source = fs.readFileSync(scriptPath, 'utf8');
|
||||||
|
|
||||||
|
function test(name, fn) {
|
||||||
|
try {
|
||||||
|
fn();
|
||||||
|
console.log(` ✓ ${name}`);
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(` ✗ ${name}`);
|
||||||
|
console.log(` Error: ${error.message}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function runTests() {
|
||||||
|
console.log('\n=== Testing release.sh ===\n');
|
||||||
|
|
||||||
|
let passed = 0;
|
||||||
|
let failed = 0;
|
||||||
|
|
||||||
|
if (test('release script rejects untracked files when checking cleanliness', () => {
|
||||||
|
assert.ok(
|
||||||
|
source.includes('git status --porcelain --untracked-files=all'),
|
||||||
|
'release.sh should use git status --porcelain --untracked-files=all for cleanliness checks'
|
||||||
|
);
|
||||||
|
})) passed++; else failed++;
|
||||||
|
|
||||||
|
if (test('release script reruns release metadata sync validation before commit/tag', () => {
|
||||||
|
const syncCheckIndex = source.indexOf('node tests/plugin-manifest.test.js');
|
||||||
|
const commitIndex = source.indexOf('git commit -m "chore: bump plugin version to $VERSION"');
|
||||||
|
|
||||||
|
assert.ok(syncCheckIndex >= 0, 'release.sh should run plugin-manifest.test.js');
|
||||||
|
assert.ok(commitIndex >= 0, 'release.sh should create the release commit');
|
||||||
|
assert.ok(
|
||||||
|
syncCheckIndex < commitIndex,
|
||||||
|
'plugin-manifest.test.js should run before the release commit is created'
|
||||||
|
);
|
||||||
|
})) passed++; else failed++;
|
||||||
|
|
||||||
|
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
|
||||||
|
process.exit(failed > 0 ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
runTests();
|
||||||
Reference in New Issue
Block a user