|
| 1 | +name: 'Build' |
| 2 | +inputs: |
| 3 | + java-version: |
| 4 | + required: false |
| 5 | + type: string |
| 6 | + default: '17' |
| 7 | + description: 'The Java version to compile and test with' |
| 8 | + java-toolchain: |
| 9 | + required: false |
| 10 | + type: boolean |
| 11 | + default: false |
| 12 | + description: 'Whether a Java toolchain should be used' |
| 13 | + publish: |
| 14 | + required: false |
| 15 | + type: boolean |
| 16 | + default: false |
| 17 | + description: 'Whether to publish artifacts ready for deployment to Artifactory' |
| 18 | + gradle-enterprise-secret-access-key: |
| 19 | + required: false |
| 20 | + type: string |
| 21 | + description: 'The secret access key for authentication with ge.spring.io' |
| 22 | + gradle-enterprise-cache-user: |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + description: 'The username for authentication with the remote build cache' |
| 26 | + gradle-enterprise-cache-password: |
| 27 | + required: false |
| 28 | + type: string |
| 29 | + description: 'The password for authentication with the remote build cache' |
| 30 | +outputs: |
| 31 | + build-scan-url: |
| 32 | + value: ${{ steps.build.outputs.build-scan-url }} |
| 33 | + version: |
| 34 | + value: ${{ steps.read-version.outputs.version }} |
| 35 | +runs: |
| 36 | + using: composite |
| 37 | + steps: |
| 38 | + - name: Set Up Java |
| 39 | + uses: actions/setup-java@v4 |
| 40 | + with: |
| 41 | + distribution: 'liberica' |
| 42 | + java-version: | |
| 43 | + ${{ inputs.java-version }} |
| 44 | + ${{ inputs.java-toolchain && '17' || '' }} |
| 45 | + - name: Set Up Gradle |
| 46 | + uses: gradle/actions/setup-gradle@1168cd3d07c1876a65e1724114de42ccbdfa7b78 # v3.2.1 |
| 47 | + with: |
| 48 | + cache-read-only: false |
| 49 | + - name: Configure Gradle Properties |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + mkdir -p $HOME/.gradle |
| 53 | + echo 'systemProp.user.name=spring-builds+github' >> $HOME/.gradle/gradle.properties |
| 54 | + echo 'systemProp.org.gradle.internal.launcher.welcomeMessageEnabled=false' >> $HOME/.gradle/gradle.properties |
| 55 | + echo 'org.gradle.daemon=false' >> $HOME/.gradle/gradle.properties |
| 56 | + - name: Configure Toolchain Properties |
| 57 | + if: ${{ inputs.java-toolchain }} |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + echo toolchainVersion=${{ inputs.java-version }} >> $HOME/.gradle/gradle.properties |
| 61 | + echo systemProp.org.gradle.java.installations.auto-detect=false >> $HOME/.gradle/gradle.properties |
| 62 | + echo systemProp.org.gradle.java.installations.auto-download=false >> $HOME/.gradle/gradle.properties |
| 63 | + echo systemProp.org.gradle.java.installations.paths=${{ format('$JAVA_HOME_{0}_X64', inputs.java-version) }} >> $HOME/.gradle/gradle.properties |
| 64 | + - name: Build |
| 65 | + if: ${{ !inputs.publish }} |
| 66 | + env: |
| 67 | + GRADLE_ENTERPRISE_URL: 'https://ge.spring.io' |
| 68 | + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ inputs.gradle-enterprise-secret-access-key }} |
| 69 | + GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ inputs.gradle-enterprise-cache-user }} |
| 70 | + GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ inputs.gradle-enterprise-cache-password }} |
| 71 | + run: ./gradlew build |
| 72 | + - name: Build and Publish |
| 73 | + if: ${{ inputs.publish }} |
| 74 | + env: |
| 75 | + GRADLE_ENTERPRISE_URL: 'https://ge.spring.io' |
| 76 | + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ inputs.gradle-enterprise-secret-access-key }} |
| 77 | + GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ inputs.gradle-enterprise-cache-user }} |
| 78 | + GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ inputs.gradle-enterprise-cache-password }} |
| 79 | + run: ./gradlew -PdeploymentRepository=$(pwd)/deployment-repository build publishAllPublicationsToDeploymentRepository |
| 80 | + - name: Read Version From gradle.properties |
| 81 | + id: read-version |
| 82 | + shell: bash |
| 83 | + run: | |
| 84 | + version=$(sed -n 's/version=\(.*\)/\1/p' gradle.properties) |
| 85 | + echo "Version is $version" |
| 86 | + echo "version=$version" >> $GITHUB_OUTPUT |
0 commit comments