-
Notifications
You must be signed in to change notification settings - Fork 4
/
action.yml
241 lines (239 loc) · 9.83 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: Build and delivery a Gradle project
description: Build and delivery a Gradle project
branding:
icon: 'box'
color: 'green'
inputs:
pre-build-command:
description: 'A command to be executed before the build phase (but after configuring the JVM)'
default: 'true'
required: false
build-command:
description: 'The command executed in the build phase'
default: './gradlew assemble --parallel || ./gradlew assemble --parallel'
required: false
check-command:
description: 'The command executed in the check phase'
default: './gradlew check --parallel || ./gradlew check --parallel'
required: false
clean-command:
description: 'The command executed in the final clean phase'
default: 'true'
required: false
codecov-directory:
description: 'The location where CodeCov searches for coverage information'
default: build
required: false
deploy-command:
description: 'The condition triggering a deploy run'
default: "./gradlew publish --parallel"
required: false
gradle-termination-command:
description: 'The command to terminate the gradle wrapper gracefully'
default: "./gradlew --stop"
required: false
java-distribution:
description: 'The Java distrbutor to use'
default: "temurin"
required: false
java-version:
description: 'The Java version to use'
default: "17"
required: false
should-run-codecov:
description: 'True if the action should send coverage results to codecov.io'
default: true
required: false
should-deploy:
description: 'True if the deploy operation should be executed'
default: false
required: false
should-validate-wrapper:
description: 'True if the wrapper should get validated before proceeding'
default: true
required: false
maven-central-username:
description: 'Username for Maven Central that will be exposed in the deployment step as the environment variables MAVEN_CENTRAL_PASSWORD and ORG_GRADLE_PROJECT_mavenUsername'
default: 'danysk'
required: false
working-directory:
description: 'Location where the repository should will be cloned'
default: '.'
required: false
custom-secret-0:
description: 'A custom secret that will be exposed in the deployment step as the environment variable CUSTOM_SECRET_0'
default: ''
required: false
custom-secret-1:
description: 'A custom secret that will be exposed in the deployment step as the environment variable CUSTOM_SECRET_1'
default: ''
required: false
custom-secret-2:
description: 'A custom secret that will be exposed in the deployment step as the environment variable CUSTOM_SECRET_2'
default: ''
required: false
custom-secret-3:
description: 'A custom secret that will be exposed in the deployment step as the environment variable CUSTOM_SECRET_3'
default: ''
required: false
custom-secret-4:
description: 'A custom secret that will be exposed in the deployment step as the environment variable CUSTOM_SECRET_4'
default: ''
required: false
github-token:
description: 'The GitHub token, it will be exposed in the deployment step as the environment variable GITHUB_TOKEN'
required: false
gradle-publish-secret:
description: 'The Gradle Plugin Portal publish secret, it will be exposed in the deployment step as the environment variable GRADLE_PUBLISH_SECRET'
required: false
gradle-publish-key:
description: 'The Gradle Plugin Portal publish key, it will be exposed in the deployment step as the environment variable GRADLE_PUBLISH_KEY'
required: false
maven-central-password:
description: 'Password for OSSRH / Maven Central, it will be exposed in the deployment step as the environment variables MAVEN_CENTRAL_PASSWORD and ORG_GRADLE_PROJECT_mavenPassword'
required: false
maven-central-repo:
description: 'URL for OSSRH / Maven Central Repository, it will be exposed in the deployment step as the environment variables MAVEN_CENTRAL_REPO and ORG_GRADLE_PROJECT_mavenRepo'
required: false
default: 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
signing-key:
description: 'ASCII-armored signing key, it will be exposed in the deployment step as the environment variable ORG_GRADLE_PROJECT_signingKey'
required: false
signing-password:
description: 'Password for the signing key, it will be exposed in the deployment step as the environment variables ORG_GRADLE_PROJECT_signingPassword and SIGNING_PASSWORD'
required: false
npm-repo:
description: 'URL for the NPM registry of choice, it will be exposed in the deployment step as the environment variable ORG_GRADLE_PROJECT_npmRepo'
required: false
default: 'https://registry.npmjs.org'
npm-token:
description: 'Authorization token for the NPM registry of choice, it will be exposed in the deployment step as the environment variable ORG_GRADLE_PROJECT_npmToken'
required: false
runs:
using: composite
steps:
- name: Validate the Gradle Wrapper
if: inputs.should-validate-wrapper == 'true'
uses: gradle/wrapper-validation-action@v1.1.0
- name: Setup Java
uses: actions/setup-java@v4.0.0
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
# Apache Maven Configuration
server-id: ossrh
server-username: MAVEN_CENTRAL_USERNAME
server-password: MAVEN_CENTRAL_PASSWORD
gpg-private-key: ${{ inputs.signing-key }}
gpg-passphrase: SIGNING_PASSWORD
- name: Configure the Windows Pagefile
if: ${{ runner.os == 'Windows' }}
uses: al-cheb/configure-pagefile-action@v1.3
with:
disk-root: 'C:'
- name: Cache Gradle packages
uses: actions/cache@v4.0.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.gradle/jdks
~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Pre-build
working-directory: ${{ inputs.working-directory }}
shell: bash
run: |
echo "::group::Pre-build"
${{ inputs.pre-build-command }}
echo "::endgroup::"
- name: Build
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
echo "::group::Build"
${{ inputs.build-command }}
echo "::endgroup::"
- name: Check
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
echo "::group::Check"
${{ inputs.check-command }}
echo "::endgroup::"
- name: CodeCov
if: inputs.should-run-codecov == 'true'
uses: codecov/codecov-action@v3.1.4
with:
directory: ${{ inputs.codecov-directory }}
- name: Deploy
if: inputs.should-deploy == 'true'
working-directory: ${{ inputs.working-directory }}
shell: bash
env:
CUSTOM_SECRET_0: ${{ inputs.custom-secret-0 }}
CUSTOM_SECRET_1: ${{ inputs.custom-secret-1 }}
CUSTOM_SECRET_2: ${{ inputs.custom-secret-2 }}
CUSTOM_SECRET_3: ${{ inputs.custom-secret-3 }}
CUSTOM_SECRET_4: ${{ inputs.custom-secret-4 }}
GITHUB_TOKEN: ${{ inputs.github-token }}
GRADLE_PUBLISH_SECRET: ${{ inputs.gradle-publish-secret }}
GRADLE_PUBLISH_KEY: ${{ inputs.gradle-publish-key }}
MAVEN_CENTRAL_PASSWORD: ${{ inputs.maven-central-password }}
MAVEN_CENTRAL_USERNAME: ${{ inputs.maven-central-username }}
SIGNING_PASSWORD: ${{ inputs.signing-password }}
NPM_REPO: ${{ inputs.npm-repo }}
NPM_TOKEN: ${{ inputs.npm-token }}
# Gradle-specific exports, see:
# https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties
ORG_GRADLE_PROJECT_mavenCentralRepo: ${{ inputs.maven-central-repo }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ inputs.maven-central-username }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ inputs.maven-central-password }}
ORG_GRADLE_PROJECT_signingKey: ${{ inputs.signing-key }}
ORG_GRADLE_PROJECT_signingPassword: ${{ inputs.signing-password }}
ORG_GRADLE_PROJECT_npmRepo: ${{ inputs.npm-repo }}
ORG_GRADLE_PROJECT_npmToken: ${{ inputs.npm-token }}
run: |
echo "::group::Deploy"
${{ inputs.deploy-command }}
echo "::endgroup::"
- name: Cleanup
working-directory: ${{ inputs.working-directory }}
shell: bash
run: |
echo "::group::Cleanup"
${{ inputs.clean-command }}
echo "::endgroup::"
- name: Turn off the Gradle Daemon
shell: bash
working-directory: ${{ inputs.working-directory }}
run: ./gradlew --stop
- name: Force-kill the remaining Gradle Daemons on Windows
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
WMIC PROCESS where "Name like 'java%' AND CommandLine like '%GradleDaemon%'" Call Terminate
- name: Cleanup the Gradle cache
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
rm -f ~/.gradle/jdks/*.lock
rm -rf ~/.gradle/jdks/*/
- name: Force the Gradle cleanup on Windows
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
$files = "c:\Users\runneradmin\.gradle\caches\modules-2\modules-2.lock","c:\Users\runneradmin\.gradle\caches\modules-2\gc.properties"
foreach ($file in $files) {
if (Test-Path -Path $file -PathType Leaf) {
Remove-Item -Force $file
}
}
$jdkFolder = "c:\Users\runneradmin\.gradle\jdks\"
if (Test-Path -Path $jdkFolder) {
Get-ChildItem -Name $jdkFolder -Filter *.lock | Foreach-Object { Remove-Item -Force "c:\Users\runneradmin\.gradle\jdks\$_" }
}