-
Notifications
You must be signed in to change notification settings - Fork 4
/
action.yml
199 lines (197 loc) · 7.75 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
name: Build and delivery a Gradle project
description: Build and delivery a Gradle project
branding:
icon: 'box'
color: 'green'
inputs:
build-command:
description: 'The command executed in the build phase'
default: './gradlew assemble --parallel'
required: false
check-command:
description: 'The command executed in the check phase'
default: './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 variable MAVEN_CENTRAL_PASSWORD'
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 variable MAVEN_CENTRAL_PASSWORD'
required: false
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 variable ORG_GRADLE_PROJECT_signingPassword and SIGNING_PASSWORD'
required: false
runs:
using: composite
steps:
- name: Validate the Gradle Wraper
if: inputs.should-validate-wrapper == 'true'
uses: gradle/wrapper-validation-action@v1.0.4
- name: Setup Java
uses: actions/setup-java@v3.3.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.2
- name: Cache Gradle packages
uses: actions/cache@v3.0.2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.gradle/jdks
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
${{ inputs.build-command }}
- name: Check
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
${{ inputs.check-command }}
- name: CodeCov
if: inputs.should-run-codecov == 'true'
uses: codecov/codecov-action@v3.1.0
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 }}
ORG_GRADLE_PROJECT_signingKey: ${{ inputs.signing-key }}
ORG_GRADLE_PROJECT_signingPassword: ${{ inputs.signing-password }}
SIGNING_PASSWORD: ${{ inputs.signing-password }}
run: |
${{ inputs.deploy-command }}
- name: Cleanup
working-directory: ${{ inputs.working-directory }}
shell: bash
run: |
${{ inputs.clean-command }}
- 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\$_" }
}