UNPKG

wp-release-automation

Version:

A comprehensive CLI tool for automating WordPress plugin and theme release processes with version management, ZIP creation, and Git integration.

63 lines (50 loc) • 2.04 kB
#!/usr/bin/env node /** * Git Push Script for WordPress Release Automation * * Pushes commits and tags to GitHub */ const { execSync } = require('child_process'); const chalk = require('chalk'); console.log(chalk.blue('šŸš€ Pushing changes to GitHub...')); try { // Check if we're in a git repository execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' }); } catch (error) { console.log(chalk.red('āŒ Not in a Git repository.')); process.exit(1); } try { // Push commits console.log(chalk.blue('šŸ“¤ Pushing commits...')); execSync('git push origin HEAD', { stdio: 'inherit' }); console.log(chalk.green('āœ… Commits pushed successfully')); // Push tags console.log(chalk.blue('šŸ·ļø Pushing tags...')); execSync('git push origin --tags', { stdio: 'inherit' }); console.log(chalk.green('āœ… Tags pushed successfully')); console.log(chalk.green('\nšŸŽ‰ All changes pushed to GitHub!\n')); // Get the current branch and last commit const branch = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim(); const commit = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim().substring(0, 7); console.log(chalk.blue('šŸ“‹ Push Summary:')); console.log(chalk.gray(`Branch: ${branch}`)); console.log(chalk.gray(`Latest commit: ${commit}`)); // Get repository URL if available try { const remoteUrl = execSync('git config --get remote.origin.url', { encoding: 'utf8' }).trim(); if (remoteUrl) { const githubUrl = remoteUrl .replace(/^git@github\.com:/, 'https://github.com/') .replace(/\.git$/, ''); console.log(chalk.blue('\nšŸ”— Repository:')); console.log(chalk.cyan(githubUrl)); console.log(chalk.cyan(githubUrl + '/releases')); } } catch (e) { // Ignore error if we can't get remote URL } } catch (error) { console.log(chalk.red('āŒ Error pushing to GitHub:'), error.message); process.exit(1); }