Auto Release Automation CLI

11.3.6 · active · verified Wed Apr 22

auto is a comprehensive command-line interface (CLI) tool meticulously engineered to automate release workflows by leveraging semantic versioning conventions, primarily driven by GitHub Pull Request labels. As of its current stable version 11.3.6, the project maintains an active release cadence, frequently delivering bug fixes and incremental enhancements, as evidenced by its consistent patch and minor updates. A significant differentiator of `auto` lies in its label-driven methodology, which streamlines the release process without necessitating alterations to your codebase or drastic overhauls of existing development workflows. It integrates seamlessly into continuous integration/continuous delivery (CI/CD) pipelines while also supporting local execution. The tool features a modular architecture, extensible through a rich ecosystem of plugins (e.g., `@auto-it/npm`, `@auto-it/slack`), enabling users to adapt its functionality for diverse package managers and platforms. Furthermore, `auto` ships with robust TypeScript types, facilitating more reliable integration and development processes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up `auto` programmatically and check the next semantic version based on GitHub labels, providing a foundation for custom automation logic or testing. It highlights the use of core and plugin imports.

import { Auto, IPlugin } from '@auto-it/core';
import { NpmPlugin } from '@auto-it/npm';
import { GithubPlugin } from '@auto-it/github';
import { execSync } from 'child_process';

async function runAutoProgrammatically() {
  // Set up required environment variables (replace with your actual tokens)
  process.env.GH_TOKEN = process.env.GH_TOKEN ?? ''; // GitHub Personal Access Token
  process.env.NPM_TOKEN = process.env.NPM_TOKEN ?? ''; // NPM Publish Token (if using NpmPlugin)

  // Basic configuration for demonstration
  const autoOptions = {
    owner: 'your-org', // Replace with your GitHub organization/user
    repo: 'your-repo', // Replace with your repository name
    baseBranch: 'main', // Or your default branch
    plugins: [
      new NpmPlugin(),
      new GithubPlugin(),
      // Add other plugins as needed
    ],
  };

  try {
    // Initialize auto (this usually happens via the CLI `auto init` for .autorc setup)
    // For programmatic use, we instantiate `Auto` directly.
    const auto = new Auto(autoOptions);
    await auto.loadConfig(); // Load default config and apply plugin configs

    // Example: Check if a release can be made
    console.log('Checking for new releases...');
    const newVersion = await auto.getVersion();
    console.log(`Calculated next version: ${newVersion}`);

    if (newVersion) {
      console.log(`
To simulate a release process, run the following commands manually after setting up GitHub labels (major, minor, patch) on a PR:
1. Create a PR with a semantic label (e.g., 'minor')
2. Merge the PR
3. Set GH_TOKEN and NPM_TOKEN (if publishing to npm)
4. Execute 'npx auto shipit' or 'npx auto version' in your CI/local environment.
`);
      // Programmatic execution of a 'version' command (simplified)
      // In a real CI, this would involve more setup and error handling.
      // For demonstration, we'll just show the concept.
      // await auto.run('version'); // This would trigger versioning, changelog, etc.
    } else {
      console.log('No new version detected based on PR labels.');
    }
  } catch (error) {
    console.error('An error occurred:', error instanceof Error ? error.message : error);
    process.exit(1);
  }
}

// To run the programmatic example:
// 1. npm install auto @auto-it/core @auto-it/npm @auto-it/github
// 2. Set GH_TOKEN and NPM_TOKEN environment variables.
// 3. Replace 'your-org' and 'your-repo'.
// 4. node your_script.js
runAutoProgrammatically();

view raw JSON →