2018-12-11 11:20:11 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-25 21:26:41 +08:00
|
|
|
report_error() {
|
|
|
|
echo "Script exited with error $1 on line $2"
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
trap 'report_error $? $LINENO' ERR
|
|
|
|
|
2018-12-11 11:20:11 +08:00
|
|
|
case "$JDK_VERSION" in
|
|
|
|
java8)
|
2020-09-22 14:14:51 +08:00
|
|
|
BASE_URL="https://api.adoptopenjdk.net/v3/assets/feature_releases/8/ga"
|
2019-02-14 07:33:04 +08:00
|
|
|
ISSUE_TITLE="Upgrade Java 8 version in CI image"
|
2018-12-11 11:20:11 +08:00
|
|
|
;;
|
|
|
|
java11)
|
2020-09-22 14:14:51 +08:00
|
|
|
BASE_URL="https://api.adoptopenjdk.net/v3/assets/feature_releases/11/ga"
|
2019-02-14 07:33:04 +08:00
|
|
|
ISSUE_TITLE="Upgrade Java 11 version in CI image"
|
2018-12-11 11:20:11 +08:00
|
|
|
;;
|
2020-09-22 14:14:51 +08:00
|
|
|
java15)
|
|
|
|
BASE_URL="https://api.adoptopenjdk.net/v3/assets/feature_releases/15/ga"
|
|
|
|
ISSUE_TITLE="Upgrade Java 15 version in CI image"
|
2020-03-07 01:01:35 +08:00
|
|
|
;;
|
2018-12-11 11:20:11 +08:00
|
|
|
*)
|
|
|
|
echo $"Unknown java version"
|
|
|
|
exit 1;
|
|
|
|
esac
|
|
|
|
|
2020-09-22 14:14:51 +08:00
|
|
|
response=$( curl -s ${BASE_URL}\?architecture\=x64\&heap_size\=normal\&image_type\=jdk\&jvm_impl\=hotspot\&os\=linux\&sort_order\=DESC\&vendor\=adoptopenjdk )
|
2019-11-28 05:40:12 +08:00
|
|
|
latest=$( jq -r '.[0].binaries[0].package.link' <<< "$response" )
|
2020-06-25 21:26:41 +08:00
|
|
|
if [[ ${latest} = "null" || ${latest} = "" ]]; then
|
|
|
|
echo "Could not parse JDK response: $response"
|
|
|
|
exit 1;
|
|
|
|
fi
|
2018-12-11 11:20:11 +08:00
|
|
|
|
|
|
|
current=$( git-repo/ci/images/get-jdk-url.sh ${JDK_VERSION} )
|
|
|
|
|
|
|
|
if [[ $current = $latest ]]; then
|
|
|
|
echo "Already up-to-date"
|
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
2020-06-25 21:26:41 +08:00
|
|
|
milestone_response=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/milestones\?state\=open )
|
|
|
|
milestone_result=$( jq -r -c --arg MILESTONE "$MILESTONE" '.[] | select(has("title")) | select(.title==$MILESTONE)' <<< "$milestone_response" )
|
|
|
|
if [[ ${milestone_result} = "null" || ${milestone_result} = "" ]]; then
|
|
|
|
echo "Could not parse milestone: $milestone_response"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
milestone_number=$( jq -r '.number' <<< "$milestone_result" )
|
2020-04-07 10:05:26 +08:00
|
|
|
existing_tasks=$( curl -s https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues\?labels\=type:%20task\&state\=open\&creator\=spring-buildmaster\&milestone\=${milestone_number} )
|
2020-06-25 21:26:41 +08:00
|
|
|
existing_jdk_issues=$( jq -r -c --arg TITLE "$ISSUE_TITLE" '.[] | select(has("title")) | select(.title==$TITLE)' <<< "$existing_tasks" )
|
2019-02-14 07:33:04 +08:00
|
|
|
|
|
|
|
if [[ ${existing_jdk_issues} = "" ]]; then
|
2018-12-11 11:20:11 +08:00
|
|
|
curl \
|
|
|
|
-s \
|
|
|
|
-u ${GITHUB_USERNAME}:${GITHUB_PASSWORD} \
|
|
|
|
-H "Content-type:application/json" \
|
2020-05-21 05:32:48 +08:00
|
|
|
-d "{\"title\":\"${ISSUE_TITLE}\",\"milestone\":\"${milestone_number}\",\"body\": \"${latest}\",\"labels\":[\"type: task\"]}" \
|
2018-12-11 11:20:11 +08:00
|
|
|
-f \
|
|
|
|
-X \
|
|
|
|
POST "https://api.github.com/repos/${GITHUB_ORGANIZATION}/${GITHUB_REPO}/issues" > /dev/null || { echo "Failed to create issue" >&2; exit 1; }
|
|
|
|
else
|
|
|
|
echo "Issue already exists."
|
2019-06-05 05:21:09 +08:00
|
|
|
fi
|