release: iriz 0.2.4

This commit is contained in:
public-repo-gate
2026-09-15 03:34:13 +03:00
parent 36c76c6934
commit 2a1ce2297a
109 changed files with 25005 additions and 21092 deletions
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
View File
+30
View File
@@ -50,6 +50,11 @@ check(draft['permissions'] == { 'contents' => 'write' } && draft['needs'] == 'bu
check(build['runs-on'] == 'macos-26' && build['env']['SMLTLK_SIGN_IDENTITY'] == '-', 'Build must use standard ARM64 and ad-hoc signing')
check(build['env']['DEVELOPER_DIR'] == '/Applications/Xcode_26.6.app/Contents/Developer', 'Pin the Xcode 26.6 toolchain')
check(build['env']['IRIZ_NOTARY_PROFILE'] == '' && build['env']['IRIZ_DMG_HEADLESS'] == '1', 'No Apple credentials or Finder in CI')
notes_check_index = build['steps'].index { |step| step['name'] == 'Verify generated GitHub Release notes' }
notes_check = notes_check_index && build['steps'][notes_check_index]
check(notes_check && notes_check['env'] == { 'RELEASE_VERSION' => '${{ steps.version.outputs.version }}' } &&
notes_check['run'] == 'node scripts/render_github_release_notes.mjs --check --version "$RELEASE_VERSION"',
'Build must verify the generated notes for the exact release version')
check(build['steps'].any? { |step| step['run'] == 'swift test --no-parallel --jobs 2' }, 'Serial tests must precede packaging')
test_index = build['steps'].index { |step| step['run'] == 'swift test --no-parallel --jobs 2' }
environment_index = build['steps'].index { |step| step['name'] == 'Prepare hosted macOS integration environment' }
@@ -61,6 +66,28 @@ check(build['steps'].none? { |step| step.key?('if') }, 'build_only must retain e
check(build['steps'].any? { |step| step['name'] == 'Verify the exact release files' }, 'Build must verify its release files')
upload = build['steps'].find { |step| step['id'] == 'upload' }
check(upload && upload.fetch('with')['overwrite'] == false, 'Build artifacts must upload without overwriting another run')
upload_index = build['steps'].index(upload)
stage_index = build['steps'].index { |step| step['name'] == 'Stage release notes for the draft' }
stage = stage_index && build['steps'][stage_index]
check(stage && stage['run'] == 'cp ".github/release-notes/v$RELEASE_VERSION.md" "release/dist/release-notes-v$RELEASE_VERSION.md"' &&
package_index < stage_index && stage_index == upload_index - 1,
'Verified release notes must be staged immediately before artifact upload')
artifact_paths = upload.fetch('with').fetch('path').lines.map(&:strip).reject(&:empty?)
check(artifact_paths == [
'release/dist/iriz-${{ steps.version.outputs.version }}-arm64.dmg',
'release/dist/iriz-macos-arm64.dmg',
'release/dist/SHA256SUMS.txt',
'release/dist/release-manifest.json',
'release/dist/release-notes-v${{ steps.version.outputs.version }}.md'
], 'Actions artifact must contain four public assets plus the generated notes')
download = draft['steps'].find { |step| step['name'] == "Download only this build's artifact" }
check(download && download.fetch('with')['artifact-ids'] == '${{ needs.build.outputs.artifact_id }}' &&
download.fetch('with')['path'] == 'release-files' && download.fetch('with')['merge-multiple'] == true &&
download.fetch('with')['digest-mismatch'] == 'error', 'Draft must download only the exact verified build artifact')
draft_verify = draft['steps'].find { |step| step['name'] == 'Verify release metadata and checksums' }.fetch('run')
check(draft_verify.include?('release-manifest.json "release-notes-v$RELEASE_VERSION.md"') &&
draft_verify.include?('[[ -f "$file" && ! -L "$file" && -s "$file" ]]'),
'Draft must reject missing, empty or linked release notes')
check(draft['steps'].none? { |step| step['uses'].to_s.start_with?('actions/checkout@') }, 'No checkout in the write job')
workflow['jobs'].each_value do |job|
job['steps'].each do |step|
@@ -306,6 +333,9 @@ Dir.mktmpdir('iriz-release-write-test-') do |fixture|
check(output.include?("CREATE_ARG:#{arg}\n"), "Missing create argument: #{arg}")
end
check(output.include?("CREATE_ARG:--target\nCREATE_ARG:#{sha}\n"), 'Draft must target the exact source commit')
check(output.include?("CREATE_ARG:--notes-file\nCREATE_ARG:release-notes-v0.2.1.md\n"),
'Draft must use the generated notes file')
check(!output.include?("CREATE_ARG:--notes\n"), 'Draft must not replace generated notes with inline copy')
check(!output.include?('--clobber'), 'Asset overwrite is forbidden')
else
check(writes.empty?, "#{name}: no writes allowed: #{writes.inspect}")
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
View File
View File
Regular → Executable
View File
View File
Regular → Executable
View File
+215
View File
@@ -0,0 +1,215 @@
#!/usr/bin/env node
import assert from 'node:assert/strict';
import { lstat, mkdir, readFile, writeFile } from 'node:fs/promises';
import { dirname, posix, resolve } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
const REPOSITORY = 'zarubinvibe/iriz';
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const VERSION = /^\d+\.\d+\.\d+$/;
function usage(message) {
throw new Error(`${message}\nUsage: node scripts/render_github_release_notes.mjs [--check] [--version X.Y.Z]`);
}
function options(argv) {
let check = false;
let selftest = false;
let version;
for (let index = 0; index < argv.length; index += 1) {
switch (argv[index]) {
case '--check': check = true; break;
case '--selftest': selftest = true; break;
case '--version':
if (index + 1 >= argv.length) usage('--version needs a value.');
version = argv[++index];
break;
default: usage(`Unknown argument: ${argv[index]}`);
}
}
if (selftest && (check || version)) usage('--selftest cannot be combined with other arguments.');
return { check, selftest, version };
}
function destination(value) {
const leading = value.match(/^\s*/u)[0];
const body = value.slice(leading.length);
if (body.startsWith('<')) {
const end = body.indexOf('>');
if (end === -1) return null;
return { path: body.slice(1, end), leading, trailing: body.slice(end + 1), brackets: true };
}
const match = body.match(/^(\S+)([\s\S]*)$/u);
return match ? { path: match[1], leading, trailing: match[2], brackets: false } : null;
}
function relativeImage(path) {
return path && !path.startsWith('/') && !path.startsWith('#') && !path.startsWith('//') &&
!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(path);
}
function escaped(text, index) {
let slashes = 0;
while (index > slashes && text[index - slashes - 1] === '\\') slashes += 1;
return slashes % 2 === 1;
}
function rewriteLine(line, rewrite) {
let cursor = 0;
let output = '';
while (cursor < line.length) {
const start = line.indexOf('![', cursor);
if (start === -1) return output + line.slice(cursor);
if (escaped(line, start)) {
output += line.slice(cursor, start + 2);
cursor = start + 2;
continue;
}
let opening = -1;
for (let index = start + 2; index < line.length - 1; index += 1) {
if (line[index] === ']' && line[index + 1] === '(' && !escaped(line, index)) {
opening = index + 1;
break;
}
}
if (opening === -1) return output + line.slice(cursor);
let depth = 1;
let closing = -1;
for (let index = opening + 1; index < line.length; index += 1) {
if (escaped(line, index)) continue;
if (line[index] === '(') depth += 1;
if (line[index] === ')' && --depth === 0) {
closing = index;
break;
}
}
if (closing === -1) throw new Error('Unclosed inline Markdown image.');
const value = line.slice(opening + 1, closing);
output += line.slice(cursor, opening + 1) + rewrite(value) + ')';
cursor = closing + 1;
}
return output;
}
export function render(source, sourcePath, tag) {
let rewrites = 0;
let fence;
const assets = new Set();
const lines = source.match(/[^\r\n]*(?:\r\n|\n|$)/gu).filter(Boolean);
const output = lines.map(line => {
const marker = line.match(/^\s*(`{3,}|~{3,})/u)?.[1];
if (marker) {
if (!fence) fence = marker;
else if (marker[0] === fence[0] && marker.length >= fence.length) fence = undefined;
return line;
}
if (fence) return line;
// ponytail: release notes use direct inline images; add a CommonMark parser only if that format grows.
return rewriteLine(line, value => {
const parsed = destination(value);
if (!parsed || !relativeImage(parsed.path)) return value;
const suffixIndex = parsed.path.search(/[?#]/u);
const path = suffixIndex === -1 ? parsed.path : parsed.path.slice(0, suffixIndex);
const suffix = suffixIndex === -1 ? '' : parsed.path.slice(suffixIndex);
if (!path || path.includes('\\') || path.includes('%')) {
throw new Error(`Unsupported relative image path: ${parsed.path}`);
}
const repositoryPath = posix.normalize(posix.join(posix.dirname(sourcePath), path));
if (repositoryPath === '..' || repositoryPath.startsWith('../') || posix.isAbsolute(repositoryPath)) {
throw new Error(`Image escapes repository root: ${parsed.path}`);
}
const prefix = `https://raw.githubusercontent.com/${REPOSITORY}/${tag}/`;
const raw = prefix + repositoryPath.split('/').map(encodeURIComponent).join('/') + suffix;
const rendered = parsed.brackets ? `<${raw}>` : raw;
rewrites += 1;
assets.add(repositoryPath);
return `${parsed.leading}${rendered}${parsed.trailing}`;
});
}).join('');
return { output, rewrites, assets: [...assets] };
}
async function verifyAssets(assets, root = ROOT, inspect = lstat) {
for (const asset of assets) {
const path = resolve(root, ...asset.split('/'));
let info;
try {
info = await inspect(path);
} catch {
throw new Error(`Release-note image is missing: ${asset}`);
}
if (!info.isFile() || info.isSymbolicLink()) {
throw new Error(`Release-note image is not a regular file: ${asset}`);
}
}
}
async function selftest() {
const source = [
'![hero](../assets/hero.png)',
'[guide](../guide.md)',
'![remote](https://example.com/hero.png)',
'```md',
'![example](../assets/example.png)',
'```',
''
].join('\n');
const result = render(source, 'docs/releases/v1.2.3.md', 'v1.2.3');
assert.equal(result.rewrites, 1);
assert.deepEqual(result.assets, ['docs/assets/hero.png']);
assert.match(result.output, /raw\.githubusercontent\.com\/zarubinvibe\/iriz\/v1\.2\.3\/docs\/assets\/hero\.png/u);
assert.match(result.output, /\[guide\]\(\.\.\/guide\.md\)/u);
assert.match(result.output, /!\[remote\]\(https:\/\/example\.com\/hero\.png\)/u);
assert.match(result.output, /!\[example\]\(\.\.\/assets\/example\.png\)/u);
assert.throws(() => render('![bad](../../../secret.png)\n', 'docs/releases/v1.2.3.md', 'v1.2.3'), /escapes repository root/u);
assert.throws(() => render('![bad](%2e%2e/%2fsecret.png)\n', 'docs/releases/v1.2.3.md', 'v1.2.3'), /Unsupported relative image path/u);
assert.throws(() => render('![bad](safe(foo)/../../../../secret.png)\n', 'docs/releases/v1.2.3.md', 'v1.2.3'), /escapes repository root/u);
await assert.rejects(verifyAssets(['docs/assets/missing.png'], '/repo', async () => { throw new Error('ENOENT'); }), /image is missing/u);
console.log('render_github_release_notes: selftest passed');
}
async function main() {
const args = options(process.argv.slice(2));
if (args.selftest) return selftest();
const version = args.version ?? (await readFile(resolve(ROOT, 'RELEASE_VERSION'), 'utf8')).trim();
if (!VERSION.test(version)) usage(`Invalid version: ${version}`);
const sourcePath = `docs/releases/v${version}.md`;
const targetPath = `.github/release-notes/v${version}.md`;
const source = await readFile(resolve(ROOT, sourcePath), 'utf8');
const result = render(source, sourcePath, `v${version}`);
if (result.rewrites === 0) throw new Error(`${sourcePath} has no relative Markdown image to publish.`);
await verifyAssets(result.assets);
const target = resolve(ROOT, targetPath);
if (args.check) {
const current = await readFile(target, 'utf8').catch(error => error.code === 'ENOENT' ? null : Promise.reject(error));
if (current !== result.output) {
throw new Error(`${targetPath} is stale. Run: node scripts/render_github_release_notes.mjs --version ${version}`);
}
console.log(`render_github_release_notes: ${targetPath} is current`);
return;
}
await mkdir(dirname(target), { recursive: true });
await writeFile(target, result.output, 'utf8');
console.log(`render_github_release_notes: wrote ${targetPath}`);
}
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
main().catch(error => {
console.error(`render_github_release_notes: ${error.message}`);
process.exitCode = 1;
});
}
Regular → Executable
View File
Regular → Executable
+11
View File
@@ -96,5 +96,16 @@ for script in install.sh scripts/build_app.sh; do
[ -r "$script" ] && ok "$script читается" || fail "$script не читается"
done
# 6. GitHub Release получает сгенерированную копию с абсолютной картинкой.
# Node.js нужен сопровождающему релиз, но не пользователю install.sh.
if ! command -v node >/dev/null 2>&1; then
ok "GitHub Release notes: проверка пропущена без Node.js (только для сопровождающего)"
elif node scripts/render_github_release_notes.mjs --selftest >/dev/null \
&& node scripts/render_github_release_notes.mjs --check >/dev/null; then
ok "GitHub Release notes собраны из канонического файла"
else
fail "GitHub Release notes устарели; запусти node scripts/render_github_release_notes.mjs"
fi
printf '\nотказов: %d\n\n' "$fails"
[ "$fails" -eq 0 ]
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
# Регрессия: пользователю install.sh Node.js не нужен, а дрейф релизных
# заметок при наличии Node.js остаётся отказом.
set -euo pipefail
case "${1:-}" in ""|--selftest) ;; *) echo "usage: selfcheck_test.sh [--selftest]" >&2; exit 2 ;; esac
repo_root="$(cd "$(dirname "$0")/.." && pwd -P)"
test_root="$(mktemp -d "${TMPDIR:-/tmp}/iriz-selfcheck-test.XXXXXX")"
trap 'rm -rf -- "$test_root"' EXIT
fixture="$test_root/repo"
mkdir -p "$fixture/scripts" "$fixture/Sources/App"
cp "$repo_root/scripts/selfcheck.sh" "$repo_root/scripts/publishable_files.py" "$fixture/scripts/"
printf '.target(name: "App")\n' > "$fixture/Package.swift"
printf '[Русский](README.ru.md) [简体中文](README.zh.md)\n' > "$fixture/README.md"
printf '[English](README.md)\n' > "$fixture/README.ru.md"
printf '[English](README.md)\n' > "$fixture/README.zh.md"
status=0
(cd "$fixture" && env -i PATH=/usr/bin:/bin LANG=C /bin/bash scripts/selfcheck.sh --selftest) \
> "$test_root/no-node.out" 2>&1 || status=$?
[ "$status" -eq 0 ] || { cat "$test_root/no-node.out" >&2; exit 1; }
grep -Fq "проверка пропущена без Node.js" "$test_root/no-node.out" \
|| { cat "$test_root/no-node.out" >&2; exit 1; }
mkdir -p "$test_root/bin"
printf '#!/bin/sh\ncase "$*" in *--selftest*) exit 0 ;; *) exit 1 ;; esac\n' > "$test_root/bin/node"
chmod +x "$test_root/bin/node"
status=0
(cd "$fixture" && env -i PATH="$test_root/bin:/usr/bin:/bin" LANG=C \
/bin/bash scripts/selfcheck.sh --selftest) > "$test_root/stale.out" 2>&1 || status=$?
[ "$status" -eq 1 ] || { cat "$test_root/stale.out" >&2; exit 1; }
grep -Fq "GitHub Release notes устарели" "$test_root/stale.out" \
|| { cat "$test_root/stale.out" >&2; exit 1; }
echo "selfcheck_test: OK"
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File