Skip to content

Commit 7f23828

Browse files
committed
addressed most of the feedback
1 parent 01f4422 commit 7f23828

File tree

7 files changed

+131
-52
lines changed

7 files changed

+131
-52
lines changed

__tests__/gpg.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import gpg = require('../src/gpg');
1616
describe('gpg tests', () => {
1717
beforeEach(async () => {
1818
await io.mkdirP(tempDir);
19-
}, 300000);
19+
});
2020

2121
afterAll(async () => {
2222
try {

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,22 @@ inputs:
2121
description: 'Path to where the compressed JDK is located. The path could
2222
be in your source repository or a local path on the agent.'
2323
required: false
24+
default: ''
2425
server-id:
2526
description: 'ID of the distributionManagement repository in the pom.xml
2627
file. Default is `github`'
2728
required: false
29+
default: 'github'
2830
server-username:
2931
description: 'Environment variable name for the username for authentication
3032
to the Apache Maven repository. Default is $GITHUB_ACTOR'
3133
required: false
34+
default: 'GITHUB_ACTOR'
3235
server-password:
3336
description: 'Environment variable name for password or token for
3437
authentication to the Apache Maven repository. Default is $GITHUB_TOKEN'
3538
required: false
39+
default: 'GITHUB_TOKEN'
3640
settings-path:
3741
description: 'Path to where the settings.xml file will be written. Default is ~/.m2.'
3842
required: false
@@ -43,6 +47,7 @@ inputs:
4347
description: 'Environment variable name for the GPG private key passphrase. Default is
4448
$GPG_PASSPHRASE.'
4549
required: false
50+
default: 'GPG_PASSHPRASE'
4651
outputs:
4752
path:
4853
description: 'Path to where the java environment has been installed (same as $JAVA_HOME)'

dist/cleanup/index.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,28 @@ module.exports = require("os");
946946

947947
module.exports = require("child_process");
948948

949+
/***/ }),
950+
951+
/***/ 211:
952+
/***/ (function(__unusedmodule, exports) {
953+
954+
"use strict";
955+
956+
Object.defineProperty(exports, "__esModule", { value: true });
957+
exports.INPUT_VERSION = 'version';
958+
exports.INPUT_JAVA_VERSION = 'java-version';
959+
exports.INPUT_ARCHITECTURE = 'architecture';
960+
exports.INPUT_JAVA_PACKAGE = 'java-package';
961+
exports.INPUT_JDK_FILE = 'jdkFile';
962+
exports.INPUT_SERVER_ID = 'server-id';
963+
exports.INPUT_SERVER_USERNAME = 'server-username';
964+
exports.INPUT_SERVER_PASSWORD = 'server-password';
965+
exports.INPUT_GPG_PRIVATE_KEY = 'gpg-private-key';
966+
exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase';
967+
exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
968+
exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint';
969+
970+
949971
/***/ }),
950972

951973
/***/ 219:
@@ -972,12 +994,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
972994
Object.defineProperty(exports, "__esModule", { value: true });
973995
const core = __importStar(__webpack_require__(470));
974996
const gpg = __importStar(__webpack_require__(884));
997+
const constants = __importStar(__webpack_require__(211));
975998
function run() {
976999
return __awaiter(this, void 0, void 0, function* () {
977-
if (core.getInput('gpg-private-key', { required: false })) {
978-
console.log('removing private key from keychain');
1000+
if (core.getInput(constants.INPUT_GPG_PRIVATE_KEY, { required: false })) {
1001+
core.info('removing private key from keychain');
9791002
try {
980-
const keyFingerprint = core.getState('gpg-private-key-fingerprint');
1003+
const keyFingerprint = core.getState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT);
9811004
yield gpg.deleteKey(keyFingerprint);
9821005
}
9831006
catch (error) {

dist/setup/index.js

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25645,6 +25645,28 @@ function range(n, m) {
2564525645
exports.range = range;
2564625646
//# sourceMappingURL=Set.js.map
2564725647

25648+
/***/ }),
25649+
25650+
/***/ 694:
25651+
/***/ (function(__unusedmodule, exports) {
25652+
25653+
"use strict";
25654+
25655+
Object.defineProperty(exports, "__esModule", { value: true });
25656+
exports.INPUT_VERSION = 'version';
25657+
exports.INPUT_JAVA_VERSION = 'java-version';
25658+
exports.INPUT_ARCHITECTURE = 'architecture';
25659+
exports.INPUT_JAVA_PACKAGE = 'java-package';
25660+
exports.INPUT_JDK_FILE = 'jdkFile';
25661+
exports.INPUT_SERVER_ID = 'server-id';
25662+
exports.INPUT_SERVER_USERNAME = 'server-username';
25663+
exports.INPUT_SERVER_PASSWORD = 'server-password';
25664+
exports.INPUT_GPG_PRIVATE_KEY = 'gpg-private-key';
25665+
exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase';
25666+
exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
25667+
exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint';
25668+
25669+
2564825670
/***/ }),
2564925671

2565025672
/***/ 695:
@@ -28650,40 +28672,46 @@ const core = __importStar(__webpack_require__(470));
2865028672
const installer = __importStar(__webpack_require__(923));
2865128673
const auth = __importStar(__webpack_require__(331));
2865228674
const gpg = __importStar(__webpack_require__(884));
28675+
const constants = __importStar(__webpack_require__(694));
2865328676
const path = __importStar(__webpack_require__(622));
28654-
const DEFAULT_ID = 'github';
28655-
const DEFAULT_USERNAME = 'GITHUB_ACTOR';
28656-
const DEFAULT_PASSWORD = 'GITHUB_TOKEN';
28657-
const DEFAULT_GPG_PRIVATE_KEY = undefined;
28658-
const DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
2865928677
function run() {
2866028678
return __awaiter(this, void 0, void 0, function* () {
2866128679
try {
28662-
let version = core.getInput('version');
28680+
let version = core.getInput(constants.INPUT_VERSION);
2866328681
if (!version) {
28664-
version = core.getInput('java-version', { required: true });
28682+
version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true });
2866528683
}
28666-
const arch = core.getInput('architecture', { required: true });
28667-
const javaPackage = core.getInput('java-package', { required: true });
28668-
const jdkFile = core.getInput('jdkFile', { required: false }) || '';
28684+
const arch = core.getInput(constants.INPUT_ARCHITECTURE, { required: true });
28685+
const javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
28686+
required: true
28687+
});
28688+
const jdkFile = core.getInput(constants.INPUT_JDK_FILE, { required: false });
2866928689
yield installer.getJava(version, arch, jdkFile, javaPackage);
2867028690
const matchersPath = path.join(__dirname, '..', '..', '.github');
28671-
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
28672-
const id = core.getInput('server-id', { required: false }) || DEFAULT_ID;
28673-
const username = core.getInput('server-username', { required: false }) || DEFAULT_USERNAME;
28674-
const password = core.getInput('server-password', { required: false }) || DEFAULT_PASSWORD;
28675-
const gpgPrivateKey = core.getInput('gpg-private-key', { required: false }) ||
28676-
DEFAULT_GPG_PRIVATE_KEY;
28677-
const gpgPassphrase = core.getInput('gpg-passphrase', { required: false }) ||
28678-
(gpgPrivateKey ? DEFAULT_GPG_PASSPHRASE : undefined);
28691+
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
28692+
const id = core.getInput(constants.INPUT_SERVER_ID, { required: false });
28693+
const username = core.getInput(constants.INPUT_SERVER_USERNAME, {
28694+
required: false
28695+
});
28696+
const password = core.getInput(constants.INPUT_SERVER_PASSWORD, {
28697+
required: false
28698+
});
28699+
const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY, {
28700+
required: false
28701+
});
28702+
const gpgPassphrase = core.getInput(constants.INPUT_GPG_PASSPHRASE, { required: false }) ||
28703+
(gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined);
2867928704
if (gpgPrivateKey) {
2868028705
core.setSecret(gpgPrivateKey);
2868128706
}
28707+
if (gpgPassphrase) {
28708+
core.setSecret(gpgPassphrase);
28709+
}
2868228710
yield auth.configAuthentication(id, username, password, gpgPassphrase);
2868328711
if (gpgPrivateKey) {
28684-
console.log('importing private key');
28712+
core.info('importing private key');
2868528713
const keyFingerprint = (yield gpg.importKey(gpgPrivateKey)) || '';
28686-
core.saveState('gpg-private-key-fingerprint', keyFingerprint);
28714+
core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint);
2868728715
}
2868828716
}
2868928717
catch (error) {

src/cleanup-java.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import * as core from '@actions/core';
22
import * as gpg from './gpg';
3+
import * as constants from './constants';
34

45
async function run() {
5-
if (core.getInput('gpg-private-key', {required: false})) {
6-
console.log('removing private key from keychain');
6+
if (core.getInput(constants.INPUT_GPG_PRIVATE_KEY, {required: false})) {
7+
core.info('removing private key from keychain');
78
try {
8-
const keyFingerprint = core.getState('gpg-private-key-fingerprint');
9+
const keyFingerprint = core.getState(
10+
constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT
11+
);
912
await gpg.deleteKey(keyFingerprint);
1013
} catch (error) {
1114
core.setFailed(error.message);

src/constants.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const INPUT_VERSION = 'version';
2+
export const INPUT_JAVA_VERSION = 'java-version';
3+
export const INPUT_ARCHITECTURE = 'architecture';
4+
export const INPUT_JAVA_PACKAGE = 'java-package';
5+
export const INPUT_JDK_FILE = 'jdkFile';
6+
export const INPUT_SERVER_ID = 'server-id';
7+
export const INPUT_SERVER_USERNAME = 'server-username';
8+
export const INPUT_SERVER_PASSWORD = 'server-password';
9+
export const INPUT_GPG_PRIVATE_KEY = 'gpg-private-key';
10+
export const INPUT_GPG_PASSPHRASE = 'gpg-passphrase';
11+
12+
export const INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
13+
14+
export const STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint';

src/setup-java.ts

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,57 @@ import * as core from '@actions/core';
22
import * as installer from './installer';
33
import * as auth from './auth';
44
import * as gpg from './gpg';
5+
import * as constants from './constants';
56
import * as path from 'path';
67

7-
const DEFAULT_ID = 'github';
8-
const DEFAULT_USERNAME = 'GITHUB_ACTOR';
9-
const DEFAULT_PASSWORD = 'GITHUB_TOKEN';
10-
const DEFAULT_GPG_PRIVATE_KEY = undefined;
11-
const DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
12-
138
async function run() {
149
try {
15-
let version = core.getInput('version');
10+
let version = core.getInput(constants.INPUT_VERSION);
1611
if (!version) {
17-
version = core.getInput('java-version', {required: true});
12+
version = core.getInput(constants.INPUT_JAVA_VERSION, {required: true});
1813
}
19-
const arch = core.getInput('architecture', {required: true});
20-
const javaPackage = core.getInput('java-package', {required: true});
21-
const jdkFile = core.getInput('jdkFile', {required: false}) || '';
14+
const arch = core.getInput(constants.INPUT_ARCHITECTURE, {required: true});
15+
const javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
16+
required: true
17+
});
18+
const jdkFile = core.getInput(constants.INPUT_JDK_FILE, {required: false});
2219

2320
await installer.getJava(version, arch, jdkFile, javaPackage);
2421

2522
const matchersPath = path.join(__dirname, '..', '..', '.github');
26-
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
27-
28-
const id = core.getInput('server-id', {required: false}) || DEFAULT_ID;
29-
const username =
30-
core.getInput('server-username', {required: false}) || DEFAULT_USERNAME;
31-
const password =
32-
core.getInput('server-password', {required: false}) || DEFAULT_PASSWORD;
33-
const gpgPrivateKey =
34-
core.getInput('gpg-private-key', {required: false}) ||
35-
DEFAULT_GPG_PRIVATE_KEY;
23+
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
24+
25+
const id = core.getInput(constants.INPUT_SERVER_ID, {required: false});
26+
const username = core.getInput(constants.INPUT_SERVER_USERNAME, {
27+
required: false
28+
});
29+
const password = core.getInput(constants.INPUT_SERVER_PASSWORD, {
30+
required: false
31+
});
32+
const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY, {
33+
required: false
34+
});
3635
const gpgPassphrase =
37-
core.getInput('gpg-passphrase', {required: false}) ||
38-
(gpgPrivateKey ? DEFAULT_GPG_PASSPHRASE : undefined);
36+
core.getInput(constants.INPUT_GPG_PASSPHRASE, {required: false}) ||
37+
(gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined);
3938

4039
if (gpgPrivateKey) {
4140
core.setSecret(gpgPrivateKey);
4241
}
4342

43+
if (gpgPassphrase) {
44+
core.setSecret(gpgPassphrase);
45+
}
46+
4447
await auth.configAuthentication(id, username, password, gpgPassphrase);
4548

4649
if (gpgPrivateKey) {
47-
console.log('importing private key');
50+
core.info('importing private key');
4851
const keyFingerprint = (await gpg.importKey(gpgPrivateKey)) || '';
49-
core.saveState('gpg-private-key-fingerprint', keyFingerprint);
52+
core.saveState(
53+
constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT,
54+
keyFingerprint
55+
);
5056
}
5157
} catch (error) {
5258
core.setFailed(error.message);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy