Skip to content

Commit d15ad6a

Browse files
bigdazskedwards88
andauthored
Update for gradle/actions@v3.1.0 (github#31624)
Co-authored-by: Sarah Edwards <skedwards88@github.com>
1 parent e8f0efe commit d15ad6a

File tree

3 files changed

+42
-39
lines changed

3 files changed

+42
-39
lines changed

content/actions/automating-builds-and-tests/building-and-testing-java-with-gradle.md

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,24 @@ We recommend that you have a basic understanding of Java and the Gradle framewor
6565
jobs:
6666
build:
6767
runs-on: ubuntu-latest
68-
6968
steps:
7069
- uses: {% data reusables.actions.action-checkout %}
71-
- name: Set up JDK 11
70+
- name: Set up JDK 17
7271
uses: {% data reusables.actions.action-setup-java %}
7372
with:
74-
java-version: '11'
73+
java-version: '17'
7574
distribution: 'temurin'
75+
76+
- name: Setup Gradle
77+
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
78+
7679
- name: Build with Gradle
77-
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
78-
with:
79-
arguments: build
80+
run: ./gradlew build
8081
```
8182
8283
{%- endif %}
84+
{% data reusables.actions.gradle-workflow-steps %}
85+
1. The "Build with Gradle" step executes the `build` task using the [Gradle Wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html).
8386

8487
1. Edit the workflow as required. For example, change the Java version.
8588

@@ -108,21 +111,21 @@ steps:
108111
with:
109112
java-version: '17'
110113
distribution: 'temurin'
111-
- name: Validate Gradle wrapper
112-
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
113-
- name: Run the Gradle package task
114-
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
115-
with:
116-
arguments: -b ci.gradle package
114+
115+
- name: Setup Gradle
116+
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
117+
118+
- name: Build with Gradle
119+
run: ./gradlew -b ci.gradle package
117120
```
118121

119122
{% ifversion actions-caching %}
120123

121124
## Caching dependencies
122125

123-
Your build dependencies can be cached to speed up your workflow runs. After a successful run, the `gradle/gradle-build-action` caches important parts of the Gradle user home directory. In future jobs, the cache will be restored so that build scripts won't need to be recompiled and dependencies won't need to be downloaded from remote package repositories.
126+
Your build dependencies can be cached to speed up your workflow runs. After a successful run, `gradle/actions/setup-gradle` caches important parts of the Gradle user home directory. In future jobs, the cache will be restored so that build scripts won't need to be recompiled and dependencies won't need to be downloaded from remote package repositories.
124127

125-
Caching is enabled by default when using the `gradle/gradle-build-action` action. For more information, see [`gradle/gradle-build-action`](https://github.com/gradle/gradle-build-action#caching).
128+
Caching is enabled by default when using the `gradle/actions/setup-gradle` action. For more information, see [`gradle/actions/setup-gradle`](https://github.com/gradle/actions/blob/main/setup-gradle/README.md#caching-build-state-between-jobs).
126129

127130
{% endif %}
128131

@@ -139,13 +142,15 @@ steps:
139142
with:
140143
java-version: '17'
141144
distribution: 'temurin'
142-
- name: Validate Gradle wrapper
143-
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
145+
146+
- name: Setup Gradle
147+
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
148+
144149
- name: Build with Gradle
145-
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
146-
with:
147-
arguments: build
148-
- uses: {% data reusables.actions.action-upload-artifact %}
150+
run: ./gradlew build
151+
152+
- name: Upload build artifacts
153+
uses: {% data reusables.actions.action-upload-artifact %}
149154
with:
150155
name: Package
151156
path: build/libs

content/actions/publishing-packages/publishing-java-packages-with-gradle.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ jobs:
9696
with:
9797
java-version: '11'
9898
distribution: 'temurin'
99-
- name: Validate Gradle wrapper
100-
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
99+
100+
- name: Setup Gradle
101+
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
102+
101103
- name: Publish package
102-
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
103-
with:
104-
arguments: publish
104+
run: ./gradlew publish
105105
env:
106106
MAVEN_USERNAME: {% raw %}${{ secrets.OSSRH_USERNAME }}{% endraw %}
107107
MAVEN_PASSWORD: {% raw %}${{ secrets.OSSRH_TOKEN }}{% endraw %}
108108
```
109109
110110
{% data reusables.actions.gradle-workflow-steps %}
111-
1. Runs the [`gradle/gradle-build-action`](https://github.com/gradle/gradle-build-action) action with the `publish` argument to publish to the `OSSRH` Maven repository. The `MAVEN_USERNAME` environment variable will be set with the contents of your `OSSRH_USERNAME` secret, and the `MAVEN_PASSWORD` environment variable will be set with the contents of your `OSSRH_TOKEN` secret.
111+
1. Executes the Gradle `publish` task to publish to the `OSSRH` Maven repository. The `MAVEN_USERNAME` environment variable will be set with the contents of your `OSSRH_USERNAME` secret, and the `MAVEN_PASSWORD` environment variable will be set with the contents of your `OSSRH_TOKEN` secret.
112112

113113
For more information about using secrets in your workflow, see "[AUTOTITLE](/actions/security-guides/using-secrets-in-github-actions)."
114114

@@ -172,18 +172,17 @@ jobs:
172172
with:
173173
java-version: '11'
174174
distribution: 'temurin'
175-
- name: Validate Gradle wrapper
176-
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
175+
- name: Setup Gradle
176+
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
177+
177178
- name: Publish package
178-
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
179-
with:
180-
arguments: publish
179+
run: ./gradlew publish
181180
env:
182181
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
183182
```
184183

185184
{% data reusables.actions.gradle-workflow-steps %}
186-
1. Runs the [`gradle/gradle-build-action`](https://github.com/gradle/gradle-build-action) action with the `publish` argument to publish to {% data variables.product.prodname_registry %}. The `GITHUB_TOKEN` environment variable will be set with the content of the `GITHUB_TOKEN` secret. The `permissions` key specifies the access that the `GITHUB_TOKEN` secret will allow.
185+
1. Executes the Gradle `publish` task to publish to {% data variables.product.prodname_registry %}. The `GITHUB_TOKEN` environment variable will be set with the content of the `GITHUB_TOKEN` secret. The `permissions` key specifies the access that the `GITHUB_TOKEN` secret will allow.
187186

188187
For more information about using secrets in your workflow, see "[AUTOTITLE](/actions/security-guides/using-secrets-in-github-actions)."
189188

@@ -256,19 +255,18 @@ jobs:
256255
with:
257256
java-version: '11'
258257
distribution: 'temurin'
259-
- name: Validate Gradle wrapper
260-
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
258+
- name: Setup Gradle
259+
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
260+
261261
- name: Publish package
262-
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
263-
with:
264-
arguments: publish
262+
run: ./gradlew publish
265263
env: {% raw %}
266264
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
267265
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
268266
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}{% endraw %}
269267
```
270268

271269
{% data reusables.actions.gradle-workflow-steps %}
272-
1. Runs the [`gradle/gradle-build-action`](https://github.com/gradle/gradle-build-action) action with the `publish` argument to publish to the `OSSRH` Maven repository and {% data variables.product.prodname_registry %}. The `MAVEN_USERNAME` environment variable will be set with the contents of your `OSSRH_USERNAME` secret, and the `MAVEN_PASSWORD` environment variable will be set with the contents of your `OSSRH_TOKEN` secret. The `GITHUB_TOKEN` environment variable will be set with the content of the `GITHUB_TOKEN` secret. The `permissions` key specifies the access that the `GITHUB_TOKEN` secret will allow.
270+
1. Executes the Gradle `publish` task to publish to the `OSSRH` Maven repository and {% data variables.product.prodname_registry %}. The `MAVEN_USERNAME` environment variable will be set with the contents of your `OSSRH_USERNAME` secret, and the `MAVEN_PASSWORD` environment variable will be set with the contents of your `OSSRH_TOKEN` secret. The `GITHUB_TOKEN` environment variable will be set with the content of the `GITHUB_TOKEN` secret. The `permissions` key specifies the access that the `GITHUB_TOKEN` secret will allow.
273271

274272
For more information about using secrets in your workflow, see "[AUTOTITLE](/actions/security-guides/using-secrets-in-github-actions)."

data/reusables/actions/gradle-workflow-steps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ This workflow performs the following steps:
22

33
1. Checks out a copy of project's repository.
44
1. Sets up the Java JDK.
5-
1. Validates the checksums of any Gradle Wrapper JAR files present in the repository.
5+
1. Sets up the Gradle environment. The [`gradle/actions/setup-gradle`](https://github.com/gradle/actions) action takes care of caching state between workflow runs, and provides a detailed summary of all Gradle executions.

0 commit comments

Comments
 (0)