Skip to content

Commit 85d653d

Browse files
committed
Fix bugs in the actions\spring-website-project-version-update
1 parent f702034 commit 85d653d

File tree

1 file changed

+29
-29
lines changed
  • .github/actions/spring-website-project-version-update

1 file changed

+29
-29
lines changed

.github/actions/spring-website-project-version-update/action.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,42 +28,42 @@ runs:
2828
exit 0
2929
fi
3030
31-
NEXT_VERSION="${{ inputs.newVersion }}"
32-
MAJOR_MINOR=$(echo "$NEXT_VERSION" | cut -d '.' -f1-2)
31+
VERSIONS_TO_UPDATE=${{ inputs.newVersion }}
3332
34-
if [[ "$NEXT_VERSION" == *"-"* ]]
33+
MAJOR_MINOR=$(echo ${{ inputs.newVersion }} | cut -d '.' -f1-2)
34+
35+
OSS_SUPPORT_END_DATE=$(eval $SPRING_WEBSITE_CLIENT/generations/${MAJOR_MINOR}.x | jq '.ossSupportEndDate' | tr -d \")
36+
37+
if [[ $OSS_SUPPORT_END_DATE > $(date '+%F') ]]
3538
then
36-
NEXT_VERSION=${NEXT_VERSION/-*}
37-
else
38-
PATCH=$(echo "$NEXT_VERSION" | cut -d '.' -f3)
39-
PATCH=$((PATCH+1))
40-
NEXT_VERSION=$MAJOR_MINOR.$PATCH
39+
NEXT_SNAPSHOT=${{ inputs.newVersion }}
40+
41+
if [[ $NEXT_SNAPSHOT == *"-"* ]]
42+
then
43+
NEXT_SNAPSHOT=${NEXT_SNAPSHOT/-*}
44+
else
45+
PATCH=$(echo $NEXT_SNAPSHOT | cut -d '.' -f3)
46+
PATCH=$((PATCH+1))
47+
NEXT_SNAPSHOT=$MAJOR_MINOR.$PATCH
48+
fi
49+
50+
NEXT_SNAPSHOT+='-SNAPSHOT'
51+
VERSIONS_TO_UPDATE+=" $NEXT_SNAPSHOT"
4152
fi
4253
43-
NEXT_VERSION=${NEXT_VERSION}-SNAPSHOT
54+
VERSIONS_TO_REMOVE=$(eval $SPRING_WEBSITE_CLIENT/releases | jq "._embedded.releases[].version | select(startswith(\"$MAJOR_MINOR\"))" | tr -d \")
4455
45-
PROJECT_PAGE_RELEASES=$(eval $SPRING_WEBSITE_CLIENT/releases | jq '._embedded.releases[].version' | tr -d \")
46-
47-
for PROJECT_PAGE_RELEASE in $PROJECT_PAGE_RELEASES
56+
for VERSION_TO_REMOVE in $VERSIONS_TO_REMOVE
4857
do
49-
if [[ $PROJECT_PAGE_RELEASE == $MAJOR_MINOR* ]]
50-
then
51-
eval $SPRING_WEBSITE_CLIENT/releases/$PROJECT_PAGE_RELEASE -X DELETE --fail --show-error
52-
fi
58+
eval $SPRING_WEBSITE_CLIENT/releases/$VERSION_TO_REMOVE -X DELETE --fail --show-error
5359
done
54-
55-
create_release() {
56-
VERSION_JSON='{"version": "${{ inputs.newVersion }}", "referenceDocUrl": "'https://docs.spring.io/$PROJECT/reference/\{version\}'", "apiDocUrl": "'https://docs.spring.io/$PROJECT/docs/\{version\}/api'", "isAntora": true}'
57-
58-
eval $SPRING_WEBSITE_CLIENT/releases -X POST -d '"$VERSION_JSON"' --fail --show-error
59-
}
6060
61-
create_release ${{ inputs.newVersion }}
61+
for VERSION in $VERSIONS_TO_UPDATE
62+
do
63+
VERSION_JSON='{"version": "'$VERSION'", "referenceDocUrl": "'https://docs.spring.io/$PROJECT/reference/\{version\}'", "apiDocUrl": "'https://docs.spring.io/$PROJECT/docs/\{version\}/api'", "isAntora": true}'
64+
eval $SPRING_WEBSITE_CLIENT/releases -X POST -d '"$VERSION_JSON"' --fail --show-error
65+
done
66+
6267
63-
OSS_SUPPORT_END_DATE=$(eval $SPRING_WEBSITE_CLIENT/generations/${MAJOR_MINOR}.x | jq '.ossSupportEndDate' | tr -d \")
64-
65-
if [[ $OSS_SUPPORT_END_DATE > $(date '+%F') ]]
66-
then
67-
create_release $NEXT_VERSION
68-
fi
68+
6969

0 commit comments

Comments
 (0)