migrate set-output command to environment files

set-output commands are now deprecated.
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

GitHub recommends environment files instead.
https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
This commit is contained in:
ICHINOSE Shogo
2022-10-13 23:11:52 +09:00
parent 22bd863447
commit f9cca350ae

View File

@@ -37,6 +37,16 @@ list_versions() {
fi fi
} }
set_output() {
name=$1
value=$2
if [ -n "${GITHUB_OUTPUT}" ]; then
echo "$name=$value" >> "{$GITHUB_OUTPUT}"
else
echo "::set-output name=$name::$value"
fi
}
LATEST_VERSION="$(\ LATEST_VERSION="$(\
list_versions | \ list_versions | \
grep -oP '\d+(\.\d+)+(-[^'\''\"\s]*)?$'| \ grep -oP '\d+(\.\d+)+(-[^'\''\"\s]*)?$'| \
@@ -51,9 +61,9 @@ fi
echo "Latest ${VERSION_NAME}=${LATEST_VERSION}" echo "Latest ${VERSION_NAME}=${LATEST_VERSION}"
# Set outputs. # Set outputs.
echo "::set-output name=current::${CURRENT_VERSION}" set_output current "${CURRENT_VERSION}"
echo "::set-output name=latest::${LATEST_VERSION}" set_output latest "${LATEST_VERSION}"
echo "::set-output name=repo::${REPO}" set_output repo "${REPO}"
if [ "${CURRENT_VERSION}" = "${LATEST_VERSION}" ]; then if [ "${CURRENT_VERSION}" = "${LATEST_VERSION}" ]; then
echo "${VERSION_NAME} is latest. Nothing to do." echo "${VERSION_NAME} is latest. Nothing to do."