Skip to content

Commit c19ed14

Browse files
authored
Merge pull request #5 from aboutbits/configurable-cache
add more control over caching and forward outputs
2 parents aa57fde + 985f84e commit c19ed14

3 files changed

Lines changed: 108 additions & 21 deletions

File tree

readme.md

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,31 @@ This action will set up the Java SDK.
1111
#### Example:
1212

1313
```yaml
14-
- uses: aboutbits/github-actions-java/setup@v2
14+
- uses: aboutbits/github-actions-java/setup@v3
1515
```
1616
1717
#### Inputs
1818
1919
The following inputs can be used as `step.with` keys:
2020

21-
| Name | Required/Default | Description |
22-
|------------------------|------------------|---------------------------|
23-
| `working-directory` | `.` | The working directory |
24-
| `java-version` | `21` | Java Version |
25-
| `distribution` | `corretto` | Java Distribution |
21+
| Name | Required/Default | Description |
22+
|---------------------|------------------------|------------------------------------------------------------------|
23+
| `working-directory` | `.` | The working directory |
24+
| `java-version` | `21` | Java Version |
25+
| `distribution` | `corretto` | Java Distribution |
26+
| `cache` | `true` | Enable Maven dependency caching. |
27+
| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. |
28+
29+
#### Outputs
30+
31+
The following outputs are forwarded from the underlying `setup-java` and `cache` actions:
32+
33+
| Name | Description |
34+
|----------------|-----------------------------------------------------------------------------|
35+
| `distribution` | Distribution of Java that has been installed. |
36+
| `version` | Actual version of the java environment that has been installed. |
37+
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
38+
| `cache-hit` | A boolean value to indicate an exact match was found for the primary key. |
2639

2740
### Setup Java and Install Dependencies
2841

@@ -31,43 +44,57 @@ This action will set up the Java SDK and install all dependencies.
3144
#### Example:
3245

3346
```yaml
34-
- uses: aboutbits/github-actions-java/setup-and-install@v2
47+
- uses: aboutbits/github-actions-java/setup-and-install@v3
3548
```
3649

3750
#### Inputs
3851

3952
The following inputs can be used as `step.with` keys:
4053

41-
| Name | Required/Default | Description |
42-
|------------------------|------------------|---------------------------|
43-
| `working-directory` | `.` | The working directory |
44-
| `java-version` | `21` | Java Version |
45-
| `distribution` | `corretto` | Java Distribution |
54+
| Name | Required/Default | Description |
55+
|---------------------|------------------------|------------------------------------------------------------------|
56+
| `working-directory` | `.` | The working directory |
57+
| `java-version` | `21` | Java Version |
58+
| `distribution` | `corretto` | Java Distribution |
59+
| `cache` | `true` | Enable Maven dependency caching. |
60+
| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. |
61+
62+
#### Outputs
63+
64+
The following outputs are forwarded from the underlying `setup-java` and `cache` actions:
4665

66+
| Name | Description |
67+
|----------------|-----------------------------------------------------------------------------|
68+
| `distribution` | Distribution of Java that has been installed. |
69+
| `version` | Actual version of the java environment that has been installed. |
70+
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
71+
| `cache-hit` | A boolean value to indicate an exact match was found for the primary key. |
4772

4873
## Versioning
4974

50-
In order to have a versioning in place and working, create lightweight tags that point to the appropriate minor release versions.
75+
In order to have a versioning in place and working, create lightweight tags that point to the appropriate minor release
76+
versions.
5177

5278
Creating a new minor release:
5379

5480
```bash
55-
git tag v2
81+
git tag v3
5682
git push --tags
5783
```
5884

5985
Replacing an already existing minor release:
6086

6187
```bash
62-
git tag -d v2
63-
git push origin :refs/tags/v2
64-
git tag v2
88+
git tag -d v3
89+
git push origin :refs/tags/v3
90+
git tag v3
6591
git push --tags
6692
```
6793

6894
## Information
6995

70-
About Bits is a company based in South Tyrol, Italy. You can find more information about us on [our website](https://aboutbits.it).
96+
About Bits is a company based in South Tyrol, Italy. You can find more information about us
97+
on [our website](https://aboutbits.it).
7198

7299
### Support
73100

setup-and-install/action.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,48 @@ inputs:
1111
distribution:
1212
default: 'corretto'
1313
description: 'Java Distribution'
14+
cache:
15+
default: 'true'
16+
description: 'Enable Maven dependency caching.'
17+
cache-name:
18+
default: 'aboutbits-setup-java'
19+
description: 'Cache name. Caches with the same name will share their contents.'
20+
21+
outputs:
22+
distribution:
23+
description: 'Distribution of Java that has been installed.'
24+
value: ${{ steps.setup-java.outputs.distribution }}
25+
version:
26+
description: 'Actual version of the java environment that has been installed.'
27+
value: ${{ steps.setup-java.outputs.version }}
28+
path:
29+
description: 'Path to where the java environment has been installed (same as $JAVA_HOME).'
30+
value: ${{ steps.setup-java.outputs.path }}
31+
cache-hit:
32+
description: 'A boolean value to indicate an exact match was found for the primary key.'
33+
value: ${{ steps.cache.outputs.cache-hit }}
1434

1535
runs:
1636
using: "composite"
1737
steps:
1838
- name: Set up JDK
1939
uses: actions/setup-java@v4
40+
id: setup-java
2041
with:
2142
java-version: ${{ inputs.java-version }}
2243
distribution: ${{ inputs.distribution }}
23-
cache: 'maven'
44+
45+
- name: Cache local Maven repository
46+
uses: actions/cache@v4
47+
id: cache
48+
if: ${{ inputs.cache == 'true' }}
49+
with:
50+
path: ~/.m2/repository
51+
key: ${{ inputs.cache-name }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
52+
restore-keys: |
53+
${{ inputs.cache-name }}-${{ runner.os }}-maven-
2454
2555
- name: Update maven dependencies
2656
working-directory: ${{ inputs.working-directory }}
27-
run: ./mvnw --batch-mode --fail-fast dependency:resolve
57+
run: ./mvnw --batch-mode --fail-fast dependency:resolve dependency:resolve-plugins
2858
shell: bash

setup/action.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,43 @@ inputs:
1111
distribution:
1212
default: 'corretto'
1313
description: 'Java Distribution'
14+
cache:
15+
default: 'true'
16+
description: 'Enable Maven dependency caching.'
17+
cache-name:
18+
default: 'aboutbits-setup-java'
19+
description: 'Cache name. Caches with the same name will share their contents.'
20+
21+
outputs:
22+
distribution:
23+
description: 'Distribution of Java that has been installed.'
24+
value: ${{ steps.setup-java.outputs.distribution }}
25+
version:
26+
description: 'Actual version of the java environment that has been installed.'
27+
value: ${{ steps.setup-java.outputs.version }}
28+
path:
29+
description: 'Path to where the java environment has been installed (same as $JAVA_HOME).'
30+
value: ${{ steps.setup-java.outputs.path }}
31+
cache-hit:
32+
description: 'A boolean value to indicate an exact match was found for the primary key.'
33+
value: ${{ steps.cache.outputs.cache-hit }}
1434

1535
runs:
1636
using: "composite"
1737
steps:
1838
- name: Set up JDK
1939
uses: actions/setup-java@v4
40+
id: setup-java
2041
with:
2142
java-version: ${{ inputs.java-version }}
2243
distribution: ${{ inputs.distribution }}
23-
cache: 'maven'
44+
45+
- name: Cache local Maven repository
46+
uses: actions/cache@v4
47+
id: cache
48+
if: ${{ inputs.cache == 'true' }}
49+
with:
50+
path: ~/.m2/repository
51+
key: ${{ inputs.cache-name }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
52+
restore-keys: |
53+
${{ inputs.cache-name }}-${{ runner.os }}-maven-

0 commit comments

Comments
 (0)