Skip to content

Commit

Permalink
Upgraded to node 20 and latest github apis
Browse files Browse the repository at this point in the history
  • Loading branch information
DavyLandman committed May 8, 2024
1 parent 2403551 commit 2ff3f00
Show file tree
Hide file tree
Showing 9 changed files with 115,339 additions and 18,521 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ inputs:
description: 'Extra maven options'
default: ''
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'
130,237 changes: 113,184 additions & 17,053 deletions dist/index.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

945 changes: 0 additions & 945 deletions dist/licenses.txt

This file was deleted.

1 change: 0 additions & 1 deletion dist/sourcemap-register.js

This file was deleted.

2,597 changes: 2,116 additions & 481 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"description": "",
"main": "lib/main.js",
"scripts": {
"build": "tsc",
"build": "esbuild src/main.ts --platform=node --target=node20 --bundle --sourcemap --outfile=dist/index.js",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"package": "npx tsc && npx ncc build --source-map --license licenses.txt"
"format-check": "prettier --check **/*.ts"
},
"repository": {
"type": "git",
Expand All @@ -22,16 +21,18 @@
"author": "",
"license": "BSD-2",
"dependencies": {
"@actions/artifact": "^1.1.0",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.0",
"@actions/github": "^5.0.0",
"@actions/io": "^1.1.0"
"@actions/artifact": "2.x",
"@actions/core": "1.x",
"@actions/exec": "1.x",
"@actions/github": "6.x",
"@actions/io": "1.x"
},
"devDependencies": {
"@types/node": "^16.0.0",
"@vercel/ncc": "^0.34.0",
"prettier": "2.8.0",
"typescript": "^4.7.0"
"@tsconfig/node20": "20.x",
"@tsconfig/strictest": "2.x",
"@types/node": "20.x",
"esbuild": "0.21.x",
"prettier": "3.x",
"typescript": "5.x"
}
}
30 changes: 10 additions & 20 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as core from '@actions/core'
import {exec} from '@actions/exec'
import * as io from '@actions/io'
import {DefaultArtifactClient} from '@actions/artifact'
import * as github from '@actions/github'
import * as artifact from '@actions/artifact'
import {lstatSync, readdirSync} from 'fs'
import {promises} from 'fs'
import path from 'path'
import os from 'os'

async function run(): Promise<void> {
try {
const localDir = path.join(process.env.RUNNER_TEMP || os.tmpdir(), github.context.sha)
const localDir = path.join(process.env['RUNNER_TEMP'] || os.tmpdir(), github.context.sha)
await io.mkdirP(localDir)
const localMavenRepo = `local::file://${localDir}`
await exec('mvn', ['-version'])
Expand All @@ -23,7 +23,7 @@ async function run(): Promise<void> {
'-DskipTests',
`-DaltDeploymentRepository=${localMavenRepo}`,
'package',
'org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy'
'org.apache.maven.plugins:maven-deploy-plugin:3.1.2:deploy'
].filter(s => s && s !== '')
)

Expand All @@ -39,31 +39,21 @@ async function run(): Promise<void> {
}

core.info('Uploading results as artifact')
const uploadResult = await artifact.create().uploadArtifact(artifactName, readFiles(localDir), localDir, {
continueOnError: false
await new DefaultArtifactClient().uploadArtifact(artifactName, await allFiles(localDir), localDir, {
compressionLevel: 0
})

if (uploadResult.failedItems.length > 0) {
throw new Error(`Error uploading artifact, failed files: ${uploadResult.failedItems}`)
}
core.info('Finished uploading artifact')
core.setOutput('artifact-root-dir', localDir)
} catch (error: any) {
core.setFailed(error.message)
}
}

function readFiles(dir: string): string[] {
const result: string[] = []
for (const entry of readdirSync(dir)) {
const fullEntry = `${dir}/${entry}`
if (lstatSync(fullEntry).isDirectory()) {
result.push(...readFiles(fullEntry))
} else {
result.push(fullEntry)
}
}
return result
async function allFiles(dir: string): Promise<string[]> {
return (await promises.readdir(dir, {recursive: true, withFileTypes: true}))
.filter(e => e.isFile())
.map(e => `${e.path}/${e.name}`)
}

run()
15 changes: 8 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": [
"@tsconfig/node20/tsconfig.json",
"@tsconfig/strictest/tsconfig.json"
],

"compilerOptions": {
"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'. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"rootDir": "src",
"outDir": "lib"
},
"exclude": ["node_modules", "**/*.test.ts"]
}

0 comments on commit 2ff3f00

Please sign in to comment.