Monorepo utils: Fix GitHub flag (#38023)

move source files
This commit is contained in:
Paul Sealock 2023-04-28 12:31:33 +12:00 committed by GitHub
parent 8f02ecbeba
commit a303df0da5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 362 additions and 483 deletions

View File

@ -47,21 +47,21 @@ jobs:
- name: 'Check whether today is the code freeze day'
id: check-freeze
run: pnpm utils code-freeze verify-day -g -o $TIME_OVERRIDE
run: pnpm utils code-freeze verify-day -o $TIME_OVERRIDE
- name: Create next milestone
id: milestone
if: steps.check-freeze.outputs.freeze == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm run utils code-freeze milestone -g -o ${{ github.repository_owner }}
run: pnpm run utils code-freeze milestone -o ${{ github.repository_owner }}
- name: Create next release branch
id: branch
if: steps.check-freeze.outputs.freeze == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm run utils code-freeze branch -g -o ${{ github.repository_owner }}
run: pnpm run utils code-freeze branch -o ${{ github.repository_owner }}
prep-trunk:
name: Preps trunk for next development cycle

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,7 @@ import {
import { WPIncrement } from '../../../core/version';
import { Logger } from '../../../core/logger';
import { Options } from './types';
import { getEnvVar } from '../../../core/environment';
const getNextReleaseBranch = async ( options: Options ) => {
const latestReleaseVersion = await getLatestGithubReleaseVersion( options );
@ -32,10 +33,6 @@ const getNextReleaseBranch = async ( options: Options ) => {
export const branchCommand = new Command( 'branch' )
.description( 'Create a new release branch' )
.option(
'-g --github',
'CLI command is used in the Github Actions context.'
)
.option( '-d --dryRun', 'Prepare the branch but do not create it.' )
.option(
'-o --owner <owner>',
@ -57,7 +54,9 @@ export const branchCommand = new Command( 'branch' )
'trunk'
)
.action( async ( options: Options ) => {
const { github, source, branch, owner, name, dryRun } = options;
const { source, branch, owner, name, dryRun } = options;
const isGithub = getEnvVar( 'CI' );
let nextReleaseBranch;
if ( ! branch ) {
@ -86,7 +85,7 @@ export const branchCommand = new Command( 'branch' )
branchSpinner.succeed();
if ( branchExists ) {
if ( github ) {
if ( isGithub ) {
Logger.error(
`Release branch ${ nextReleaseBranch } already exists`
);
@ -133,7 +132,7 @@ export const branchCommand = new Command( 'branch' )
await createGithubBranch( options, nextReleaseBranch, ref );
createBranchSpinner.succeed();
if ( github ) {
if ( isGithub ) {
setOutput( 'nextReleaseBranch', nextReleaseBranch );
}

View File

@ -13,13 +13,10 @@ import { setGithubMilestoneOutputs } from './utils';
import { WPIncrement } from '../../../core/version';
import { Options } from './types';
import { Logger } from '../../../core/logger';
import { getEnvVar } from '../../../core/environment';
export const milestoneCommand = new Command( 'milestone' )
.description( 'Create a milestone' )
.option(
'-g --github',
'CLI command is used in the Github Actions context.'
)
.option( '-d --dryRun', 'Prepare the milestone but do not create it.' )
.option(
'-o --owner <owner>',
@ -36,9 +33,10 @@ export const milestoneCommand = new Command( 'milestone' )
'Milestone to create. Next milestone is gathered from Github if none is supplied'
)
.action( async ( options: Options ) => {
const { owner, name, dryRun, milestone, github } = options;
const { owner, name, dryRun, milestone } = options;
const isGithub = getEnvVar( 'CI' );
if ( milestone && github ) {
if ( milestone && isGithub ) {
Logger.error(
"You can't manually supply a milestone using Github mode. Please use the CLI locally to add a milestone."
);
@ -108,7 +106,7 @@ export const milestoneCommand = new Command( 'milestone' )
Logger.notice(
`Milestone ${ nextMilestone } already exists in ${ owner }/${ name }`
);
if ( github ) {
if ( isGithub ) {
setGithubMilestoneOutputs(
nextReleaseVersion,
nextMilestone
@ -126,7 +124,7 @@ export const milestoneCommand = new Command( 'milestone' )
}
milestoneSpinner.succeed();
if ( github ) {
if ( isGithub ) {
setGithubMilestoneOutputs( nextReleaseVersion, nextMilestone );
}
Logger.notice(

View File

@ -14,6 +14,7 @@ import {
getFutureDate,
} from './utils';
import { Logger } from '../../../core/logger';
import { getEnvVar } from '../../../core/environment';
export const verifyDayCommand = new Command( 'verify-day' )
.description( 'Verify if today is the code freeze day' )
@ -21,11 +22,7 @@ export const verifyDayCommand = new Command( 'verify-day' )
'-o, --override <override>',
"Time Override: The time to use in checking whether the action should run (default: 'now')."
)
.option(
'-g --github',
'CLI command is used in the Github Actions context.'
)
.action( ( { override, github } ) => {
.action( ( { override } ) => {
const today = getToday( override );
const futureDate = getFutureDate( today );
Logger.warn( "Today's timestamp UTC is: " + today.toUTCString() );
@ -42,7 +39,7 @@ export const verifyDayCommand = new Command( 'verify-day' )
`Today is ${ isCodeFreezeDay ? 'indeed' : 'not' } code freeze day.`
);
if ( github ) {
if ( getEnvVar( 'CI' ) ) {
setOutput( 'freeze', isCodeFreezeDay.toString() );
}