Merge pull request #19 from OpenLiberty/dependabot/github_actions/act… #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Java CI with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
strategy: | |
matrix: | |
# TODO add 22-ea | |
java-version: [ '17', '18', '19', '20', '21' ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
# Strip -ea off of java-version for build-time use | |
- name: Strip java-version postfix | |
id: strip | |
env: | |
JAVA_VERSION: ${{ matrix.java-version }} | |
run: | | |
echo "java-version=${JAVA_VERSION%-ea}" >> $GITHUB_OUTPUT | |
# Gradle 8.X no longer uses a default repository for toolchains. | |
# Ref: https://docs.gradle.org/current/userguide/upgrading_version_7.html#using_automatic_toolchain_downloading_without_having_a_repository_configured | |
# Always preload toolchain JDK | |
- name: Preload JDK ${{ matrix.java-version }} | |
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 | |
with: | |
java-version: ${{ matrix.java-version }} | |
distribution: 'temurin' | |
# This is the JDK gradle will use since gradle does not always support the -ea version | |
- name: Set up JDK 11 | |
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Toolchain debug | |
run: | | |
./gradlew -q javaToolchains | |
- name: Build application | |
run: | | |
./gradlew io.openliberty.java.internal_fat_${{ steps.strip.outputs.java-version }}:build | |
- name: Verify application | |
run: | | |
./.github/workflows/scripts/verifyArtifact.sh ${{ steps.strip.outputs.java-version }} | |
- name: Repackage application | |
run: | | |
./.github/workflows/scripts/repackageApplication.sh io.openliberty.java.internal_fat_${{ steps.strip.outputs.java-version }}/build/libs/io.openliberty.java.internal_fat_${{ steps.strip.outputs.java-version }}.war .jar | |
- name: Upload application | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: actions/upload-artifact@3a8048248f2f288c271830f8ecf2a1c5d8eb0e9a #v3.1.2 | |
with: | |
name: Applications | |
path: io.openliberty.java.internal_fat_${{ steps.strip.outputs.java-version }}/build/libs/io.openliberty.java.internal_fat_${{ steps.strip.outputs.java-version }}.jar | |
if-no-files-found: error |