Skip to content

Commit be887f8

Browse files
committed
Introduce base GHA support
This commit adds support for building and deploying snapshots to repo.spring.io as well as building pull requests.
1 parent b78aa3c commit be887f8

File tree

6 files changed

+268
-0
lines changed

6 files changed

+268
-0
lines changed

.github/actions/build/action.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: 'Build'
2+
description: 'Builds the project, optionally publishing it to a local deployment repository'
3+
inputs:
4+
develocity-access-key:
5+
description: 'Access key for authentication with ge.spring.io'
6+
required: false
7+
java-distribution:
8+
description: 'Java distribution to use'
9+
required: false
10+
default: 'liberica'
11+
java-early-access:
12+
description: 'Whether the Java version is in early access'
13+
required: false
14+
default: 'false'
15+
java-toolchain:
16+
description: 'Whether a Java toolchain should be used'
17+
required: false
18+
default: 'false'
19+
java-version:
20+
description: 'Java version to compile and test with'
21+
required: false
22+
default: '17'
23+
opensource-repository-password:
24+
description: 'Password for authentication with the open-source repository'
25+
required: false
26+
opensource-repository-username:
27+
description: 'Username for authentication with the open-source repository'
28+
required: false
29+
publish:
30+
description: 'Whether to publish artifacts ready for deployment to Artifactory'
31+
required: false
32+
default: 'false'
33+
outputs:
34+
build-scan-url:
35+
description: 'URL, if any, of the build scan produced by the build'
36+
value: ${{ (inputs.publish == 'true' && steps.publish.outputs.build-scan-url) || steps.build.outputs.build-scan-url }}
37+
version:
38+
description: 'Version that was built'
39+
value: ${{ steps.read-version.outputs.version }}
40+
runs:
41+
using: composite
42+
steps:
43+
- name: Prepare Gradle Build
44+
uses: ./.github/actions/prepare-gradle-build
45+
with:
46+
develocity-access-key: ${{ inputs.develocity-access-key }}
47+
java-distribution: ${{ inputs.java-distribution }}
48+
java-early-access: ${{ inputs.java-early-access }}
49+
java-toolchain: ${{ inputs.java-toolchain }}
50+
java-version: ${{ inputs.java-version }}
51+
- name: Build
52+
id: build
53+
if: ${{ inputs.publish == 'false' }}
54+
shell: bash
55+
env:
56+
SPRING_REPOSITORY_PASSWORD: ${{ inputs.opensource-repository-password }}
57+
SPRING_REPOSITORY_USERNAME: ${{ inputs.opensource-repository-username }}
58+
run: ./gradlew check
59+
- name: Publish
60+
id: publish
61+
if: ${{ inputs.publish == 'true' }}
62+
shell: bash
63+
env:
64+
SPRING_REPOSITORY_PASSWORD: ${{ inputs.opensource-repository-password }}
65+
SPRING_REPOSITORY_USERNAME: ${{ inputs.opensource-repository-username }}
66+
run: ./gradlew -PdeploymentRepository=$(pwd)/deployment-repository build dist publishAllPublicationsToDeploymentRepository
67+
- name: Read Version From gradle.properties
68+
id: read-version
69+
shell: bash
70+
run: |
71+
version=$(sed -n 's/version=\(.*\)/\1/p' gradle.properties)
72+
echo "Version is $version"
73+
echo "version=$version" >> $GITHUB_OUTPUT
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Prepare Gradle Build
2+
description: 'Prepares a Gradle build. Sets up Java and Gradle and configures Gradle properties'
3+
inputs:
4+
develocity-access-key:
5+
description: 'Access key for authentication with ge.spring.io'
6+
required: false
7+
java-distribution:
8+
description: 'Java distribution to use'
9+
required: false
10+
default: 'liberica'
11+
java-early-access:
12+
description: 'Whether the Java version is in early access. When true, forces java-distribution to temurin'
13+
required: false
14+
default: 'false'
15+
java-toolchain:
16+
description: 'Whether a Java toolchain should be used'
17+
required: false
18+
default: 'false'
19+
java-version:
20+
description: 'Java version to use for the build'
21+
required: false
22+
default: '17'
23+
runs:
24+
using: composite
25+
steps:
26+
- name: Set Up Java
27+
uses: actions/setup-java@v4
28+
with:
29+
distribution: ${{ inputs.java-early-access == 'true' && 'temurin' || (inputs.java-distribution || 'liberica') }}
30+
java-version: |
31+
${{ inputs.java-early-access == 'true' && format('{0}-ea', inputs.java-version) || inputs.java-version }}
32+
${{ inputs.java-toolchain == 'true' && '17' || '' }}
33+
- name: Set Up Gradle
34+
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0
35+
with:
36+
cache-read-only: false
37+
develocity-access-key: ${{ inputs.develocity-access-key }}
38+
- name: Configure Gradle Properties
39+
shell: bash
40+
run: |
41+
mkdir -p $HOME/.gradle
42+
echo 'systemProp.user.name=spring-builds+github' >> $HOME/.gradle/gradle.properties
43+
echo 'systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false' >> $HOME/.gradle/gradle.properties
44+
echo 'org.gradle.daemon=false' >> $HOME/.gradle/gradle.properties
45+
echo 'org.gradle.daemon=4' >> $HOME/.gradle/gradle.properties
46+
- name: Configure Toolchain Properties
47+
if: ${{ inputs.java-toolchain == 'true' }}
48+
shell: bash
49+
run: |
50+
echo toolchainVersion=${{ inputs.java-version }} >> $HOME/.gradle/gradle.properties
51+
echo systemProp.org.gradle.java.installations.auto-detect=false >> $HOME/.gradle/gradle.properties
52+
echo systemProp.org.gradle.java.installations.auto-download=false >> $HOME/.gradle/gradle.properties
53+
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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Send Notification
2+
description: 'Sends a Google Chat message as a notification of the job''s outcome'
3+
inputs:
4+
build-scan-url:
5+
description: 'URL of the build scan to include in the notification'
6+
required: false
7+
run-name:
8+
description: 'Name of the run to include in the notification'
9+
required: false
10+
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
17+
runs:
18+
using: composite
19+
steps:
20+
- name: Prepare Variables
21+
shell: bash
22+
run: |
23+
echo "BUILD_SCAN=${{ inputs.build-scan-url == '' && ' [build scan unavailable]' || format(' [<{0}|Build Scan>]', inputs.build-scan-url) }}" >> "$GITHUB_ENV"
24+
echo "RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_ENV"
25+
- name: Success Notification
26+
if: ${{ inputs.status == 'success' }}
27+
shell: bash
28+
run: |
29+
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
30+
- name: Failure Notification
31+
if: ${{ inputs.status == 'failure' }}
32+
shell: bash
33+
run: |
34+
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
35+
- name: Cancel Notification
36+
if: ${{ inputs.status == 'cancelled' }}
37+
shell: bash
38+
run: |
39+
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: Build and Deploy Snapshot
2+
on:
3+
push:
4+
branches:
5+
- main
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
jobs:
9+
build-and-deploy-snapshot:
10+
name: Build and Deploy Snapshot
11+
if: ${{ github.repository == 'spring-projects/spring-webflow' }}
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 60
14+
steps:
15+
- name: Check Out Code
16+
uses: actions/checkout@v4
17+
- name: Build and Publish
18+
id: build-and-publish
19+
uses: ./.github/actions/build
20+
with:
21+
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
22+
opensource-repository-password: ${{ secrets.ARTIFACTORY_PASSWORD }}
23+
opensource-repository-username: ${{ secrets.ARTIFACTORY_USERNAME }}
24+
publish: true
25+
- name: Deploy
26+
uses: spring-io/artifactory-deploy-action@26bbe925a75f4f863e1e529e85be2d0093cac116 # v0.0.1
27+
with:
28+
artifact-properties: |
29+
/**/spring-webflow-*.zip::zip.name=spring-webflow,zip.deployed=false
30+
/**/spring-webflow-*-docs.zip::zip.type=docs
31+
/**/spring-webflow-*-dist.zip::zip.type=dist
32+
/**/spring-webflow-*-schema.zip::zip.type=schema
33+
build-name: 'spring-webflow-3.0.x'
34+
folder: 'deployment-repository'
35+
password: ${{ secrets.ARTIFACTORY_PASSWORD }}
36+
repository: 'libs-snapshot-local'
37+
signing-key: ${{ secrets.GPG_PRIVATE_KEY }}
38+
signing-passphrase: ${{ secrets.GPG_PASSPHRASE }}
39+
uri: 'https://repo.spring.io'
40+
username: ${{ secrets.ARTIFACTORY_USERNAME }}
41+
- name: Send Notification
42+
if: always()
43+
uses: ./.github/actions/send-notification
44+
with:
45+
build-scan-url: ${{ steps.build-and-publish.outputs.build-scan-url }}
46+
run-name: ${{ format('{0} | Linux | Java 17', github.ref_name) }}
47+
status: ${{ job.status }}
48+
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
49+
outputs:
50+
version: ${{ steps.build-and-publish.outputs.version }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build Pull Request
2+
on: pull_request
3+
permissions:
4+
contents: read
5+
jobs:
6+
build:
7+
name: Build Pull Request
8+
if: ${{ github.repository == 'spring-projects/spring-webflow' }}
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 60
11+
steps:
12+
- name: Set Up JDK 17
13+
uses: actions/setup-java@v4
14+
with:
15+
distribution: 'liberica'
16+
java-version: '17'
17+
- name: Check Out
18+
uses: actions/checkout@v4
19+
- name: Set Up Gradle
20+
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0
21+
- name: Build
22+
env:
23+
CI: 'true'
24+
GRADLE_ENTERPRISE_URL: 'https://ge.spring.io'
25+
SPRING_REPOSITORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
26+
SPRING_REPOSITORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
27+
run: ./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --no-parallel --continue build
28+
- name: Print JVM Thread Dumps When Cancelled
29+
if: cancelled()
30+
uses: ./.github/actions/print-jvm-thread-dumps
31+
- name: Upload Build Reports
32+
if: failure()
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: build-reports
36+
path: '**/build/reports/'

0 commit comments

Comments
 (0)