Include provisioned Gradle version as action output

Fixes #259
This commit is contained in:
daz 2023-08-19 11:50:40 -06:00 committed by Daz DeBoer
parent 124cb765ee
commit 8cade330d4
5 changed files with 49 additions and 22 deletions

View File

@ -55,6 +55,17 @@ jobs:
- name: Test use release-candidate
working-directory: .github/workflow-samples/no-wrapper
run: gradle help
- name: Setup Gradle with current
id: gradle-current
uses: ./
with:
gradle-version: current
- name: Check current version output parameter
if: ${{ !startsWith(steps.gradle-current.outputs.gradle-version , '8.') }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Gradle version parameter not set correctly: value was "${{ steps.gradle-current.outputs.gradle-version }}"')
gradle-versions:
strategy:
@ -80,10 +91,17 @@ jobs:
distribution: temurin
java-version: 8
- name: Setup Gradle
id: setup-gradle
uses: ./
with:
cache-read-only: false # For testing, allow writing cache entries on non-default branches
gradle-version: ${{ matrix.gradle }}
- name: Check output parameter
if: ${{ steps.setup-gradle.outputs.gradle-version != matrix.gradle }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Gradle version parameter not set correctly: value was "${{ steps.setup-gradle.outputs.gradle-version }}"')
- name: Run Gradle build
id: gradle
working-directory: .github/workflow-samples/no-wrapper${{ matrix.build-root-suffix }}

View File

@ -90,6 +90,8 @@ outputs:
description: Link to the Build Scan® generated by a Gradle build. Note that this output applies to a Step executing Gradle, not to the `gradle-build-action` Step itself.
dependency-graph-file:
description: Path to the GitHub Dependency Graph snapshot file generated by a Gradle build. Note that this output applies to a Step executing Gradle, not to the `gradle-build-action` Step itself.
gradle-version:
description: Version of Gradle that was setup by the action
runs:
using: 'node16'

20
dist/main/index.js vendored
View File

@ -74827,6 +74827,13 @@ function addToPath(executable) {
});
}
function installGradle(version) {
return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield resolveGradleVersion(version);
core.setOutput('gradle-version', versionInfo.version);
return installGradleVersion(versionInfo);
});
}
function resolveGradleVersion(version) {
return __awaiter(this, void 0, void 0, function* () {
switch (version) {
case 'current':
@ -74847,15 +74854,14 @@ function installGradle(version) {
}
function gradleCurrent() {
return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`);
return installGradleVersion(versionInfo);
return yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`);
});
}
function gradleReleaseCandidate() {
return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`);
if (versionInfo && versionInfo.version && versionInfo.downloadUrl) {
return installGradleVersion(versionInfo);
return versionInfo;
}
core.info('No current release-candidate found, will fallback to current');
return gradleCurrent();
@ -74863,14 +74869,12 @@ function gradleReleaseCandidate() {
}
function gradleNightly() {
return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`);
return installGradleVersion(versionInfo);
return yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`);
});
}
function gradleReleaseNightly() {
return __awaiter(this, void 0, void 0, function* () {
const versionInfo = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`);
return installGradleVersion(versionInfo);
return yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`);
});
}
function gradle(version) {
@ -74879,7 +74883,7 @@ function gradle(version) {
if (!versionInfo) {
throw new Error(`Gradle version ${version} does not exists`);
}
return installGradleVersion(versionInfo);
return versionInfo;
});
}
function gradleVersionDeclaration(url) {

File diff suppressed because one or more lines are too long

View File

@ -38,6 +38,12 @@ async function addToPath(executable: string): Promise<string> {
}
async function installGradle(version: string): Promise<string> {
const versionInfo = await resolveGradleVersion(version)
core.setOutput('gradle-version', versionInfo.version)
return installGradleVersion(versionInfo)
}
async function resolveGradleVersion(version: string): Promise<GradleVersionInfo> {
switch (version) {
case 'current':
return gradleCurrent()
@ -55,36 +61,33 @@ async function installGradle(version: string): Promise<string> {
}
}
async function gradleCurrent(): Promise<string> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`)
return installGradleVersion(versionInfo)
async function gradleCurrent(): Promise<GradleVersionInfo> {
return await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`)
}
async function gradleReleaseCandidate(): Promise<string> {
async function gradleReleaseCandidate(): Promise<GradleVersionInfo> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`)
if (versionInfo && versionInfo.version && versionInfo.downloadUrl) {
return installGradleVersion(versionInfo)
return versionInfo
}
core.info('No current release-candidate found, will fallback to current')
return gradleCurrent()
}
async function gradleNightly(): Promise<string> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`)
return installGradleVersion(versionInfo)
async function gradleNightly(): Promise<GradleVersionInfo> {
return await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`)
}
async function gradleReleaseNightly(): Promise<string> {
const versionInfo = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`)
return installGradleVersion(versionInfo)
async function gradleReleaseNightly(): Promise<GradleVersionInfo> {
return await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`)
}
async function gradle(version: string): Promise<string> {
async function gradle(version: string): Promise<GradleVersionInfo> {
const versionInfo = await findGradleVersionDeclaration(version)
if (!versionInfo) {
throw new Error(`Gradle version ${version} does not exists`)
}
return installGradleVersion(versionInfo)
return versionInfo
}
async function gradleVersionDeclaration(url: string): Promise<GradleVersionInfo> {