|
| 1 | +name: Update the Spring website project page for new version |
| 2 | + |
| 3 | +description: 'Update the Spring website project page for new version. The SNAPSHOT version is also added if generation permits. Supports only Antora docs.' |
| 4 | + |
| 5 | +inputs: |
| 6 | + newVersion: |
| 7 | + description: 'The version to add to project page' |
| 8 | + required: true |
| 9 | + token: |
| 10 | + description: 'A GitHub token for REST api calls' |
| 11 | + required: true |
| 12 | + |
| 13 | +runs: |
| 14 | + using: composite |
| 15 | + steps: |
| 16 | + - name: Update project page for new version |
| 17 | + shell: bash |
| 18 | + env: |
| 19 | + GH_TOKEN: ${{ inputs.token }} |
| 20 | + run: | |
| 21 | + PROJECT=${{ github.event.repository.name }} |
| 22 | + GITHUB_USER=$(gh api /user --jq '.login') |
| 23 | + SPRING_WEBSITE_CLIENT='curl -s -u "$GITHUB_USER:${{ inputs.token }}" -H "Content-Type: application/json" --url "https://api.spring.io/projects/$PROJECT"' |
| 24 | + |
| 25 | + if [ $(eval $SPRING_WEBSITE_CLIENT -o /dev/null -w '%{http_code}') != '200' ] |
| 26 | + then |
| 27 | + echo "::notice title=Nothing to update on Spring website::No versions update for $PROJECT project which is not listed on Spring website." |
| 28 | + exit 0 |
| 29 | + fi |
| 30 | + |
| 31 | + NEXT_VERSION="${{ inputs.newVersion }}" |
| 32 | + MAJOR_MINOR=$(echo "$NEXT_VERSION" | cut -d '.' -f1-2) |
| 33 | + |
| 34 | + if [[ "$NEXT_VERSION" == *"-"* ]] |
| 35 | + 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 |
| 41 | + fi |
| 42 | + |
| 43 | + NEXT_VERSION=${NEXT_VERSION}-SNAPSHOT |
| 44 | + |
| 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 |
| 48 | + 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 |
| 53 | + 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 | + } |
| 60 | + |
| 61 | + create_release ${{ inputs.newVersion }} |
| 62 | + |
| 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 |
| 69 | + |
0 commit comments