diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 72505d70..eff22c77 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -235,13 +235,13 @@ setup_php() { semver="$(php_semver)" extra_version="$(php_extra_version)" configure_php + set_output "php-version" "$semver" if [ "${semver%.*}" != "$version" ]; then add_log "${cross:?}" "PHP" "Could not setup PHP $version" exit 1 fi sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/" - echo "::set-output name=php-version::$semver" add_log "$tick" "PHP" "$status PHP $semver$extra_version" } diff --git a/src/scripts/extensions/cubrid.sh b/src/scripts/extensions/cubrid.sh index cb38fdac..201a667c 100644 --- a/src/scripts/extensions/cubrid.sh +++ b/src/scripts/extensions/cubrid.sh @@ -1,10 +1,10 @@ # Function to log license details. add_license_log() { - printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information" + printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information" printf "Cubrid CCI package is required for %s extension.\n" "$ext" printf "The extension %s and Cubrid CCI are provided under the license linked below.\n" "$ext" printf "Refer to: \033[35;1m%s \033[0m\n" "https://github.com/CUBRID/cubrid-cci/blob/develop/COPYING" - echo "::endgroup::" + echo "$END_GROUP" } # Function to setup gcc-7 and g++-7 diff --git a/src/scripts/extensions/ioncube.ps1 b/src/scripts/extensions/ioncube.ps1 index 2534df38..d5a9cab0 100644 --- a/src/scripts/extensions/ioncube.ps1 +++ b/src/scripts/extensions/ioncube.ps1 @@ -1,8 +1,8 @@ # Function to log result of a operation. Function Add-LicenseLog() { - printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information" + printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information" Get-Content $ext_dir\ioncube\LICENSE.txt - Write-Output "::endgroup::" + Write-Output "$env:END_GROUP" } # Function to add ioncube extension. diff --git a/src/scripts/extensions/ioncube.sh b/src/scripts/extensions/ioncube.sh index ec8eecd1..bfb038d6 100644 --- a/src/scripts/extensions/ioncube.sh +++ b/src/scripts/extensions/ioncube.sh @@ -1,8 +1,8 @@ # Function to log result of a operation. add_license_log() { - printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information" + printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information" cat "${ext_dir:?}"/IONCUBE_LICENSE.txt - echo "::endgroup::" + echo "$END_GROUP" } # Function to install ioncube. diff --git a/src/scripts/extensions/oci.ps1 b/src/scripts/extensions/oci.ps1 index 8d3047e4..d89d1764 100644 --- a/src/scripts/extensions/oci.ps1 +++ b/src/scripts/extensions/oci.ps1 @@ -1,10 +1,10 @@ # Function to log license information. Function Add-LicenseLog() { - printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $extension "Click to read the $extension related license information" + printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $extension "Click to read the $extension related license information" printf "Oracle Instant Client package is required for %s extension.\n" $extension printf "It is provided under the Oracle Technology Network Development and Distribution License.\n" printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html" - Write-Output "::endgroup::" + Write-Output "$env:END_GROUP" } # Function to get instantclinet. diff --git a/src/scripts/extensions/oci.sh b/src/scripts/extensions/oci.sh index 11544c05..838be60d 100644 --- a/src/scripts/extensions/oci.sh +++ b/src/scripts/extensions/oci.sh @@ -1,10 +1,10 @@ # Function to log result of a operation. add_license_log() { - printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information" + printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information" printf "Oracle Instant Client package is required for %s extension.\n" "$ext" printf "It is provided under the Oracle Technology Network Development and Distribution License.\n" printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html" - echo "::endgroup::" + echo "$END_GROUP" } # Function to install instantclient and SDK. diff --git a/src/scripts/extensions/source.sh b/src/scripts/extensions/source.sh index acd9be67..221beaaf 100644 --- a/src/scripts/extensions/source.sh +++ b/src/scripts/extensions/source.sh @@ -68,10 +68,10 @@ run_group() { command=$1 log=$2 echo "$command" | sudo tee ./run_group.sh >/dev/null 2>&1 - echo "::group::$log" + echo "$GROUP$log" . ./run_group.sh rm ./run_group.sh - echo "::endgroup::" + echo "$END_GROUP" } patch_extension() { diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 3b74268f..3bd1a2af 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -239,10 +239,10 @@ setup_php() { mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +) link_pecl_file configure_php + set_output "php-version" "$semver" sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1 sudo chmod 777 "${ini_file[@]}" "$pecl_file" "${tool_path_dir:?}" sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/" - echo "::set-output name=php-version::$semver" add_log "${tick:?}" "PHP" "$status PHP $semver$extra_version" } diff --git a/src/scripts/tools/grpc_php_plugin.ps1 b/src/scripts/tools/grpc_php_plugin.ps1 index 8ec8bdf7..71d732e4 100644 --- a/src/scripts/tools/grpc_php_plugin.ps1 +++ b/src/scripts/tools/grpc_php_plugin.ps1 @@ -12,10 +12,10 @@ Function Add-Grpc_php_plugin() { $logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1 $grpc_version = Get-ToolVersion 'Write-Output' "$logs" Add-Path $msys_location\mingw64\bin - Write-Output "::set-output name=grpc_php_plugin_path::$msys_location\mingw64\bin\grpc_php_plugin.exe" + Set-Output grpc_php_plugin_path "$msys_location\mingw64\bin\grpc_php_plugin.exe" Add-ToProfile $current_profile 'grpc_php_plugin' "New-Alias grpc_php_plugin $msys_location\mingw64\bin\grpc_php_plugin.exe" Add-Log $tick "grpc_php_plugin" "Added grpc_php_plugin $grpc_version" - printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information" + printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information" Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/grpc/grpc/master/LICENSE).Content - Write-Output "::endgroup::" + Write-Output "$env:END_GROUP" } diff --git a/src/scripts/tools/grpc_php_plugin.sh b/src/scripts/tools/grpc_php_plugin.sh index 2452bf9a..b8f35124 100644 --- a/src/scripts/tools/grpc_php_plugin.sh +++ b/src/scripts/tools/grpc_php_plugin.sh @@ -50,9 +50,9 @@ add_grpc_php_plugin() { else add_grpc_php_plugin_compile >/dev/null 2>&1 fi - echo "::set-output name=grpc_php_plugin_path::$(command -v grpc_php_plugin)" + set_output grpc_php_plugin_path "$(command -v grpc_php_plugin)" add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}" - printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information" + printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information" cat "$license_path" - echo "::endgroup::" + echo "$END_GROUP" } diff --git a/src/scripts/tools/protoc.ps1 b/src/scripts/tools/protoc.ps1 index b5416caf..a1fb4182 100644 --- a/src/scripts/tools/protoc.ps1 +++ b/src/scripts/tools/protoc.ps1 @@ -32,7 +32,7 @@ Function Add-Protoc() { Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe" Add-Log $tick "protoc" "Added protoc $($protobuf_tag -replace 'v', '')" - printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information" + printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information" Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE).Content - Write-Output "::endgroup::" + Write-Output "$env:END_GROUP" } diff --git a/src/scripts/tools/protoc.sh b/src/scripts/tools/protoc.sh index f8829f82..4645e9f1 100644 --- a/src/scripts/tools/protoc.sh +++ b/src/scripts/tools/protoc.sh @@ -22,7 +22,7 @@ add_protoc() { sudo chmod -R 777 /usr/local/bin/protoc /usr/local/include/google ) >/dev/null 2>&1 add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}" - printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information" + printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information" curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE - echo "::endgroup::" + echo "$END_GROUP" } diff --git a/src/scripts/unix.sh b/src/scripts/unix.sh index a53d92af..dc97bfb3 100644 --- a/src/scripts/unix.sh +++ b/src/scripts/unix.sh @@ -11,6 +11,14 @@ export github="https://github.com/shivammathur" export jsdeliver="https://cdn.jsdelivr.net/gh/shivammathur" export setup_php="https://setup-php.com" +if [ -n "${GITHUB_ACTIONS}" ]; then + export GROUP='::group::' + export END_GROUP='::endgroup::' +else + export GROUP='' + export END_GROUP='' +fi + # Function to log start of a operation. step_log() { message=$1 @@ -30,6 +38,15 @@ add_log() { fi } +# Function to set output on GitHub Actions. +set_output() { + name=$1 + value=$2 + if [ "${GITHUB_ACTIONS}" = "true" ]; then + echo "::set-output name=${name}::${value}" + fi +} + # Function to read env inputs. read_env() { update="${update:-${UPDATE:-false}}" diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index b556cc44..a3c2365c 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -28,6 +28,25 @@ Function Add-Log($mark, $subject, $message) { } } +# Function to set output on GitHub Actions. +Function Set-Output() { + param( + [Parameter(Position = 0, Mandatory = $true)] + [ValidateNotNull()] + [ValidateLength(1, [int]::MaxValue)] + [string] + $output, + [Parameter(Position = 1, Mandatory = $true)] + [ValidateNotNull()] + [ValidateLength(1, [int]::MaxValue)] + [string] + $value + ) + if ($env:GITHUB_ACTIONS -eq 'true') { + Write-Output "::set-output name=$output::$value" + } +} + # Function to add a line to a powershell profile safely. Function Add-ToProfile { param( @@ -231,6 +250,15 @@ if($env:PHPTS -ne 'ts') { } else { $env:PHPTS = '' } + +if ( $env:GITHUB_ACTIONS -eq 'true') { + $env:GROUP = '::group::' + $env:END_GROUP = '::endgroup::' +} else { + $env:GROUP = '' + $env:END_GROUP = '' +} + if($env:RUNNER -eq 'self-hosted' -or (-not($env:ImageOS) -and -not($env:ImageVersion))) { $bin_dir = 'C:\tools\bin' $php_dir = "$php_dir$version" @@ -316,5 +344,5 @@ if($version -lt "5.5") { Enable-PhpExtension -Extension $enable_extensions -Path $php_dir Add-PhpCAInfo Copy-Item -Path $src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE -Write-Output "::set-output name=php-version::$($installed.FullVersion)" +Set-Output php-version $($installed.FullVersion) Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"