Skip to content

Commit ef12eff

Browse files
committed
Align GitHub Actions config more closely with Spring Boot
1 parent d34584b commit ef12eff

File tree

12 files changed

+166
-118
lines changed

12 files changed

+166
-118
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Await HTTP Resource
2+
description: 'Waits for an HTTP resource to be available (a HEAD request succeeds)'
3+
inputs:
4+
url:
5+
description: 'URL of the resource to await'
6+
required: true
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Await HTTP resource
11+
shell: bash
12+
run: |
13+
url=${{ inputs.url }}
14+
echo "Waiting for $url"
15+
until curl --fail --head --silent ${{ inputs.url }} > /dev/null
16+
do
17+
echo "."
18+
sleep 60
19+
done
20+
echo "$url is available"

.github/actions/build/action.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,52 @@
1-
name: 'Build'
1+
name: Build
22
description: 'Builds the project, optionally publishing it to a local deployment repository'
33
inputs:
4-
java-version:
4+
develocity-access-key:
5+
description: 'Access key for authentication with ge.spring.io'
56
required: false
6-
default: '17'
7-
description: 'The Java version to compile and test with'
7+
gradle-cache-read-only:
8+
description: 'Whether Gradle''s cache should be read only'
9+
required: false
10+
default: 'true'
811
java-distribution:
12+
description: 'Java distribution to use'
913
required: false
1014
default: 'liberica'
11-
description: 'The Java distribution to use for the build'
12-
java-toolchain:
15+
java-early-access:
16+
description: 'Whether the Java version is in early access'
1317
required: false
1418
default: 'false'
19+
java-toolchain:
1520
description: 'Whether a Java toolchain should be used'
16-
publish:
1721
required: false
1822
default: 'false'
23+
java-version:
24+
description: 'Java version to compile and test with'
25+
required: false
26+
default: '17'
27+
publish:
1928
description: 'Whether to publish artifacts ready for deployment to Artifactory'
20-
develocity-access-key:
2129
required: false
22-
description: 'The access key for authentication with ge.spring.io'
30+
default: 'false'
2331
outputs:
2432
build-scan-url:
25-
description: 'The URL, if any, of the build scan produced by the build'
33+
description: 'URL, if any, of the build scan produced by the build'
2634
value: ${{ (inputs.publish == 'true' && steps.publish.outputs.build-scan-url) || steps.build.outputs.build-scan-url }}
2735
version:
28-
description: 'The version that was built'
36+
description: 'Version that was built'
2937
value: ${{ steps.read-version.outputs.version }}
3038
runs:
3139
using: composite
3240
steps:
3341
- name: Prepare Gradle Build
3442
uses: ./.github/actions/prepare-gradle-build
3543
with:
44+
cache-read-only: ${{ inputs.gradle-cache-read-only }}
3645
develocity-access-key: ${{ inputs.develocity-access-key }}
37-
java-version: ${{ inputs.java-version }}
3846
java-distribution: ${{ inputs.java-distribution }}
47+
java-early-access: ${{ inputs.java-early-access }}
3948
java-toolchain: ${{ inputs.java-toolchain }}
49+
java-version: ${{ inputs.java-version }}
4050
- name: Build
4151
id: build
4252
if: ${{ inputs.publish == 'false' }}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
name: Create GitHub Release
2-
description: Create the release on GitHub with a changelog
2+
description: 'Create the release on GitHub with a changelog'
33
inputs:
44
milestone:
5-
description: Name of the GitHub milestone for which a release will be created
6-
required: true
7-
token:
8-
description: Token to use for authentication with GitHub
5+
description: 'Name of the GitHub milestone for which a release will be created'
96
required: true
107
pre-release:
11-
description: Whether the release is a pre-release (a milestone or release candidate)
8+
description: 'Whether the release is a pre-release (a milestone or release candidate)'
129
required: false
1310
default: 'false'
11+
token:
12+
description: 'Token to use for authentication with GitHub'
13+
required: true
1414
runs:
1515
using: composite
1616
steps:
1717
- name: Generate Changelog
1818
uses: spring-io/github-changelog-generator@185319ad7eaa75b0e8e72e4b6db19c8b2cb8c4c1 #v0.0.11
1919
with:
20+
config-file: .github/actions/create-github-release/changelog-generator.yml
2021
milestone: ${{ inputs.milestone }}
2122
token: ${{ inputs.token }}
22-
config-file: .github/actions/create-github-release/changelog-generator.yml
2323
- name: Create GitHub Release
24+
shell: bash
2425
env:
2526
GITHUB_TOKEN: ${{ inputs.token }}
26-
shell: bash
2727
run: gh release create ${{ format('v{0}', inputs.milestone) }} --notes-file changelog.md ${{ inputs.pre-release == 'true' && '--prerelease' || '' }}

.github/actions/create-github-release/changelog-generator.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
changelog:
2-
repository: spring-projects/spring-restdocs
32
sections:
43
- title: ":star: New Features"
54
labels:

.github/actions/prepare-gradle-build/action.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,55 @@
1-
name: 'Prepare Gradle Build'
1+
name: Prepare Gradle Build
22
description: 'Prepares a Gradle build. Sets up Java and Gradle and configures Gradle properties'
33
inputs:
4-
java-version:
4+
cache-read-only:
5+
description: 'Whether Gradle''s cache should be read only'
6+
required: false
7+
default: 'true'
8+
develocity-access-key:
9+
description: 'Access key for authentication with ge.spring.io'
510
required: false
6-
default: '17'
7-
description: 'The Java version to use for the build'
811
java-distribution:
12+
description: 'Java distribution to use'
913
required: false
1014
default: 'liberica'
11-
description: 'The Java distribution to use for the build'
12-
java-toolchain:
15+
java-early-access:
16+
description: 'Whether the Java version is in early access. When true, forces java-distribution to temurin'
1317
required: false
1418
default: 'false'
19+
java-toolchain:
1520
description: 'Whether a Java toolchain should be used'
16-
develocity-access-key:
1721
required: false
18-
description: 'The access key for authentication with ge.spring.io'
22+
default: 'false'
23+
java-version:
24+
description: 'Java version to use for the build'
25+
required: false
26+
default: '17'
1927
runs:
2028
using: composite
2129
steps:
30+
- name: Free Disk Space
31+
if: ${{ runner.os == 'Linux' }}
32+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
33+
with:
34+
tool-cache: true
35+
docker-images: false
2236
- name: Set Up Java
23-
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
37+
uses: actions/setup-java@v4
2438
with:
25-
distribution: ${{ inputs.java-distribution }}
39+
distribution: ${{ inputs.java-early-access == 'true' && 'temurin' || (inputs.java-distribution || 'liberica') }}
2640
java-version: |
27-
${{ inputs.java-version }}
41+
${{ inputs.java-early-access == 'true' && format('{0}-ea', inputs.java-version) || inputs.java-version }}
2842
${{ inputs.java-toolchain == 'true' && '17' || '' }}
29-
- name: Set Up Gradle
43+
- name: Set Up Gradle With Read/Write Cache
44+
if: ${{ inputs.cache-read-only == 'false' }}
3045
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0
3146
with:
3247
cache-read-only: false
3348
develocity-access-key: ${{ inputs.develocity-access-key }}
49+
- name: Set Up Gradle
50+
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0
51+
with:
52+
develocity-access-key: ${{ inputs.develocity-access-key }}
3453
- name: Configure Gradle Properties
3554
shell: bash
3655
run: |

.github/actions/print-jvm-thread-dumps/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Print JVM thread dumps
2-
description: Prints a thread dump for all running JVMs
2+
description: 'Prints a thread dump for all running JVMs'
33
runs:
44
using: composite
55
steps:
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
name: Send Notification
2-
description: Sends a Google Chat message as a notification of the job's outcome
2+
description: 'Sends a Google Chat message as a notification of the job''s outcome'
33
inputs:
4-
webhook-url:
5-
description: 'Google Chat Webhook URL'
6-
required: true
7-
status:
8-
description: 'Status of the job'
9-
required: true
104
build-scan-url:
115
description: 'URL of the build scan to include in the notification'
6+
required: false
127
run-name:
138
description: 'Name of the run to include in the notification'
9+
required: false
1410
default: ${{ format('{0} {1}', github.ref_name, github.job) }}
11+
status:
12+
description: 'Status of the job'
13+
required: true
14+
webhook-url:
15+
description: 'Google Chat Webhook URL'
16+
required: true
1517
runs:
1618
using: composite
1719
steps:
18-
- shell: bash
20+
- name: Prepare Variables
21+
shell: bash
1922
run: |
2023
echo "BUILD_SCAN=${{ inputs.build-scan-url == '' && ' [build scan unavailable]' || format(' [<{0}|Build Scan>]', inputs.build-scan-url) }}" >> "$GITHUB_ENV"
2124
echo "RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_ENV"
22-
- shell: bash
25+
- name: Success Notification
2326
if: ${{ inputs.status == 'success' }}
27+
shell: bash
2428
run: |
2529
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was successful ${{ env.BUILD_SCAN }}"}' || true
26-
- shell: bash
30+
- name: Failure Notification
2731
if: ${{ inputs.status == 'failure' }}
32+
shell: bash
2833
run: |
2934
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<users/all> *<${{ env.RUN_URL }}|${{ inputs.run-name }}> failed* ${{ env.BUILD_SCAN }}"}' || true
30-
- shell: bash
35+
- name: Cancel Notification
3136
if: ${{ inputs.status == 'cancelled' }}
37+
shell: bash
3238
run: |
3339
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was cancelled"}' || true
Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
name: Sync to Maven Central
2-
description: Syncs a release to Maven Central and waits for it to be available for use
2+
description: 'Syncs a release to Maven Central and waits for it to be available for use'
33
inputs:
44
jfrog-cli-config-token:
55
description: 'Config token for the JFrog CLI'
66
required: true
7-
spring-restdocs-version:
8-
description: 'The version of Spring REST Docs that is being synced to Central'
9-
required: true
10-
ossrh-s01-token-username:
11-
description: 'Username for authentication with s01.oss.sonatype.org'
7+
ossrh-s01-staging-profile:
8+
description: 'Staging profile to use when syncing to Central'
129
required: true
1310
ossrh-s01-token-password:
1411
description: 'Password for authentication with s01.oss.sonatype.org'
1512
required: true
16-
ossrh-s01-staging-profile:
17-
description: 'Staging profile to use when syncing to Central'
13+
ossrh-s01-token-username:
14+
description: 'Username for authentication with s01.oss.sonatype.org'
15+
required: true
16+
spring-restdocs-version:
17+
description: 'Version of Spring REST Docs that is being synced to Central'
1818
required: true
1919
runs:
2020
using: composite
@@ -29,22 +29,15 @@ runs:
2929
- name: Sync
3030
uses: spring-io/nexus-sync-action@42477a2230a2f694f9eaa4643fa9e76b99b7ab84 # v0.0.1
3131
with:
32-
username: ${{ inputs.ossrh-s01-token-username }}
32+
close: true
33+
create: true
34+
generate-checksums: true
3335
password: ${{ inputs.ossrh-s01-token-password }}
36+
release: true
3437
staging-profile-name: ${{ inputs.ossrh-s01-staging-profile }}
35-
create: true
3638
upload: true
37-
close: true
38-
release: true
39-
generate-checksums: true
39+
username: ${{ inputs.ossrh-s01-token-username }}
4040
- name: Await
41-
shell: bash
42-
run: |
43-
url=${{ format('https://repo.maven.apache.org/maven2/org/springframework/restdocs/spring-restdocs-core/{0}/spring-restdocs-core-{0}.jar', inputs.spring-restdocs-version) }}
44-
echo "Waiting for $url"
45-
until curl --fail --head --silent $url > /dev/null
46-
do
47-
echo "."
48-
sleep 60
49-
done
50-
echo "$url is available"
41+
uses: ./.github/actions/await-http-resource
42+
with:
43+
url: ${{ format('https://repo.maven.apache.org/maven2/org/springframework/restdocs/spring-restdocs-core/{0}/spring-restdocs-core-{0}.jar', inputs.spring-restdocs-version) }}

.github/workflows/build-and-deploy-snapshot.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,38 @@ concurrency:
88
jobs:
99
build-and-deploy-snapshot:
1010
name: Build and Deploy Snapshot
11-
runs-on: ubuntu-latest
1211
if: ${{ github.repository == 'spring-projects/spring-restdocs' }}
12+
runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }}
1313
steps:
1414
- name: Check Out Code
15-
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
15+
uses: actions/checkout@v4
1616
- name: Build and Publish
1717
id: build-and-publish
1818
uses: ./.github/actions/build
1919
with:
20-
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
20+
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
21+
gradle-cache-read-only: false
2122
publish: true
2223
- name: Deploy
2324
uses: spring-io/artifactory-deploy-action@26bbe925a75f4f863e1e529e85be2d0093cac116 # v0.0.1
2425
with:
25-
uri: 'https://repo.spring.io'
26-
username: ${{ secrets.ARTIFACTORY_USERNAME }}
27-
password: ${{ secrets.ARTIFACTORY_PASSWORD }}
28-
build-name: 'spring-restdocs-3.0.x'
29-
repository: 'libs-snapshot-local'
26+
artifact-properties: |
27+
/**/spring-restdocs-*.zip::zip.type=docs,zip.deployed=false
28+
build-name: ${{ format('spring-restdocs-{0}', github.ref_name) }}
3029
folder: 'deployment-repository'
30+
password: ${{ secrets.ARTIFACTORY_PASSWORD }}
31+
repository: ${{ 'libs-snapshot-local' }}
3132
signing-key: ${{ secrets.GPG_PRIVATE_KEY }}
3233
signing-passphrase: ${{ secrets.GPG_PASSPHRASE }}
33-
artifact-properties: |
34-
/**/spring-restdocs-*.zip::zip.type=docs,zip.deployed=false
34+
uri: 'https://repo.spring.io'
35+
username: ${{ secrets.ARTIFACTORY_USERNAME }}
3536
- name: Send Notification
36-
uses: ./.github/actions/send-notification
3737
if: always()
38+
uses: ./.github/actions/send-notification
3839
with:
39-
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
40-
status: ${{ job.status }}
4140
build-scan-url: ${{ steps.build-and-publish.outputs.build-scan-url }}
4241
run-name: ${{ format('{0} | Linux | Java 17', github.ref_name) }}
42+
status: ${{ job.status }}
43+
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
4344
outputs:
4445
version: ${{ steps.build-and-publish.outputs.version }}

0 commit comments

Comments
 (0)