فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

ci(release): fail closed unless all P0, QA and backup gates are accepted

davoodmehraban89 committed Oct 14, 2026 at 23:49 UTC b83f5ebe15fa34a375bddd2d4b9685a610835b22
1 file changed +54
scripts/verify-phase-a-release.mjs new
+54
@@ -0,0 +1,54 @@
1 +import { readFileSync } from 'node:fs';
2 +import { pathToFileURL } from 'node:url';
3 +
4 +const required = ['A01','A02','A03','A04','A05','A06','A07','A08',
5 + 'INDEPENDENT_QA','DATA_BACKUP'];
6 +
7 +export function verifyPhaseARelease({ acceptance, packageVersion, desktopVersion, tag }) {
8 + if (!/^v\d+\.\d+\.\d+$/.test(tag) ||
9 + tag !== 'v' + packageVersion || packageVersion !== desktopVersion) {
10 + throw new Error('Public release version/tag/package/installer mismatch');
11 + }
12 + if (!acceptance || acceptance.schemaVersion !== 1 || acceptance.phase !== 'A' ||
13 + !Array.isArray(acceptance.requirements)) {
14 + throw new Error('Missing phase-A release acceptance manifest');
15 + }
16 + const byId = new Map();
17 + for (const row of acceptance.requirements) {
18 + if (!row || typeof row.id !== 'string' || byId.has(row.id)) {
19 + throw new Error('Duplicated or malformed release acceptance entry');
20 + }
21 + byId.set(row.id, row);
22 + }
23 + const blocked = [];
24 + for (const id of required) {
25 + const row = byId.get(id);
26 + if (row?.accepted !== true ||
27 + !Array.isArray(row.evidence) || !row.evidence.length ||
28 + row.evidence.some(link => typeof link !== 'string' ||
29 + !/^https:\/\/github\.com\/davoodmehraban89\/Factor-easyPro\/(?:actions\/runs|pull|issues)\/\d+/.test(link))) {
30 + blocked.push(id);
31 + }
32 + }
33 + if (blocked.length) {
34 + throw new Error('Public release blocked by unaccepted evidence-backed gates: ' + blocked.join(', '));
35 + }
36 + return { ready: true, tag, gates: required.length };
37 +}
38 +
39 +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
40 + try {
41 + const json = path => JSON.parse(readFileSync(new URL('../' + path, import.meta.url), 'utf8'));
42 + const acceptance = json('docs/PHASE_A_RELEASE_ACCEPTANCE.json');
43 + const packageVersion = json('package.json').version;
44 + const desktopVersion = json('src-tauri/tauri.conf.json').version;
45 + const result = verifyPhaseARelease({
46 + acceptance, packageVersion, desktopVersion,
47 + tag: process.argv[2] || process.env.RELEASE_TAG || ''
48 + });
49 + console.log(JSON.stringify(result));
50 + } catch (error) {
51 + console.error(error.message);
52 + process.exitCode = 1;
53 + }
54 +}