chore(build): move commit to release step and cleanup scripts\n\n- remove build:commit scripts and delete build-and-commit.js\n- add final release commit in release:push\n- update README to reflect new flow\n- document icon emphasis colors in icons/README
This commit is contained in:
		
					parent
					
						
							
								99bee995ce
							
						
					
				
			
			
				commit
				
					
						11c0f38526
					
				
			
		
					 7 changed files with 68 additions and 108 deletions
				
			
		| 
						 | 
				
			
			@ -212,3 +212,54 @@ if (fs.existsSync(updatesPath)) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
console.log('Upload complete.');
 | 
			
		||||
 | 
			
		||||
// After upload, commit generated artifacts to the repo so changes are tracked.
 | 
			
		||||
try {
 | 
			
		||||
  const { spawnSync } = require('child_process');
 | 
			
		||||
 | 
			
		||||
  function runGit(args, opts = {}) {
 | 
			
		||||
    const res = spawnSync('git', args, { stdio: 'inherit', cwd: root, ...opts });
 | 
			
		||||
    if (res.error) throw res.error;
 | 
			
		||||
    return res.status || 0;
 | 
			
		||||
  }
 | 
			
		||||
  function runGitOut(args, opts = {}) {
 | 
			
		||||
    const res = spawnSync('git', args, { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8', cwd: root, ...opts });
 | 
			
		||||
    if (res.error) throw res.error;
 | 
			
		||||
    return { code: res.status || 0, out: (res.stdout || '').trim(), err: (res.stderr || '').trim() };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  console.log('Staging release artifacts for commit…');
 | 
			
		||||
  // Stage updates.json and the current version folder; icons may have changed earlier, include them too.
 | 
			
		||||
  runGit(['add', 'releases/updates.json']);
 | 
			
		||||
  runGit(['add', '-f', path.join('releases', String(version))]);
 | 
			
		||||
  runGit(['add', 'icons/icon-*.png']);
 | 
			
		||||
 | 
			
		||||
  const { out: staged } = runGitOut(['diff', '--cached', '--name-only']);
 | 
			
		||||
  if (!staged) {
 | 
			
		||||
    console.log('✓ Nothing to commit. Repository already up to date.');
 | 
			
		||||
  } else {
 | 
			
		||||
    const msg = `chore(release): publish v${version} artifacts`;
 | 
			
		||||
    console.log(`Committing: ${msg}`);
 | 
			
		||||
    const codeCommit = runGit(['commit', '-m', msg]);
 | 
			
		||||
    if (codeCommit !== 0) {
 | 
			
		||||
      console.warn('Warning: git commit exited with non-zero status.');
 | 
			
		||||
    } else {
 | 
			
		||||
      // Optional push if requested
 | 
			
		||||
      const doPush = String(process.env.GIT_PUSH || '').toLowerCase() === 'true';
 | 
			
		||||
      if (doPush) {
 | 
			
		||||
        console.log('Pushing commit to upstream…');
 | 
			
		||||
        const { code: upCode } = runGitOut(['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}']);
 | 
			
		||||
        if (upCode === 0) {
 | 
			
		||||
          runGit(['push']);
 | 
			
		||||
        } else {
 | 
			
		||||
          const { out: branch } = runGitOut(['rev-parse', '--abbrev-ref', 'HEAD']);
 | 
			
		||||
          runGit(['push', '-u', 'origin', branch]);
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        console.log('✓ Commit created. Skipping git push (enable with GIT_PUSH=true).');
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
} catch (e) {
 | 
			
		||||
  console.warn('Warning: Failed to create release commit:', e.message);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue