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' - name: 'Check whether today is the code freeze day'
id: check-freeze 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 - name: Create next milestone
id: milestone id: milestone
if: steps.check-freeze.outputs.freeze == 'true' if: steps.check-freeze.outputs.freeze == 'true'
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 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 - name: Create next release branch
id: branch id: branch
if: steps.check-freeze.outputs.freeze == 'true' if: steps.check-freeze.outputs.freeze == 'true'
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 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: prep-trunk:
name: Preps trunk for next development cycle 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 { WPIncrement } from '../../../core/version';
import { Logger } from '../../../core/logger'; import { Logger } from '../../../core/logger';
import { Options } from './types'; import { Options } from './types';
import { getEnvVar } from '../../../core/environment';
const getNextReleaseBranch = async ( options: Options ) => { const getNextReleaseBranch = async ( options: Options ) => {
const latestReleaseVersion = await getLatestGithubReleaseVersion( options ); const latestReleaseVersion = await getLatestGithubReleaseVersion( options );
@ -32,10 +33,6 @@ const getNextReleaseBranch = async ( options: Options ) => {
export const branchCommand = new Command( 'branch' ) export const branchCommand = new Command( 'branch' )
.description( 'Create a new release 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( '-d --dryRun', 'Prepare the branch but do not create it.' )
.option( .option(
'-o --owner <owner>', '-o --owner <owner>',
@ -57,7 +54,9 @@ export const branchCommand = new Command( 'branch' )
'trunk' 'trunk'
) )
.action( async ( options: Options ) => { .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; let nextReleaseBranch;
if ( ! branch ) { if ( ! branch ) {
@ -86,7 +85,7 @@ export const branchCommand = new Command( 'branch' )
branchSpinner.succeed(); branchSpinner.succeed();
if ( branchExists ) { if ( branchExists ) {
if ( github ) { if ( isGithub ) {
Logger.error( Logger.error(
`Release branch ${ nextReleaseBranch } already exists` `Release branch ${ nextReleaseBranch } already exists`
); );
@ -133,7 +132,7 @@ export const branchCommand = new Command( 'branch' )
await createGithubBranch( options, nextReleaseBranch, ref ); await createGithubBranch( options, nextReleaseBranch, ref );
createBranchSpinner.succeed(); createBranchSpinner.succeed();
if ( github ) { if ( isGithub ) {
setOutput( 'nextReleaseBranch', nextReleaseBranch ); setOutput( 'nextReleaseBranch', nextReleaseBranch );
} }

View File

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

View File

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