mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-10-20 15:18:56 +08:00
Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
064f85c156 | ||
|
580b26a94c | ||
|
15e064da79 | ||
|
c61d0fe2b5 | ||
|
c5e1979a6b | ||
|
dc882d2669 | ||
|
f9f0422c72 | ||
|
6170f06e8d | ||
|
e561eefa28 | ||
|
38eaee068d | ||
|
0a56b592f2 | ||
|
091093ee61 | ||
|
7a4f128c22 | ||
|
f943246fd9 | ||
|
8337949d80 | ||
|
76166f0035 | ||
|
a9718db8ba |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,5 +1,10 @@
|
||||
__tests__/runner/*
|
||||
!lib/
|
||||
!node_modules
|
||||
|
||||
.idea
|
||||
*.iml
|
||||
__tests__/runner/*
|
||||
|
||||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||
# Logs
|
||||
@@ -42,7 +47,6 @@ bower_components
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
!node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
|
76
CODE_OF_CONDUCT.md
Normal file
76
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at paul@nosphere.org. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
38
README.md
38
README.md
@@ -2,13 +2,16 @@
|
||||
|
||||
This Github Action can be used to run arbitrary Gradle commands on any platform supported by Github Actions.
|
||||
|
||||
You might also be interested by the related [Gradle Plugin](https://github.com/eskatos/gradle-github-actions-plugin) that allows your build to easily get Github Actions environment and tag Gradle Build Scans accordingly.
|
||||
|
||||
## Usage
|
||||
|
||||
The following workflow will run `gradle build` using the wrapper from the repository on ubuntu, macos and windows:
|
||||
The following workflow will run `gradle build` using the wrapper from the repository on ubuntu, macos and windows. The only prerequisite is to have Java installed, you can define the version you need to run the build using the `actions/setup-java` action.
|
||||
|
||||
|
||||
|
||||
```yaml
|
||||
// .github/workflows/gradle-build-pr.yml
|
||||
# .github/workflows/gradle-build-pr.yml
|
||||
name: Run Gradle on PRs
|
||||
on: pull-request
|
||||
jobs:
|
||||
@@ -94,10 +97,10 @@ Moreover, you can use the following aliases:
|
||||
| `nightly` | The latest [nightly](https://gradle.org/nightly/), fails if none. |
|
||||
| `release-nightly` | The latest [release nightly](https://gradle.org/release-nightly/), fails if none. |
|
||||
|
||||
This can be handy to automatically test your build with the next Gradle version once a release candidate is out:
|
||||
This can be handy to, for example, automatically test your build with the next Gradle version once a release candidate is out:
|
||||
|
||||
```yaml
|
||||
// .github/workflows/test-gradle-rc.yml
|
||||
# .github/workflows/test-gradle-rc.yml
|
||||
name: Test latest Gradle RC
|
||||
on:
|
||||
schedule:
|
||||
@@ -121,3 +124,30 @@ jobs:
|
||||
If your build publishes a [build scan](https://gradle.com/build-scans/) the `gradle-command-action` action will emit the link to the published build scan as an output named `build-scan-url`.
|
||||
|
||||
You can then use that link in subsequent actions of your workflow.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
# .github/workflows/gradle-build-pr.yml
|
||||
name: Run Gradle on PRs
|
||||
on: pull-request
|
||||
jobs:
|
||||
gradle:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
- uses: eskatos/gradle-command-action@v1
|
||||
with:
|
||||
arguments: build
|
||||
id: gradle
|
||||
- uses: example/action-that-comments-on-the-pr@v0
|
||||
if: failure()
|
||||
with:
|
||||
comment: Build failed ${{ steps.gradle.outputs.build-scan-url }}
|
||||
```
|
||||
|
@@ -20,9 +20,10 @@ const exec = __importStar(require("@actions/exec"));
|
||||
function execute(executable, root, argv) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let publishing = false;
|
||||
let buildScanLink = null;
|
||||
yield exec.exec(executable, argv, {
|
||||
let buildScanUrl;
|
||||
const status = yield exec.exec(executable, argv, {
|
||||
cwd: root,
|
||||
ignoreReturnCode: true,
|
||||
listeners: {
|
||||
stdline: (line) => {
|
||||
if (line.startsWith("Publishing build scan...")) {
|
||||
@@ -32,21 +33,19 @@ function execute(executable, root, argv) {
|
||||
publishing = false;
|
||||
}
|
||||
if (publishing && line.startsWith("http")) {
|
||||
buildScanLink = line.trim();
|
||||
buildScanUrl = line.trim();
|
||||
publishing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (buildScanLink != null) {
|
||||
return new BuildResultImpl(buildScanLink.toString());
|
||||
}
|
||||
return new BuildResultImpl(null);
|
||||
return new BuildResultImpl(status, buildScanUrl);
|
||||
});
|
||||
}
|
||||
exports.execute = execute;
|
||||
class BuildResultImpl {
|
||||
constructor(buildScanUrl) {
|
||||
constructor(status, buildScanUrl) {
|
||||
this.status = status;
|
||||
this.buildScanUrl = buildScanUrl;
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const IS_WINDOWS = process.platform === "win32";
|
||||
function wrapperFilename() {
|
||||
const isWindows = process.platform === "win32";
|
||||
return isWindows ? "gradlew.bat" : "gradlew";
|
||||
return IS_WINDOWS ? "gradlew.bat" : "gradlew";
|
||||
}
|
||||
exports.wrapperFilename = wrapperFilename;
|
||||
function installScriptFilename() {
|
||||
const isWindows = process.platform === "win32";
|
||||
return isWindows ? "gradle.bat" : "gradle";
|
||||
return IS_WINDOWS ? "gradle.bat" : "gradle";
|
||||
}
|
||||
exports.installScriptFilename = installScriptFilename;
|
||||
|
17
lib/main.js
17
lib/main.js
@@ -22,42 +22,47 @@ const string_argv_1 = require("string-argv");
|
||||
const execution = __importStar(require("./execution"));
|
||||
const gradlew = __importStar(require("./gradlew"));
|
||||
const provision = __importStar(require("./provision"));
|
||||
// Invoked by Github Actions
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const baseDirectory = process.env[`GITHUB_WORKSPACE`] || "";
|
||||
let result = yield execution.execute(yield resolveGradleExecutable(baseDirectory), resolveBuildRootDirectory(baseDirectory), parseCommandLineArguments());
|
||||
if (result.buildScanUrl != null) {
|
||||
if (result.buildScanUrl) {
|
||||
core.setOutput("build-scan-url", result.buildScanUrl);
|
||||
}
|
||||
if (result.status != 0) {
|
||||
core.setFailed(`Gradle process exited with status ${result.status}`);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.run = run;
|
||||
run();
|
||||
function resolveGradleExecutable(baseDirectory) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const gradleVersion = inputOrNull("gradle-version");
|
||||
if (gradleVersion != null) {
|
||||
return provision.gradleVersion(gradleVersion);
|
||||
return path.resolve(yield provision.gradleVersion(gradleVersion));
|
||||
}
|
||||
const gradleExecutable = inputOrNull("gradle-executable");
|
||||
if (gradleExecutable != null) {
|
||||
return path.join(baseDirectory, gradleExecutable);
|
||||
return path.resolve(baseDirectory, gradleExecutable);
|
||||
}
|
||||
const wrapperDirectory = inputOrNull("wrapper-directory");
|
||||
const executableDirectory = wrapperDirectory != null
|
||||
? path.join(baseDirectory, wrapperDirectory)
|
||||
: baseDirectory;
|
||||
return path.join(executableDirectory, gradlew.wrapperFilename());
|
||||
return path.resolve(executableDirectory, gradlew.wrapperFilename());
|
||||
});
|
||||
}
|
||||
function resolveBuildRootDirectory(baseDirectory) {
|
||||
let buildRootDirectory = inputOrNull("build-root-directory");
|
||||
return buildRootDirectory == null ? baseDirectory : path.join(baseDirectory, buildRootDirectory);
|
||||
return buildRootDirectory == null
|
||||
? path.resolve(baseDirectory)
|
||||
: path.resolve(baseDirectory, buildRootDirectory);
|
||||
}
|
||||
function parseCommandLineArguments() {
|
||||
const input = inputOrNull("arguments");
|
||||
|
@@ -24,9 +24,8 @@ const core = __importStar(require("@actions/core"));
|
||||
const io = __importStar(require("@actions/io"));
|
||||
const toolCache = __importStar(require("@actions/tool-cache"));
|
||||
const gradlew = __importStar(require("./gradlew"));
|
||||
/**
|
||||
* @return Gradle executable
|
||||
*/
|
||||
const httpc = new httpm.HttpClient("eskatos/gradle-command-action");
|
||||
const gradleVersionsBaseUrl = "https://services.gradle.org/versions";
|
||||
function gradleVersion(gradleVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
switch (gradleVersion) {
|
||||
@@ -44,7 +43,6 @@ function gradleVersion(gradleVersion) {
|
||||
});
|
||||
}
|
||||
exports.gradleVersion = gradleVersion;
|
||||
const gradleVersionsBaseUrl = "https://services.gradle.org/versions";
|
||||
function gradleCurrent() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const json = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`);
|
||||
@@ -54,7 +52,7 @@ function gradleCurrent() {
|
||||
function gradleReleaseCandidate() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const json = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`);
|
||||
if (json != null) {
|
||||
if (json) {
|
||||
return provisionGradle(json.version, json.downloadUrl);
|
||||
}
|
||||
return gradleCurrent();
|
||||
@@ -75,7 +73,7 @@ function gradleReleaseNightly() {
|
||||
function gradle(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const declaration = yield findGradleVersionDeclaration(version);
|
||||
if (declaration == null) {
|
||||
if (!declaration) {
|
||||
throw new Error(`Gradle version ${version} does not exists`);
|
||||
}
|
||||
return provisionGradle(declaration.version, declaration.downloadUrl);
|
||||
@@ -83,31 +81,23 @@ function gradle(version) {
|
||||
}
|
||||
function gradleVersionDeclaration(url) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const httpc = new httpm.HttpClient("gradle-github-action");
|
||||
const response = yield httpc.get(url);
|
||||
const body = yield response.readBody();
|
||||
const json = JSON.parse(body);
|
||||
return (json == null || json.version == null || json.version.length <= 0)
|
||||
? null
|
||||
: json;
|
||||
const json = yield httpGetJson(url);
|
||||
return (json.version && json.version.length > 0) ? json : undefined;
|
||||
});
|
||||
}
|
||||
function findGradleVersionDeclaration(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const httpc = new httpm.HttpClient("gradle-github-action");
|
||||
const response = yield httpc.get(`${gradleVersionsBaseUrl}/all`);
|
||||
const body = yield response.readBody();
|
||||
const json = JSON.parse(body);
|
||||
const found = json.find(entry => {
|
||||
return entry.version == version;
|
||||
const json = yield httpGetJson(`${gradleVersionsBaseUrl}/all`);
|
||||
const found = json.find((entry) => {
|
||||
return entry.version === version;
|
||||
});
|
||||
return found != undefined ? found : null;
|
||||
return found ? found : undefined;
|
||||
});
|
||||
}
|
||||
function provisionGradle(version, url) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const cachedInstall = toolCache.find("gradle", version);
|
||||
if (cachedInstall != null && cachedInstall.length > 0) {
|
||||
if (cachedInstall.length > 0) {
|
||||
const cachedExecutable = executableFrom(cachedInstall);
|
||||
core.info(`Provisioned Gradle executable ${cachedExecutable}`);
|
||||
return cachedExecutable;
|
||||
@@ -135,10 +125,16 @@ function provisionGradle(version, url) {
|
||||
function executableFrom(installDir) {
|
||||
return path.join(installDir, "bin", `${gradlew.installScriptFilename()}`);
|
||||
}
|
||||
function httpGetJson(url) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const response = yield httpc.get(url);
|
||||
const body = yield response.readBody();
|
||||
return JSON.parse(body);
|
||||
});
|
||||
}
|
||||
function httpDownload(url, path) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const httpc = new httpm.HttpClient("gradle-github-action");
|
||||
const writeStream = fs.createWriteStream(path);
|
||||
httpc.get(url).then(response => {
|
||||
response.message.pipe(writeStream)
|
||||
|
@@ -4,10 +4,11 @@ import * as exec from "@actions/exec";
|
||||
export async function execute(executable: string, root: string, argv: string[]): Promise<BuildResult> {
|
||||
|
||||
let publishing = false;
|
||||
let buildScanLink: any = null;
|
||||
let buildScanUrl: string | undefined;
|
||||
|
||||
await exec.exec(executable, argv, {
|
||||
const status: number = await exec.exec(executable, argv, {
|
||||
cwd: root,
|
||||
ignoreReturnCode: true,
|
||||
listeners: {
|
||||
stdline: (line: string) => {
|
||||
if (line.startsWith("Publishing build scan...")) {
|
||||
@@ -17,24 +18,25 @@ export async function execute(executable: string, root: string, argv: string[]):
|
||||
publishing = false
|
||||
}
|
||||
if (publishing && line.startsWith("http")) {
|
||||
buildScanLink = line.trim();
|
||||
buildScanUrl = line.trim();
|
||||
publishing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (buildScanLink != null) {
|
||||
return new BuildResultImpl(buildScanLink.toString());
|
||||
}
|
||||
return new BuildResultImpl(null as unknown as string);
|
||||
return new BuildResultImpl(status, buildScanUrl);
|
||||
}
|
||||
|
||||
export interface BuildResult {
|
||||
buildScanUrl: string
|
||||
readonly status: number
|
||||
readonly buildScanUrl?: string
|
||||
}
|
||||
|
||||
class BuildResultImpl implements BuildResult {
|
||||
constructor(readonly buildScanUrl: string) {
|
||||
constructor(
|
||||
readonly status: number,
|
||||
readonly buildScanUrl?: string
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
export function wrapperFilename() {
|
||||
const isWindows = process.platform === "win32";
|
||||
return isWindows ? "gradlew.bat" : "gradlew";
|
||||
const IS_WINDOWS = process.platform === "win32";
|
||||
|
||||
|
||||
export function wrapperFilename(): string {
|
||||
return IS_WINDOWS ? "gradlew.bat" : "gradlew";
|
||||
}
|
||||
|
||||
export function installScriptFilename() {
|
||||
const isWindows = process.platform === "win32";
|
||||
return isWindows ? "gradle.bat" : "gradle";
|
||||
|
||||
export function installScriptFilename(): string {
|
||||
return IS_WINDOWS ? "gradle.bat" : "gradle";
|
||||
}
|
||||
|
18
src/main.ts
18
src/main.ts
@@ -8,7 +8,7 @@ import * as provision from "./provision";
|
||||
|
||||
|
||||
// Invoked by Github Actions
|
||||
async function run() {
|
||||
export async function run() {
|
||||
try {
|
||||
|
||||
const baseDirectory = process.env[`GITHUB_WORKSPACE`] || "";
|
||||
@@ -19,10 +19,14 @@ async function run() {
|
||||
parseCommandLineArguments()
|
||||
);
|
||||
|
||||
if (result.buildScanUrl != null) {
|
||||
if (result.buildScanUrl) {
|
||||
core.setOutput("build-scan-url", result.buildScanUrl);
|
||||
}
|
||||
|
||||
if (result.status != 0) {
|
||||
core.setFailed(`Gradle process exited with status ${result.status}`)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
@@ -36,12 +40,12 @@ async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
|
||||
|
||||
const gradleVersion = inputOrNull("gradle-version");
|
||||
if (gradleVersion != null) {
|
||||
return provision.gradleVersion(gradleVersion)
|
||||
return path.resolve(await provision.gradleVersion(gradleVersion))
|
||||
}
|
||||
|
||||
const gradleExecutable = inputOrNull("gradle-executable");
|
||||
if (gradleExecutable != null) {
|
||||
return path.join(baseDirectory, gradleExecutable)
|
||||
return path.resolve(baseDirectory, gradleExecutable)
|
||||
}
|
||||
|
||||
const wrapperDirectory = inputOrNull("wrapper-directory");
|
||||
@@ -49,13 +53,15 @@ async function resolveGradleExecutable(baseDirectory: string): Promise<string> {
|
||||
? path.join(baseDirectory, wrapperDirectory)
|
||||
: baseDirectory;
|
||||
|
||||
return path.join(executableDirectory, gradlew.wrapperFilename());
|
||||
return path.resolve(executableDirectory, gradlew.wrapperFilename());
|
||||
}
|
||||
|
||||
|
||||
function resolveBuildRootDirectory(baseDirectory: string): string {
|
||||
let buildRootDirectory = inputOrNull("build-root-directory");
|
||||
return buildRootDirectory == null ? baseDirectory : path.join(baseDirectory, buildRootDirectory);
|
||||
return buildRootDirectory == null
|
||||
? path.resolve(baseDirectory)
|
||||
: path.resolve(baseDirectory, buildRootDirectory);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -9,8 +9,12 @@ import * as toolCache from "@actions/tool-cache";
|
||||
import * as gradlew from "./gradlew";
|
||||
|
||||
|
||||
const httpc = new httpm.HttpClient("eskatos/gradle-command-action");
|
||||
const gradleVersionsBaseUrl = "https://services.gradle.org/versions";
|
||||
|
||||
|
||||
/**
|
||||
* @return Gradle executable
|
||||
* @return Gradle executable path
|
||||
*/
|
||||
export async function gradleVersion(gradleVersion: string): Promise<string> {
|
||||
switch (gradleVersion) {
|
||||
@@ -28,9 +32,6 @@ export async function gradleVersion(gradleVersion: string): Promise<string> {
|
||||
}
|
||||
|
||||
|
||||
const gradleVersionsBaseUrl = "https://services.gradle.org/versions";
|
||||
|
||||
|
||||
async function gradleCurrent(): Promise<string> {
|
||||
const json = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`);
|
||||
return provisionGradle(json.version, json.downloadUrl);
|
||||
@@ -39,7 +40,7 @@ async function gradleCurrent(): Promise<string> {
|
||||
|
||||
async function gradleReleaseCandidate(): Promise<string> {
|
||||
const json = await gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`);
|
||||
if (json != null) {
|
||||
if (json) {
|
||||
return provisionGradle(json.version, json.downloadUrl);
|
||||
}
|
||||
return gradleCurrent();
|
||||
@@ -60,39 +61,32 @@ async function gradleReleaseNightly(): Promise<string> {
|
||||
|
||||
async function gradle(version: string): Promise<string> {
|
||||
const declaration = await findGradleVersionDeclaration(version);
|
||||
if (declaration == null) {
|
||||
if (!declaration) {
|
||||
throw new Error(`Gradle version ${version} does not exists`);
|
||||
}
|
||||
return provisionGradle(declaration.version, declaration.downloadUrl);
|
||||
}
|
||||
|
||||
|
||||
async function gradleVersionDeclaration(url: string): Promise<any | null> {
|
||||
const httpc = new httpm.HttpClient("gradle-github-action");
|
||||
const response = await httpc.get(url);
|
||||
const body = await response.readBody();
|
||||
const json = JSON.parse(body);
|
||||
return (json == null || json.version == null || json.version.length <= 0)
|
||||
? null
|
||||
: json
|
||||
async function gradleVersionDeclaration(url: string): Promise<any | undefined> {
|
||||
const json: any = await httpGetJson(url);
|
||||
return (json.version && json.version.length > 0) ? json : undefined
|
||||
}
|
||||
|
||||
|
||||
async function findGradleVersionDeclaration(version: string): Promise<any | null> {
|
||||
const httpc = new httpm.HttpClient("gradle-github-action");
|
||||
const response = await httpc.get(`${gradleVersionsBaseUrl}/all`);
|
||||
const body = await response.readBody();
|
||||
const json = JSON.parse(body);
|
||||
const found = json.find(entry => {
|
||||
return entry.version == version;
|
||||
async function findGradleVersionDeclaration(version: string): Promise<any | undefined> {
|
||||
const json: any = await httpGetJson(`${gradleVersionsBaseUrl}/all`);
|
||||
const found: any = json.find((entry: any) => {
|
||||
return entry.version === version;
|
||||
});
|
||||
return found != undefined ? found : null
|
||||
return found ? found : undefined
|
||||
}
|
||||
|
||||
|
||||
async function provisionGradle(version: string, url: string): Promise<string> {
|
||||
|
||||
const cachedInstall: string = toolCache.find("gradle", version);
|
||||
if (cachedInstall != null && cachedInstall.length > 0) {
|
||||
if (cachedInstall.length > 0) {
|
||||
const cachedExecutable = executableFrom(cachedInstall);
|
||||
core.info(`Provisioned Gradle executable ${cachedExecutable}`);
|
||||
return cachedExecutable;
|
||||
@@ -130,9 +124,15 @@ function executableFrom(installDir: string): string {
|
||||
}
|
||||
|
||||
|
||||
async function httpGetJson(url: string): Promise<any> {
|
||||
const response = await httpc.get(url);
|
||||
const body = await response.readBody();
|
||||
return JSON.parse(body);
|
||||
}
|
||||
|
||||
|
||||
async function httpDownload(url: string, path: string): Promise<void> {
|
||||
return new Promise<void>(function (resolve, reject) {
|
||||
const httpc = new httpm.HttpClient("gradle-github-action");
|
||||
const writeStream = fs.createWriteStream(path);
|
||||
httpc.get(url).then(response => {
|
||||
response.message.pipe(writeStream)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"incremental": true, /* Enable incremental compilation */
|
||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
@@ -15,7 +15,7 @@
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
"removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
@@ -23,13 +23,13 @@
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"strictNullChecks": true, /* Enable strict null checks. */
|
||||
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
|
Reference in New Issue
Block a user