diff --git a/readme.md b/readme.md index 504d377..ff3e9f1 100644 --- a/readme.md +++ b/readme.md @@ -11,18 +11,31 @@ This action will set up the Java SDK. #### Example: ```yaml - - uses: aboutbits/github-actions-java/setup@v2 + - uses: aboutbits/github-actions-java/setup@v3 ``` #### Inputs The following inputs can be used as `step.with` keys: -| Name | Required/Default | Description | -|------------------------|------------------|---------------------------| -| `working-directory` | `.` | The working directory | -| `java-version` | `21` | Java Version | -| `distribution` | `corretto` | Java Distribution | +| Name | Required/Default | Description | +|---------------------|------------------------|------------------------------------------------------------------| +| `working-directory` | `.` | The working directory | +| `java-version` | `21` | Java Version | +| `distribution` | `corretto` | Java Distribution | +| `cache` | `true` | Enable Maven dependency caching. | +| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. | + +#### Outputs + +The following outputs are forwarded from the underlying `setup-java` and `cache` actions: + +| Name | Description | +|----------------|-----------------------------------------------------------------------------| +| `distribution` | Distribution of Java that has been installed. | +| `version` | Actual version of the java environment that has been installed. | +| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). | +| `cache-hit` | A boolean value to indicate an exact match was found for the primary key. | ### Setup Java and Install Dependencies @@ -31,43 +44,57 @@ This action will set up the Java SDK and install all dependencies. #### Example: ```yaml - - uses: aboutbits/github-actions-java/setup-and-install@v2 + - uses: aboutbits/github-actions-java/setup-and-install@v3 ``` #### Inputs The following inputs can be used as `step.with` keys: -| Name | Required/Default | Description | -|------------------------|------------------|---------------------------| -| `working-directory` | `.` | The working directory | -| `java-version` | `21` | Java Version | -| `distribution` | `corretto` | Java Distribution | +| Name | Required/Default | Description | +|---------------------|------------------------|------------------------------------------------------------------| +| `working-directory` | `.` | The working directory | +| `java-version` | `21` | Java Version | +| `distribution` | `corretto` | Java Distribution | +| `cache` | `true` | Enable Maven dependency caching. | +| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. | + +#### Outputs + +The following outputs are forwarded from the underlying `setup-java` and `cache` actions: +| Name | Description | +|----------------|-----------------------------------------------------------------------------| +| `distribution` | Distribution of Java that has been installed. | +| `version` | Actual version of the java environment that has been installed. | +| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). | +| `cache-hit` | A boolean value to indicate an exact match was found for the primary key. | ## Versioning -In order to have a versioning in place and working, create lightweight tags that point to the appropriate minor release versions. +In order to have a versioning in place and working, create lightweight tags that point to the appropriate minor release +versions. Creating a new minor release: ```bash -git tag v2 +git tag v3 git push --tags ``` Replacing an already existing minor release: ```bash -git tag -d v2 -git push origin :refs/tags/v2 -git tag v2 +git tag -d v3 +git push origin :refs/tags/v3 +git tag v3 git push --tags ``` ## Information -About Bits is a company based in South Tyrol, Italy. You can find more information about us on [our website](https://aboutbits.it). +About Bits is a company based in South Tyrol, Italy. You can find more information about us +on [our website](https://aboutbits.it). ### Support diff --git a/setup-and-install/action.yml b/setup-and-install/action.yml index c4c5bd8..577ace3 100644 --- a/setup-and-install/action.yml +++ b/setup-and-install/action.yml @@ -11,18 +11,48 @@ inputs: distribution: default: 'corretto' description: 'Java Distribution' + cache: + default: 'true' + description: 'Enable Maven dependency caching.' + cache-name: + default: 'aboutbits-setup-java' + description: 'Cache name. Caches with the same name will share their contents.' + +outputs: + distribution: + description: 'Distribution of Java that has been installed.' + value: ${{ steps.setup-java.outputs.distribution }} + version: + description: 'Actual version of the java environment that has been installed.' + value: ${{ steps.setup-java.outputs.version }} + path: + description: 'Path to where the java environment has been installed (same as $JAVA_HOME).' + value: ${{ steps.setup-java.outputs.path }} + cache-hit: + description: 'A boolean value to indicate an exact match was found for the primary key.' + value: ${{ steps.cache.outputs.cache-hit }} runs: using: "composite" steps: - name: Set up JDK uses: actions/setup-java@v4 + id: setup-java with: java-version: ${{ inputs.java-version }} distribution: ${{ inputs.distribution }} - cache: 'maven' + + - name: Cache local Maven repository + uses: actions/cache@v4 + id: cache + if: ${{ inputs.cache == 'true' }} + with: + path: ~/.m2/repository + key: ${{ inputs.cache-name }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ inputs.cache-name }}-${{ runner.os }}-maven- - name: Update maven dependencies working-directory: ${{ inputs.working-directory }} - run: ./mvnw --batch-mode --fail-fast dependency:resolve + run: ./mvnw --batch-mode --fail-fast dependency:resolve dependency:resolve-plugins shell: bash diff --git a/setup/action.yml b/setup/action.yml index 76c6514..3e4c419 100644 --- a/setup/action.yml +++ b/setup/action.yml @@ -11,13 +11,43 @@ inputs: distribution: default: 'corretto' description: 'Java Distribution' + cache: + default: 'true' + description: 'Enable Maven dependency caching.' + cache-name: + default: 'aboutbits-setup-java' + description: 'Cache name. Caches with the same name will share their contents.' + +outputs: + distribution: + description: 'Distribution of Java that has been installed.' + value: ${{ steps.setup-java.outputs.distribution }} + version: + description: 'Actual version of the java environment that has been installed.' + value: ${{ steps.setup-java.outputs.version }} + path: + description: 'Path to where the java environment has been installed (same as $JAVA_HOME).' + value: ${{ steps.setup-java.outputs.path }} + cache-hit: + description: 'A boolean value to indicate an exact match was found for the primary key.' + value: ${{ steps.cache.outputs.cache-hit }} runs: using: "composite" steps: - name: Set up JDK uses: actions/setup-java@v4 + id: setup-java with: java-version: ${{ inputs.java-version }} distribution: ${{ inputs.distribution }} - cache: 'maven' + + - name: Cache local Maven repository + uses: actions/cache@v4 + id: cache + if: ${{ inputs.cache == 'true' }} + with: + path: ~/.m2/repository + key: ${{ inputs.cache-name }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ inputs.cache-name }}-${{ runner.os }}-maven-