Add a set_output function to script that uses the new GITHUB_OUTPUT (#35894)

This commit is contained in:
Sam Seay 2022-12-13 10:27:42 +13:00 committed by GitHub
parent 3cc47d245d
commit 7224c76053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 6 deletions

View File

@ -1,4 +1,5 @@
<?php
// phpcs:ignoreFile
/**
* Script to automatically enforce the release code freeze.
*
@ -12,6 +13,16 @@ if ( getenv( 'TIME_OVERRIDE' ) ) {
$now = strtotime( getenv( 'TIME_OVERRIDE' ) );
}
/**
* Set an output for the GitHub action.
*
* @param string $name The name of the output.
* @param string $value The value of the output.
*/
function set_output( $name, $value ) {
file_put_contents( getenv( 'GITHUB_OUTPUT' ), "{$name}={$value}" . PHP_EOL, FILE_APPEND );
}
// Code freeze comes 26 days prior to release day.
$release_time = strtotime( '+26 days', $now );
$release_day_of_week = date( 'l', $release_time );
@ -41,10 +52,11 @@ $milestone_to_create = "{$milestone_major_minor}.0";
if ( getenv( 'GITHUB_OUTPUTS' ) ) {
echo 'Including GitHub Outputs...' . PHP_EOL;
echo '::set-output name=next_version::' . $milestone_major_minor . PHP_EOL;
echo '::set-output name=release_version::' . $branch_major_minor . PHP_EOL;
echo '::set-output name=branch::' . $release_branch_to_create . PHP_EOL;
echo '::set-output name=milestone::' . $milestone_to_create . PHP_EOL;
set_output( 'next_version', $milestone_major_minor );
set_output( 'release_version', $branch_major_minor );
set_output( 'branch', $release_branch_to_create );
set_output( 'milestone', $milestone_to_create );
}
if ( getenv( 'DRY_RUN' ) ) {