91 lines
3.6 KiB
YAML
91 lines
3.6 KiB
YAML
name: 'Build'
|
|
inputs:
|
|
java-version:
|
|
required: false
|
|
type: string
|
|
default: '17'
|
|
description: 'The Java version to compile and test with'
|
|
java-toolchain:
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
description: 'Whether a Java toolchain should be used'
|
|
publish:
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
description: 'Whether to publish artifacts ready for deployment to Artifactory'
|
|
gradle-enterprise-secret-access-key:
|
|
required: false
|
|
type: string
|
|
description: 'The secret access key for authentication with ge.spring.io'
|
|
gradle-enterprise-cache-user:
|
|
required: false
|
|
type: string
|
|
description: 'The username for authentication with the remote build cache'
|
|
gradle-enterprise-cache-password:
|
|
required: false
|
|
type: string
|
|
description: 'The password for authentication with the remote build cache'
|
|
outputs:
|
|
build-scan-url:
|
|
value: ${{ (inputs.publish && steps.build-and-publish.outputs.build-scan-url) || steps.build.outputs.build-scan-url }}
|
|
version:
|
|
value: ${{ steps.read-version.outputs.version }}
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Set Up Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'liberica'
|
|
java-version: |
|
|
${{ inputs.java-version }}
|
|
${{ inputs.java-toolchain && '17' || '' }}
|
|
- name: Set Up Gradle
|
|
uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 #v3.3.0
|
|
with:
|
|
cache-read-only: false
|
|
- name: Configure Gradle Properties
|
|
shell: bash
|
|
run: |
|
|
mkdir -p $HOME/.gradle
|
|
echo 'systemProp.user.name=spring-builds+github' >> $HOME/.gradle/gradle.properties
|
|
echo 'systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false' >> $HOME/.gradle/gradle.properties
|
|
echo 'org.gradle.daemon=false' >> $HOME/.gradle/gradle.properties
|
|
- name: Configure Toolchain Properties
|
|
if: ${{ inputs.java-toolchain }}
|
|
shell: bash
|
|
run: |
|
|
echo toolchainVersion=${{ inputs.java-version }} >> $HOME/.gradle/gradle.properties
|
|
echo systemProp.org.gradle.java.installations.auto-detect=false >> $HOME/.gradle/gradle.properties
|
|
echo systemProp.org.gradle.java.installations.auto-download=false >> $HOME/.gradle/gradle.properties
|
|
echo systemProp.org.gradle.java.installations.paths=${{ format('$JAVA_HOME_{0}_X64', inputs.java-version) }} >> $HOME/.gradle/gradle.properties
|
|
- name: Build
|
|
id: build
|
|
if: ${{ !inputs.publish }}
|
|
shell: bash
|
|
env:
|
|
GRADLE_ENTERPRISE_URL: 'https://ge.spring.io'
|
|
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ inputs.gradle-enterprise-secret-access-key }}
|
|
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ inputs.gradle-enterprise-cache-user }}
|
|
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ inputs.gradle-enterprise-cache-password }}
|
|
run: ./gradlew build
|
|
- name: Build and Publish
|
|
id: build-and-publish
|
|
if: ${{ inputs.publish }}
|
|
shell: bash
|
|
env:
|
|
GRADLE_ENTERPRISE_URL: 'https://ge.spring.io'
|
|
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ inputs.gradle-enterprise-secret-access-key }}
|
|
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ inputs.gradle-enterprise-cache-user }}
|
|
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ inputs.gradle-enterprise-cache-password }}
|
|
run: ./gradlew -PdeploymentRepository=$(pwd)/deployment-repository build publishAllPublicationsToDeploymentRepository
|
|
- name: Read Version From gradle.properties
|
|
id: read-version
|
|
shell: bash
|
|
run: |
|
|
version=$(sed -n 's/version=\(.*\)/\1/p' gradle.properties)
|
|
echo "Version is $version"
|
|
echo "version=$version" >> $GITHUB_OUTPUT
|