Skip to content

Commit 27817ac

Browse files
committed
add action to set version in pom.xml
1 parent 4fa74e6 commit 27817ac

6 files changed

Lines changed: 138 additions & 91 deletions

File tree

readme.md

Lines changed: 103 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,95 +4,155 @@ A collection of GitHub actions for Java projects with Maven and Gradle support.
44

55
## Actions
66

7-
### Setup Java
7+
### Setup Java with Maven
88

9-
This action will set up the Java SDK.
9+
This action will set up the Java SDK including Maven.
1010

1111
#### Example:
1212

1313
```yaml
14-
# Maven
1514
- uses: aboutbits/github-actions-java/setup-with-maven@v4
15+
```
16+
17+
#### Inputs
18+
19+
The following inputs can be used as `step.with` keys:
20+
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/Gradle 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+
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
36+
1637

17-
# Gradle
38+
### Setup Java with Gradle
39+
40+
This action will set up the Java SDK including Gradle.
41+
42+
#### Example:
43+
44+
```yaml
1845
- uses: aboutbits/github-actions-java/setup-with-gradle@v4
1946
```
2047

2148
#### Inputs
2249

2350
The following inputs can be used as `step.with` keys:
2451

25-
| Name | Required/Default | Description |
26-
|------------------------|------------------------|-------------------------------------------------------------------------------------------------------|
27-
| `working-directory` | `.` | The working directory |
28-
| `java-version` | `21` | Java Version |
29-
| `distribution` | `corretto` | Java Distribution |
30-
| `cache` | `true` | Enable Maven/Gradle dependency caching. |
31-
| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. (Not applicable when Gradle is used) |
32-
| `cache-encryption-key` | | Optional encryption key for the Gradle configuration cache. (Not applicable when Maven is used) |
52+
| Name | Required/Default | Description |
53+
|------------------------|------------------|-------------------------------------------------------------|
54+
| `working-directory` | `.` | The working directory |
55+
| `java-version` | `21` | Java Version |
56+
| `distribution` | `corretto` | Java Distribution |
57+
| `cache` | `true` | Enable Maven/Gradle dependency caching. |
58+
| `cache-encryption-key` | | Optional encryption key for the Gradle configuration cache. |
3359

3460
#### Outputs
3561

3662
The following outputs are forwarded from the underlying `setup-java` and `cache` actions:
3763

38-
| Name | Description |
39-
|----------------|----------------------------------------------------------------------------------------------------------------|
40-
| `distribution` | Distribution of Java that has been installed. |
41-
| `version` | Actual version of the java environment that has been installed. |
42-
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
43-
| `cache-hit` | A boolean value to indicate an exact match was found for the primary key. (Not applicable when Gradle is used) |
64+
| Name | Description |
65+
|--------|-----------------------------------------------------------------------------|
66+
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
4467

45-
### Setup Java and Install Dependencies
68+
### Setup Java and Install Dependencies with Maven
4669

47-
This action will set up the Java SDK and install all dependencies.
48-
You can choose between the Maven and Gradle build tool.
70+
This action will set up the Java SDK and install all dependencies using Maven.
4971

5072
#### Example:
5173

5274
```yaml
53-
# Maven
5475
- uses: aboutbits/github-actions-java/setup-and-install-with-maven@v4
76+
```
77+
78+
#### Inputs
79+
80+
The following inputs can be used as `step.with` keys:
81+
82+
| Name | Required/Default | Description |
83+
|---------------------|------------------------|------------------------------------------------------------------|
84+
| `working-directory` | `.` | The working directory |
85+
| `java-version` | `21` | Java Version |
86+
| `distribution` | `corretto` | Java Distribution |
87+
| `cache` | `true` | Enable Maven/Gradle dependency caching. |
88+
| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. |
5589

56-
# Gradle
90+
#### Outputs
91+
92+
The following outputs are forwarded from the underlying `setup-java` and `cache` actions:
93+
94+
| Name | Description |
95+
|--------|-----------------------------------------------------------------------------|
96+
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
97+
98+
### Setup Java and Install Dependencies with Gradle
99+
100+
This action will set up the Java SDK and install all dependencies using Gradle.
101+
102+
#### Example:
103+
104+
```yaml
57105
- uses: aboutbits/github-actions-java/setup-and-install-with-gradle@v4
58106
```
59107

60108
#### Inputs
61109

62110
The following inputs can be used as `step.with` keys:
63111

64-
| Name | Required/Default | Description |
65-
|------------------------|------------------------|-------------------------------------------------------------------------------------------------------|
66-
| `working-directory` | `.` | The working directory |
67-
| `java-version` | `21` | Java Version |
68-
| `distribution` | `corretto` | Java Distribution |
69-
| `cache` | `true` | Enable Maven/Gradle dependency caching. |
70-
| `cache-name` | `aboutbits-setup-java` | Cache name. Caches with the same name will share their contents. (Not applicable when Gradle is used) |
71-
| `cache-encryption-key` | | Optional encryption key for the Gradle configuration cache. (Not applicable when Maven is used) |
112+
| Name | Required/Default | Description |
113+
|------------------------|------------------|-------------------------------------------------------------|
114+
| `working-directory` | `.` | The working directory |
115+
| `java-version` | `21` | Java Version |
116+
| `distribution` | `corretto` | Java Distribution |
117+
| `cache` | `true` | Enable Maven/Gradle dependency caching. |
118+
| `cache-encryption-key` | | Optional encryption key for the Gradle configuration cache. |
72119

73120
#### Outputs
74121

75122
The following outputs are forwarded from the underlying `setup-java` and `cache` actions:
76123

77-
| Name | Description |
78-
|----------------|----------------------------------------------------------------------------------------------------------------|
79-
| `distribution` | Distribution of Java that has been installed. |
80-
| `version` | Actual version of the java environment that has been installed. |
81-
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
82-
| `cache-hit` | A boolean value to indicate an exact match was found for the primary key. (Not applicable when Gradle is used) |
124+
| Name | Description |
125+
|---------|-----------------------------------------------------------------------------|
126+
| `path` | Path to where the java environment has been installed (same as $JAVA_HOME). |
127+
128+
### Set Version with Maven
129+
130+
This action will set the given version in a pom.xml file.
131+
132+
#### Example:
133+
134+
```yaml
135+
- uses: aboutbits/github-actions-java/set-version-with-maven@v4
136+
```
137+
138+
#### Inputs
139+
140+
The following inputs can be used as `step.with` keys:
141+
142+
| Name | Required/Default | Description |
143+
|------------------------|------------------|-----------------------|
144+
| `working-directory` | `.` | The working directory |
145+
| `version` | Required | Package version |
83146

84-
## Gradle configuration cache
147+
## Gradle cache configuration
85148

86-
To enable the Gradle configuration cache, which further improves the build performance in addition to the default
87-
enabled wrapper/script/dependency/build cache, create a GitHub secret called `GRADLE_ENCRYPTION_KEY` and pass it to the
88-
`cache-encryption-key` input.
149+
To enable the Gradle configuration cache, which further improves the build performance in addition to the default enabled wrapper/script/dependency/build cache, pass a secret to the `cache-encryption-key` input.
89150
If you do not specify `cache-encryption-key`, Gradle will still work, but the configuration cache will not be saved.
90151
https://github.com/gradle/actions/blob/main/docs/setup-gradle.md#saving-configuration-cache-data
91152

92153
## Versioning
93154

94-
In order to have a versioning in place and working, create lightweight tags that point to the appropriate minor release
95-
versions.
155+
In order to have a versioning in place and working, create lightweight tags that point to the appropriate minor release versions.
96156

97157
Creating a new minor release:
98158

set-version-with-maven/action.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'Set version in pom.xml'
2+
3+
inputs:
4+
working-directory:
5+
description: 'The working directory'
6+
default: '.'
7+
version:
8+
description: 'The version'
9+
required: true
10+
11+
runs:
12+
using: 'composite'
13+
steps:
14+
- name: Install xmlstarlet
15+
run: sudo apt-get install -y xmlstarlet
16+
shell: bash
17+
- name: Set version of pom.xml file
18+
working-directory: ${{ inputs.working-directory }}
19+
run: xmlstarlet ed -P -L -u "/_:project/_:version" -v "${{ inputs.version }}" pom.xml
20+
shell: bash

setup-and-install-with-gradle/action.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,19 @@ inputs:
66
description: 'The working directory'
77
default: '.'
88
java-version:
9-
default: '21'
109
description: 'Java Version'
10+
default: '21'
1111
distribution:
12-
default: 'corretto'
1312
description: 'Java Distribution'
13+
default: 'corretto'
1414
cache:
15-
default: 'true'
1615
description: 'Enable Gradle configuration and dependency caching.'
16+
default: 'true'
1717
cache-encryption-key:
1818
description: 'Optional encryption key for the Gradle configuration cache'
1919
required: false
2020

2121
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 }}
2822
path:
2923
description: 'Path to where the java environment has been installed (same as $JAVA_HOME).'
3024
value: ${{ steps.setup-java.outputs.path }}
@@ -38,14 +32,12 @@ runs:
3832
with:
3933
java-version: ${{ inputs.java-version }}
4034
distribution: ${{ inputs.distribution }}
41-
4235
- name: Setup Gradle
4336
uses: gradle/actions/setup-gradle@v4
4437
with:
4538
cache-disabled: ${{ inputs.cache == 'false' }}
4639
cache-encryption-key: ${{ inputs.cache-encryption-key }}
4740
cache-read-only: 'false'
48-
4941
- name: Update dependencies
5042
working-directory: ${{ inputs.working-directory }}
5143
run: ./gradlew build --dry-run

setup-and-install-with-maven/action.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,19 @@ inputs:
66
description: 'The working directory'
77
default: '.'
88
java-version:
9-
default: '21'
109
description: 'Java Version'
10+
default: '21'
1111
distribution:
12-
default: 'corretto'
1312
description: 'Java Distribution'
13+
default: 'corretto'
1414
cache:
15-
default: 'true'
1615
description: 'Enable Maven dependency caching.'
16+
default: 'true'
1717
cache-name:
18-
default: 'aboutbits-setup-java'
1918
description: 'Cache name. Caches with the same name will share their contents.'
19+
default: 'aboutbits-setup-java'
2020

2121
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 }}
2822
path:
2923
description: 'Path to where the java environment has been installed (same as $JAVA_HOME).'
3024
value: ${{ steps.setup-java.outputs.path }}
@@ -41,7 +35,6 @@ runs:
4135
with:
4236
java-version: ${{ inputs.java-version }}
4337
distribution: ${{ inputs.distribution }}
44-
4538
- name: Cache local Maven repository
4639
uses: actions/cache@v4
4740
id: cache
@@ -51,7 +44,6 @@ runs:
5144
key: ${{ inputs.cache-name }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
5245
restore-keys: |
5346
${{ inputs.cache-name }}-${{ runner.os }}-maven-
54-
5547
- name: Update Maven dependencies
5648
working-directory: ${{ inputs.working-directory }}
5749
run: ./mvnw --batch-mode --fail-fast dependency:resolve dependency:resolve-plugins

setup-with-gradle/action.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,19 @@ inputs:
66
description: 'The working directory'
77
default: '.'
88
java-version:
9-
default: '21'
109
description: 'Java Version'
10+
default: '21'
1111
distribution:
12-
default: 'corretto'
1312
description: 'Java Distribution'
13+
default: 'corretto'
1414
cache:
15-
default: 'true'
1615
description: 'Enable Gradle configuration and dependency caching.'
16+
default: 'true'
1717
cache-encryption-key:
1818
description: 'Optional encryption key for the Gradle configuration cache'
1919
required: false
2020

2121
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 }}
2822
path:
2923
description: 'Path to where the java environment has been installed (same as $JAVA_HOME).'
3024
value: ${{ steps.setup-java.outputs.path }}
@@ -38,7 +32,6 @@ runs:
3832
with:
3933
java-version: ${{ inputs.java-version }}
4034
distribution: ${{ inputs.distribution }}
41-
4235
- name: Setup Gradle
4336
uses: gradle/actions/setup-gradle@v4
4437
with:

setup-with-maven/action.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,22 @@ inputs:
66
description: 'The working directory'
77
default: '.'
88
java-version:
9-
default: '21'
109
description: 'Java Version'
10+
default: '21'
1111
distribution:
12-
default: 'corretto'
1312
description: 'Java Distribution'
13+
default: 'corretto'
1414
cache:
15-
default: 'true'
1615
description: 'Enable Maven dependency caching.'
16+
default: 'true'
1717
cache-name:
18-
default: 'aboutbits-setup-java'
1918
description: 'Cache name. Caches with the same name will share their contents.'
19+
default: 'aboutbits-setup-java'
2020

2121
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 }}
2822
path:
2923
description: 'Path to where the java environment has been installed (same as $JAVA_HOME).'
3024
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 }}
3425

3526
runs:
3627
using: "composite"
@@ -41,7 +32,6 @@ runs:
4132
with:
4233
java-version: ${{ inputs.java-version }}
4334
distribution: ${{ inputs.distribution }}
44-
4535
- name: Cache local Maven repository
4636
uses: actions/cache@v4
4737
id: cache
@@ -50,4 +40,4 @@ runs:
5040
path: ~/.m2/repository
5141
key: ${{ inputs.cache-name }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
5242
restore-keys: |
53-
${{ inputs.cache-name }}-${{ runner.os }}-maven-
43+
${{ inputs.cache-name }}-${{ runner.os }}-maven

0 commit comments

Comments
 (0)