Repository: eslint/eslint
File: Makefile.js (JavaScript)

Code before:
    // always write docs into the next major directory (so 2.0.0-alpha.0 writes to 2.0.0)
    target.gensite(nextMajor);

    /*
     * Premajor release should have identical "next major version".
     * Preminor and prepatch release will not.
     * 5.0.0-alpha.0 --> next major = 5, current major = 5
     * 4.4.0-alpha.0 --> next major = 5, current major = 4
     * 4.0.1-alpha.0 --> next major = 5, current major = 4
     */
    if (semver.major(releaseInfo.version) === semver.major(nextMajor)) {

        /*
         * This prerelease is for a major release (not preminor/prepatch).
         * Blog post generation logic needs to be aware of this (as well as
         * know what the next major version is actually supposed to be).
         */
        generateBlogPost(releaseInfo, nextMajor);
    } else {
        generateBlogPost(releaseInfo);
    }

    commitSiteToGit(`v${releaseInfo.version}`);

    // push to the next branch to trigger docs deploy
    exec("git push origin HEAD:next -f");
}

/**
 * Publishes a generated release to npm and GitHub, and pushes changes to the adjacent `website` repo
 * to remote repo.
 * @returns {void}
 */
function publishRelease() {
    ReleaseOps.publishRelease();

    // push to latest branch to trigger docs deploy
    exec("git push origin HEAD:latest -f");

    publishSite();
}

/**
 * Splits a command result to separate lines.
 * @param {string} result The command result string.
 * @returns {Array} The separated lines.
 */
function splitCommandResultToLines(result) {
    return result.trim().split("\n");
}


Review comment (suggestion):
`generateRelease`/`generatePrerelease` should just prepare everything locally, and then `publishRelease` in the next step publishes the package and updates repositories on GitHub, so this should be in `publishRelease`. We should update `publishRelease` anyway to avoid updating the `latest` branch:

https://github.com/eslint/eslint/blob/a4e89dbe85589dab982885872dc206e090c27b3c/Makefile.js#L345-L352



Code after:
    // always write docs into the next major directory (so 2.0.0-alpha.0 writes to 2.0.0)
    target.gensite(nextMajor);

    /*
     * Premajor release should have identical "next major version".
     * Preminor and prepatch release will not.
     * 5.0.0-alpha.0 --> next major = 5, current major = 5
     * 4.4.0-alpha.0 --> next major = 5, current major = 4
     * 4.0.1-alpha.0 --> next major = 5, current major = 4
     */
    if (semver.major(releaseInfo.version) === semver.major(nextMajor)) {

        /*
         * This prerelease is for a major release (not preminor/prepatch).
         * Blog post generation logic needs to be aware of this (as well as
         * know what the next major version is actually supposed to be).
         */
        generateBlogPost(releaseInfo, nextMajor);
    } else {
        generateBlogPost(releaseInfo);
    }

    commitSiteToGit(`v${releaseInfo.version}`);
}

/**
 * Publishes a generated release to npm and GitHub, and pushes changes to the adjacent `website` repo
 * to remote repo.
 * @returns {void}
 */
function publishRelease() {
    ReleaseOps.publishRelease();
    const releaseInfo = JSON.parse(cat(".eslint-release-info.json"));
    const isPreRelease = /[a-z]/u.test(releaseInfo.version);

    /*
     * for a pre-release, push to the "next" branch to trigger docs deploy
     * for a release, push to the "latest" branch to trigger docs deploy
     */
    if (isPreRelease) {
        exec("git push origin HEAD:next -f");
    } else {
        exec("git push origin HEAD:latest -f");
    }

    publishSite();
}

/**
 * Splits a command result to separate lines.
 * @param {string} result The command result string.