-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
69 lines (52 loc) · 2.61 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Update the Spring website project page for new version
description: 'Update the Spring website project page for new version. The SNAPSHOT version is also added if generation permits. Supports only Antora docs.'
inputs:
newVersion:
description: 'The version to add to project page'
required: true
token:
description: 'A GitHub token for REST api calls'
required: true
runs:
using: composite
steps:
- name: Update project page for new version
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
PROJECT=${{ github.event.repository.name }}
GITHUB_USER=$(gh api /user --jq '.login')
SPRING_WEBSITE_CLIENT='curl -s -u "$GITHUB_USER:${{ inputs.token }}" -H "Content-Type: application/json" --url "https://api.spring.io/projects/$PROJECT"'
if [ $(eval $SPRING_WEBSITE_CLIENT -o /dev/null -w '%{http_code}') != '200' ]
then
echo "::notice title=Nothing to update on Spring website::No versions update for $PROJECT project which is not listed on Spring website."
exit 0
fi
VERSIONS_TO_UPDATE=${{ inputs.newVersion }}
MAJOR_MINOR=$(echo ${{ inputs.newVersion }} | cut -d '.' -f1-2)
OSS_SUPPORT_END_DATE=$(eval $SPRING_WEBSITE_CLIENT/generations/${MAJOR_MINOR}.x | jq '.ossSupportEndDate' | tr -d \")
if [[ -z $OSS_SUPPORT_END_DATE || $OSS_SUPPORT_END_DATE > $(date '+%F') ]]
then
NEXT_SNAPSHOT=${{ inputs.newVersion }}
if [[ $NEXT_SNAPSHOT == *"-"* ]]
then
NEXT_SNAPSHOT=${NEXT_SNAPSHOT/-*}
else
PATCH=$(echo $NEXT_SNAPSHOT | cut -d '.' -f3)
PATCH=$((PATCH+1))
NEXT_SNAPSHOT=$MAJOR_MINOR.$PATCH
fi
NEXT_SNAPSHOT+='-SNAPSHOT'
VERSIONS_TO_UPDATE+=" $NEXT_SNAPSHOT"
fi
VERSIONS_TO_REMOVE=$(eval $SPRING_WEBSITE_CLIENT/releases | jq "._embedded.releases[].version | select(startswith(\"$MAJOR_MINOR\"))" | tr -d \")
for VERSION_TO_REMOVE in $VERSIONS_TO_REMOVE
do
eval $SPRING_WEBSITE_CLIENT/releases/$VERSION_TO_REMOVE -X DELETE
done
for VERSION in $VERSIONS_TO_UPDATE
do
VERSION_JSON='{"version": "'$VERSION'", "referenceDocUrl": "'https://docs.spring.io/$PROJECT/reference/\{version\}'", "apiDocUrl": "'https://docs.spring.io/$PROJECT/docs/$VERSION/api'", "isAntora": true}'
eval $SPRING_WEBSITE_CLIENT/releases -X POST -d '"$VERSION_JSON"' --fail --show-error
done