mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-12-26 00:32:08 -05:00
Merge pull request #52 from eskatos/dd/update-versions
Update dependency versions
This commit is contained in:
commit
13d33a88ca
6 changed files with 792 additions and 877 deletions
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
1537
package-lock.json
generated
1537
package-lock.json
generated
File diff suppressed because it is too large
Load diff
36
package.json
36
package.json
|
@ -24,30 +24,28 @@
|
|||
"author": "Paul Merlin <paul@nosphere.org>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "1.0.5",
|
||||
"@actions/core": "1.2.6",
|
||||
"@actions/exec": "1.0.4",
|
||||
"@actions/glob": "0.1.1",
|
||||
"@actions/http-client": "1.0.9",
|
||||
"@actions/io": "1.0.2",
|
||||
"@actions/tool-cache": "1.6.1",
|
||||
"string-argv": "0.3.1",
|
||||
"unzipper": "0.10.11"
|
||||
"@actions/cache": "1.0.7",
|
||||
"@actions/core": "1.4.0",
|
||||
"@actions/exec": "1.1.0",
|
||||
"@actions/glob": "0.2.0",
|
||||
"@actions/http-client": "1.0.11",
|
||||
"@actions/tool-cache": "1.7.1",
|
||||
"string-argv": "0.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "26.0.19",
|
||||
"@types/node": "12.12.6",
|
||||
"@types/unzipper": "0.10.3",
|
||||
"@typescript-eslint/parser": "4.11.0",
|
||||
"@types/jest": "26.0.23",
|
||||
"@types/node": "14.17.3",
|
||||
"@types/unzipper": "0.10.4",
|
||||
"@typescript-eslint/parser": "4.28.2",
|
||||
"@zeit/ncc": "0.22.3",
|
||||
"eslint": "7.16.0",
|
||||
"eslint-plugin-github": "4.1.1",
|
||||
"eslint-plugin-jest": "24.1.3",
|
||||
"eslint": "7.30.0",
|
||||
"eslint-plugin-github": "4.1.3",
|
||||
"eslint-plugin-jest": "24.3.6",
|
||||
"jest": "26.6.3",
|
||||
"jest-circus": "26.6.3",
|
||||
"js-yaml": "3.14.1",
|
||||
"prettier": "2.2.1",
|
||||
"ts-jest": "26.4.4",
|
||||
"typescript": "4.0.2"
|
||||
"prettier": "2.3.2",
|
||||
"ts-jest": "26.5.6",
|
||||
"typescript": "4.3.5"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,44 +1,13 @@
|
|||
import * as crypto from 'crypto'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import * as stream from 'stream'
|
||||
import * as util from 'util'
|
||||
|
||||
import * as glob from '@actions/glob'
|
||||
|
||||
export async function hashFiles(
|
||||
baseDir: string,
|
||||
globs: string[] = ['**'],
|
||||
patterns: string[] = ['**'],
|
||||
followSymbolicLinks = false
|
||||
): Promise<string | null> {
|
||||
let hasMatch = false
|
||||
type FileHashes = Record<string, Buffer>
|
||||
const hashes: FileHashes = {}
|
||||
for await (const globPattern of globs) {
|
||||
const globMatch = `${baseDir}${path.sep}${globPattern}`
|
||||
const globber = await glob.create(globMatch, {followSymbolicLinks})
|
||||
for await (const file of globber.globGenerator()) {
|
||||
// console.log(file)
|
||||
if (!file.startsWith(`${baseDir}${path.sep}`)) {
|
||||
// console.log(`Ignore '${file}' since it is not under '${baseDir}'.`)
|
||||
continue
|
||||
}
|
||||
if (fs.statSync(file).isDirectory()) {
|
||||
// console.log(`Skip directory '${file}'.`)
|
||||
continue
|
||||
}
|
||||
const hash = crypto.createHash('sha256')
|
||||
const pipeline = util.promisify(stream.pipeline)
|
||||
await pipeline(fs.createReadStream(file), hash)
|
||||
hashes[path.relative(baseDir, file)] = hash.digest()
|
||||
hasMatch = true
|
||||
}
|
||||
}
|
||||
if (!hasMatch) return null
|
||||
const result = crypto.createHash('sha256')
|
||||
for (const file of Object.keys(hashes).sort()) {
|
||||
result.update(hashes[file])
|
||||
}
|
||||
result.end()
|
||||
return result.digest('hex')
|
||||
const combinedPatterns = patterns
|
||||
.map(pattern => `${baseDir}${path.sep}${pattern}`)
|
||||
.join('\n')
|
||||
return glob.hashFiles(combinedPatterns, {followSymbolicLinks})
|
||||
}
|
||||
|
|
|
@ -2,14 +2,11 @@ import * as fs from 'fs'
|
|||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
import * as httpm from '@actions/http-client'
|
||||
import * as unzip from 'unzipper'
|
||||
import * as core from '@actions/core'
|
||||
import * as io from '@actions/io'
|
||||
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'
|
||||
|
||||
/**
|
||||
|
@ -95,22 +92,21 @@ async function provisionGradle(version: string, url: string): Promise<string> {
|
|||
return cachedExecutable
|
||||
}
|
||||
|
||||
const home = os.homedir()
|
||||
const tmpdir = path.join(home, 'gradle-provision-tmpdir')
|
||||
const downloadsDir = path.join(tmpdir, 'downloads')
|
||||
const installsDir = path.join(tmpdir, 'installs')
|
||||
await io.mkdirP(downloadsDir)
|
||||
await io.mkdirP(installsDir)
|
||||
const tmpdir = path.join(os.homedir(), 'gradle-provision-tmpdir')
|
||||
|
||||
core.info(`Downloading ${url}`)
|
||||
|
||||
const downloadPath = path.join(downloadsDir, `gradle-${version}-bin.zip`)
|
||||
await httpDownload(url, downloadPath)
|
||||
const downloadPath = path.join(
|
||||
tmpdir,
|
||||
`downloads/gradle-${version}-bin.zip`
|
||||
)
|
||||
await toolCache.downloadTool(url, downloadPath)
|
||||
core.info(
|
||||
`Downloaded at ${downloadPath}, size ${fs.statSync(downloadPath).size}`
|
||||
)
|
||||
|
||||
await extractZip(downloadPath, installsDir)
|
||||
const installsDir = path.join(tmpdir, 'installs')
|
||||
await toolCache.extractZip(downloadPath, installsDir)
|
||||
const installDir = path.join(installsDir, `gradle-${version}`)
|
||||
core.info(`Extracted in ${installDir}`)
|
||||
|
||||
|
@ -138,38 +134,11 @@ async function httpGetGradleVersions(
|
|||
}
|
||||
|
||||
async function httpGetString(url: string): Promise<string> {
|
||||
const response = await httpc.get(url)
|
||||
const httpClient = new httpm.HttpClient('eskatos/gradle-command-action')
|
||||
const response = await httpClient.get(url)
|
||||
return response.readBody()
|
||||
}
|
||||
|
||||
async function httpDownload(url: string, localPath: string): Promise<void> {
|
||||
const response = await httpc.get(url)
|
||||
return new Promise<void>(function (resolve, reject) {
|
||||
const writeStream = fs.createWriteStream(localPath)
|
||||
response.message
|
||||
.pipe(writeStream)
|
||||
.on('close', () => {
|
||||
resolve()
|
||||
})
|
||||
.on('error', err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function extractZip(zip: string, destination: string): Promise<void> {
|
||||
return new Promise<void>(function (resolve, reject) {
|
||||
fs.createReadStream(zip)
|
||||
.pipe(unzip.Extract({path: destination}))
|
||||
.on('close', () => {
|
||||
resolve()
|
||||
})
|
||||
.on('error', err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
interface GradleVersionInfo {
|
||||
version: string
|
||||
downloadUrl: string
|
||||
|
|
Loading…
Reference in a new issue