Skip to content

Commit a788853

Browse files
committed
Align GitHub Actions configuration with Spring Boot
1 parent 60f12e4 commit a788853

File tree

13 files changed

+415
-72
lines changed

13 files changed

+415
-72
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Create GitHub Release
2+
description: Create the release on GitHub with a changelog
3+
inputs:
4+
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
9+
required: true
10+
pre-release:
11+
description: Whether the release is a pre-release (a milestone or release candidate)
12+
required: false
13+
default: 'false'
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Generate Changelog
18+
uses: spring-io/github-changelog-generator@185319ad7eaa75b0e8e72e4b6db19c8b2cb8c4c1 #v0.0.11
19+
with:
20+
milestone: ${{ inputs.milestone }}
21+
token: ${{ inputs.token }}
22+
config-file: .github/actions/create-github-release/changelog-generator.yml
23+
- name: Create GitHub Release
24+
env:
25+
GITHUB_TOKEN: ${{ inputs.token }}
26+
shell: bash
27+
run: gh release create ${{ format('v{0}', inputs.milestone) }} --notes-file changelog.md ${{ inputs.pre-release == 'true' && '--prerelease' || '' }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
changelog:
2+
repository: spring-projects/spring-restdocs
3+
sections:
4+
- title: ":star: New Features"
5+
labels:
6+
- "type: enhancement"
7+
- title: ":lady_beetle: Bug Fixes"
8+
labels:
9+
- "type: bug"
10+
- "type: regression"
11+
- title: ":notebook_with_decorative_cover: Documentation"
12+
labels:
13+
- "type: documentation"
14+
- title: ":hammer: Dependency Upgrades"
15+
sort: "title"
16+
labels:
17+
- "type: dependency-upgrade"
18+
issues:
19+
ports:
20+
- label: "status: forward-port"
21+
bodyExpression: 'Forward port of issue #(\d+).*'
22+
- label: "status: back-port"
23+
bodyExpression: 'Back port of issue #(\d+).*'
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Prepare Gradle Build'
2+
description: 'Prepares a Gradle build. Sets up Java and Gradle and configures Gradle properties'
3+
inputs:
4+
java-version:
5+
required: false
6+
default: '17'
7+
description: 'The Java version to use for the build'
8+
java-distribution:
9+
required: false
10+
default: 'liberica'
11+
description: 'The Java distribution to use for the build'
12+
java-toolchain:
13+
required: false
14+
default: 'false'
15+
description: 'Whether a Java toolchain should be used'
16+
develocity-access-key:
17+
required: false
18+
description: 'The access key for authentication with ge.spring.io'
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Set Up Java
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: ${{ inputs.java-distribution }}
26+
java-version: |
27+
${{ inputs.java-version }}
28+
${{ inputs.java-toolchain == 'true' && '17' || '' }}
29+
- name: Set Up Gradle
30+
uses: gradle/actions/setup-gradle@d9c87d481d55275bb5441eef3fe0e46805f9ef70 # v3.5.0
31+
with:
32+
cache-read-only: false
33+
develocity-access-key: ${{ inputs.develocity-access-key }}
34+
- name: Configure Gradle Properties
35+
shell: bash
36+
run: |
37+
mkdir -p $HOME/.gradle
38+
echo 'systemProp.user.name=spring-builds+github' >> $HOME/.gradle/gradle.properties
39+
echo 'systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false' >> $HOME/.gradle/gradle.properties
40+
echo 'org.gradle.daemon=false' >> $HOME/.gradle/gradle.properties
41+
- name: Configure Toolchain Properties
42+
if: ${{ inputs.java-toolchain == 'true' }}
43+
shell: bash
44+
run: |
45+
echo toolchainVersion=${{ inputs.java-version }} >> $HOME/.gradle/gradle.properties
46+
echo systemProp.org.gradle.java.installations.auto-detect=false >> $HOME/.gradle/gradle.properties
47+
echo systemProp.org.gradle.java.installations.auto-download=false >> $HOME/.gradle/gradle.properties
48+
echo systemProp.org.gradle.java.installations.paths=${{ format('$JAVA_HOME_{0}_X64', inputs.java-version) }} >> $HOME/.gradle/gradle.properties
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Print JVM thread dumps
2+
description: Prints a thread dump for all running JVMs
3+
runs:
4+
using: composite
5+
steps:
6+
- if: ${{ runner.os == 'Linux' }}
7+
shell: bash
8+
run: |
9+
for jvm_pid in $(jps -q -J-XX:+PerfDisableSharedMem); do
10+
jcmd $jvm_pid Thread.print
11+
done
12+
- if: ${{ runner.os == 'Windows' }}
13+
shell: powershell
14+
run: |
15+
foreach ($jvm_pid in $(jps -q -J-XX:+PerfDisableSharedMem)) {
16+
jcmd $jvm_pid Thread.print
17+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Send Notification
2+
description: Sends a Google Chat message as a notification of the job's outcome
3+
inputs:
4+
webhook-url:
5+
description: 'Google Chat Webhook URL'
6+
required: true
7+
status:
8+
description: 'Status of the job'
9+
required: true
10+
build-scan-url:
11+
description: 'URL of the build scan to include in the notification'
12+
run-name:
13+
description: 'Name of the run to include in the notification'
14+
default: ${{ format('{0} {1}', github.ref_name, github.job) }}
15+
runs:
16+
using: composite
17+
steps:
18+
- shell: bash
19+
run: |
20+
echo "BUILD_SCAN=${{ inputs.build-scan-url == '' && ' [build scan unavailable]' || format(' [<{0}|Build Scan>]', inputs.build-scan-url) }}" >> "$GITHUB_ENV"
21+
echo "RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_ENV"
22+
- shell: bash
23+
if: ${{ inputs.status == 'success' }}
24+
run: |
25+
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
27+
if: ${{ inputs.status == 'failure' }}
28+
run: |
29+
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
31+
if: ${{ inputs.status == 'cancelled' }}
32+
run: |
33+
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was cancelled"}' || true
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Sync to Maven Central
2+
description: Syncs a release to Maven Central and waits for it to be available for use
3+
inputs:
4+
jfrog-cli-config-token:
5+
description: 'Config token for the JFrog CLI'
6+
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'
12+
required: true
13+
ossrh-s01-token-password:
14+
description: 'Password for authentication with s01.oss.sonatype.org'
15+
required: true
16+
ossrh-s01-staging-profile:
17+
description: 'Staging profile to use when syncing to Central'
18+
required: true
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Set Up JFrog CLI
23+
uses: jfrog/setup-jfrog-cli@8bab65dc312163b065ac5b03de6f6a5bdd1bec41 # v4.1.3
24+
env:
25+
JF_ENV_SPRING: ${{ inputs.jfrog-cli-config-token }}
26+
- name: Download Release Artifacts
27+
shell: bash
28+
run: jf rt download --spec ${{ format('{0}/artifacts.spec', github.action_path) }} --spec-vars 'buildName=${{ format('spring-restdocs-{0}', inputs.spring-restdocs-version) }};buildNumber=${{ github.run_number }}'
29+
- name: Sync
30+
uses: spring-io/nexus-sync-action@42477a2230a2f694f9eaa4643fa9e76b99b7ab84 # v0.0.1
31+
with:
32+
username: ${{ inputs.ossrh-s01-token-username }}
33+
password: ${{ inputs.ossrh-s01-token-password }}
34+
staging-profile-name: ${{ inputs.ossrh-s01-staging-profile }}
35+
create: true
36+
upload: true
37+
close: true
38+
release: true
39+
generate-checksums: true
40+
- 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"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"files": [
3+
{
4+
"aql": {
5+
"items.find": {
6+
"$and": [
7+
{
8+
"@build.name": "${buildName}",
9+
"@build.number": "${buildNumber}",
10+
"path": {
11+
"$nmatch": "org/springframework/restdocs/spring-restdocs/*"
12+
}
13+
}
14+
]
15+
}
16+
},
17+
"target": "nexus/"
18+
}
19+
]
20+
}

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

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,37 @@ on:
66
concurrency:
77
group: ${{ github.workflow }}-${{ github.ref }}
88
jobs:
9-
build:
10-
if: ${{ github.repository == 'spring-projects/spring-restdocs' }}
9+
build-and-deploy-snapshot:
1110
name: Build and Deploy Snapshot
1211
runs-on: ubuntu-latest
12+
if: ${{ github.repository == 'spring-projects/spring-restdocs' }}
1313
steps:
14-
- name: Set Up Java
15-
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
16-
with:
17-
distribution: 'liberica'
18-
java-version: 17
1914
- name: Check Out Code
20-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
21-
- name: Set Up Gradle
22-
uses: gradle/actions/setup-gradle@750cdda3edd6d51b7fdfc069d2e2818cf3c44f4c # v3.3.1
23-
- name: Configure Gradle Properties
24-
shell: bash
25-
run: |
26-
mkdir -p $HOME/.gradle
27-
echo 'systemProp.user.name=spring-builds+github' >> $HOME/.gradle/gradle.properties
28-
echo 'systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false' >> $HOME/.gradle/gradle.properties
29-
echo 'org.gradle.daemon=false' >> $HOME/.gradle/gradle.properties
15+
uses: actions/checkout@v4
3016
- name: Build and Publish
31-
env:
32-
DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
33-
run: ./gradlew -PdeploymentRepository=$(pwd)/distribution-repository build publishAllPublicationsToDeploymentRepository
17+
id: build-and-publish
18+
uses: ./.github/actions/build
19+
with:
20+
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
21+
publish: true
3422
- name: Deploy
3523
uses: spring-io/artifactory-deploy-action@26bbe925a75f4f863e1e529e85be2d0093cac116 # v0.0.1
3624
with:
3725
uri: 'https://repo.spring.io'
3826
username: ${{ secrets.ARTIFACTORY_USERNAME }}
3927
password: ${{ secrets.ARTIFACTORY_PASSWORD }}
40-
build-name: spring-restdocs
28+
build-name: 'spring-restdocs-3.0.x'
4129
repository: 'libs-snapshot-local'
42-
folder: 'distribution-repository'
30+
folder: 'deployment-repository'
4331
signing-key: ${{ secrets.GPG_PRIVATE_KEY }}
4432
signing-passphrase: ${{ secrets.GPG_PASSPHRASE }}
45-
artifact-properties: |
46-
/**/spring-restdocs-*.zip::zip.type=docs,zip.deployed=false
33+
- name: Send Notification
34+
uses: ./.github/actions/send-notification
35+
if: always()
36+
with:
37+
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
38+
status: ${{ job.status }}
39+
build-scan-url: ${{ steps.build-and-publish.outputs.build-scan-url }}
40+
run-name: ${{ format('{0} | Linux | Java 17', github.ref_name) }}
41+
outputs:
42+
version: ${{ steps.build-and-publish.outputs.version }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build Pull Request
2+
on: pull_request
3+
4+
permissions:
5+
contents: read
6+
7+
jobs:
8+
build:
9+
name: Build Pull Request
10+
runs-on: ubuntu-latest
11+
if: ${{ github.repository == 'spring-projects/spring-restdocs' }}
12+
steps:
13+
- name: Set Up JDK 17
14+
uses: actions/setup-java@v4
15+
with:
16+
java-version: '17'
17+
distribution: 'liberica'
18+
- name: Check Out
19+
uses: actions/checkout@v4
20+
- name: Validate Gradle Wrapper
21+
uses: gradle/actions/wrapper-validation@d9c87d481d55275bb5441eef3fe0e46805f9ef70 # v3.5.0
22+
- name: Set Up Gradle
23+
uses: gradle/actions/setup-gradle@d9c87d481d55275bb5441eef3fe0e46805f9ef70 # v3.5.0
24+
- name: Build
25+
env:
26+
run: ./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --no-parallel --continue build
27+
- name: Upload Build Reports
28+
uses: actions/upload-artifact@v4
29+
if: failure()
30+
with:
31+
name: build-reports
32+
path: '**/build/reports/'

.github/workflows/build.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)