Skip to content

Commit d52d274

Browse files
committed
Revert "Use spring-release-actions/update-learn-page"
This reverts commit b10e656.
1 parent fa8aca6 commit d52d274

3 files changed

Lines changed: 102 additions & 7 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
set -euo pipefail
22+
23+
PROJECT=${{ github.event.repository.name }}
24+
NEW_VERSION=${{ inputs.newVersion }}
25+
GITHUB_USER=$(gh api /user --jq '.login')
26+
BASE_URL="https://api.spring.io/projects/$PROJECT"
27+
declare -a CURL_OPTS=(-s -u "$GITHUB_USER:$GH_TOKEN" -H "Content-Type: application/json")
28+
29+
# Check if project exists on Spring website
30+
HTTP_CODE=$(curl "${CURL_OPTS[@]}" -o /dev/null -w '%{http_code}' "$BASE_URL")
31+
32+
if [ "$HTTP_CODE" != "200" ]
33+
then
34+
echo "::notice title=Nothing to update on Spring website:: No versions update for $PROJECT project which is not listed on Spring website."
35+
exit 0
36+
fi
37+
38+
MAJOR_MINOR=$(echo "$NEW_VERSION" | cut -d '.' -f1-2)
39+
40+
# Fetch OSS support end date
41+
OSS_SUPPORT_END_DATE=$(curl "${CURL_OPTS[@]}" "$BASE_URL/generations/${MAJOR_MINOR}.x" \
42+
| jq -r '.ossSupportEndDate // empty')
43+
44+
VERSIONS_TO_UPDATE=$NEW_VERSION
45+
46+
# Add next SNAPSHOT version if OSS support is still active
47+
if [[ -n "$OSS_SUPPORT_END_DATE" && "$OSS_SUPPORT_END_DATE" > "$(date '+%F')" ]]
48+
then
49+
if [[ "$NEW_VERSION" == *"-"* ]]
50+
then
51+
NEXT_SNAPSHOT=${NEW_VERSION/-*}
52+
else
53+
PATCH=$(echo "$NEW_VERSION" | cut -d '.' -f3)
54+
PATCH=$((PATCH+1))
55+
NEXT_SNAPSHOT=$MAJOR_MINOR.$PATCH
56+
fi
57+
58+
NEXT_SNAPSHOT+='-SNAPSHOT'
59+
VERSIONS_TO_UPDATE+=" $NEXT_SNAPSHOT"
60+
fi
61+
62+
# Fetch versions to remove
63+
VERSIONS_TO_REMOVE=$(curl "${CURL_OPTS[@]}" "$BASE_URL/releases" \
64+
| jq -r --arg major_minor "$MAJOR_MINOR" '._embedded.releases[].version | select(startswith($major_minor))')
65+
66+
# Delete old versions and filter out existing from VERSIONS_TO_UPDATE
67+
for VERSION_TO_REMOVE in $VERSIONS_TO_REMOVE
68+
do
69+
if echo "$VERSIONS_TO_UPDATE" | grep -qw "$VERSION_TO_REMOVE"
70+
then
71+
# Version exists in update list, remove it from update list
72+
VERSIONS_TO_UPDATE=$(echo ${VERSIONS_TO_UPDATE//$VERSION_TO_REMOVE/})
73+
else
74+
# Version not in update list, delete it
75+
curl "${CURL_OPTS[@]}" -X DELETE --fail --show-error "$BASE_URL/releases/$VERSION_TO_REMOVE"
76+
fi
77+
done
78+
79+
# Add new versions (only the ones remaining in VERSIONS_TO_UPDATE)
80+
if [ -n "$VERSIONS_TO_UPDATE" ]
81+
then
82+
for VERSION in $VERSIONS_TO_UPDATE
83+
do
84+
VERSION_JSON=$(jq -n \
85+
--arg version "$VERSION" \
86+
--arg project "$PROJECT" \
87+
'{version: $version,
88+
referenceDocUrl: "https://docs.spring.io/\($project)/reference/{version}",
89+
apiDocUrl: "https://docs.spring.io/\($project)/docs/\($version)/api",
90+
isAntora: true}')
91+
92+
curl "${CURL_OPTS[@]}" -d "$VERSION_JSON" --fail --show-error "$BASE_URL/releases"
93+
done
94+
fi

.github/workflows/spring-finalize-release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- uses: actions/setup-java@v5
3232
with:
3333
distribution: temurin
34-
java-version: 25
34+
java-version: 24
3535

3636
- name: Tag Release and Next Development Version
3737
id: tag-release
@@ -113,10 +113,10 @@ jobs:
113113
show-progress: false
114114

115115
- name: Update Spring IO website for new version
116-
uses: spring-io/spring-release-actions/update-learn-page@0.0.3
116+
uses: ./.github/spring-github-workflows/.github/actions/spring-website-project-version-update
117117
with:
118-
version: ${{ inputs.milestone }}
119-
website-token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
118+
newVersion: ${{ inputs.milestone }}
119+
token: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
120120

121121
- name: Announce Release in Chat
122122
if: env.CHAT_WEBHOOK_URL

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ This job stages released artifacts using JFrog Artifactory plugin into `libs-sta
8282
- Then [spring-finalize-release.yml](.github/workflows/spring-finalize-release.yml) job is executed, which tags release into GitHub, commits next development version, generates release notes using [Spring Changelog Generator](https://github.com/spring-io/github-changelog-generator) excluding repository admins from `Contributors` section.
8383
The `gh release create` command is performed on a tag for a just released version.
8484
Then `spring.io` project page is updated for a newly released version.
85+
(The [spring-website-project-version-update](.github/actions/spring-website-project-version-update) local action is implemented for this goal).
8586
And in the end the milestone closed, and specific Google Space notified about release (if `SPRING_RELEASE_CHAT_WEBHOOK_URL` secret is present in the repository).
8687

8788
#### Example of Release caller workflow:
8889
https://github.com/spring-io/spring-github-workflows/blob/88d5c5f78e88d00b9ad18885438d4e3657433ccf/samples/release-with-gradle.yml#L1-L24
8990

90-
Such a workflow must be on every branch supposed to be released via GitHub actions.
91+
Such a workflow must be on every branch that is supposed to be released via GitHub actions.
9192

9293
The `buildToolArgs` parameter for this job means extra build tool arguments.
9394
For example, the mentioned `dist` value is a Gradle task in the project.
@@ -105,13 +106,13 @@ https://github.com/spring-io/spring-github-workflows/blob/78b29123a17655f019d800
105106
> **Warning**
106107
> The [spring-artifactory-gradle-release.yml](.github/workflows/spring-artifactory-gradle-release.yml) (and [spring-artifactory-maven-release.yml](.github/workflows/spring-artifactory-maven-release.yml)) already uses 3 of 4 levels of nested reusable workflows.
107108
> Where the caller workflow is the last one.
108-
> Therefore, don't try to reuse your caller workflow.
109+
> Therefore don't try to reuse your caller workflow.
109110
110111
## Verify Staged Artifacts
111112

112113
The `verify-staged` job expects an optional `verifyStagedWorkflow` input (the `verify-staged-artifacts.yml`, by default) workflow supplied from the target project.
113114
For example, [Spring Integration for AWS](https://github.com/spring-projects/spring-integration-aws) uses `jfrog rt download` command to verify that released `spring-integration-aws-${{ inputs.releaseVersion }}.jar` is valid.
114-
Other projects may check out their samples repository and set up a release version to perform smoke tests against just staged artifacts.
115+
Other projects may check out their samples repository and set up release version to perform smoke tests against just staged artifacts.
115116

116117
#### Verify the staged workflow sample:
117118
https://github.com/spring-io/spring-github-workflows/blob/78b29123a17655f019d800690cc906d692f836a9/samples/verify-staged-artifacts.yml#L1-L28

0 commit comments

Comments
 (0)