mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-23 20:27:02 +08:00
Merge pull request #515 from codecov/specify-version
Allow specifying version of Codecov uploader
This commit is contained in:
16
.github/workflows/main.yml
vendored
16
.github/workflows/main.yml
vendored
@@ -22,6 +22,14 @@ jobs:
|
|||||||
file: ./coverage/coverage-final.json
|
file: ./coverage/coverage-final.json
|
||||||
flags: demo,${{ matrix.os }}
|
flags: demo,${{ matrix.os }}
|
||||||
name: codecov-demo
|
name: codecov-demo
|
||||||
|
- name: Upload coverage to Codecov (version)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
||||||
|
file: ./coverage/coverage-final.json
|
||||||
|
flags: version,${{ matrix.os }}
|
||||||
|
name: codecov-version
|
||||||
|
version: v0.1.0_8880
|
||||||
run:
|
run:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
@@ -49,3 +57,11 @@ jobs:
|
|||||||
file: ./coverage/coverage-final.json
|
file: ./coverage/coverage-final.json
|
||||||
flags: demo,${{ matrix.os }}
|
flags: demo,${{ matrix.os }}
|
||||||
name: codecov-demo
|
name: codecov-demo
|
||||||
|
- name: Upload coverage to Codecov (version)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
||||||
|
file: ./coverage/coverage-final.json
|
||||||
|
flags: version,${{ matrix.os }}
|
||||||
|
name: codecov-version
|
||||||
|
version: v0.1.0_8880
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
## 2.1.0
|
||||||
|
### Features
|
||||||
|
- #515 Allow specifying version of Codecov uploader
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
- #499 build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.30.0
|
||||||
|
- #508 build(deps): bump openpgp from 5.0.0-5 to 5.0.0
|
||||||
|
- #514 build(deps-dev): bump @types/node from 16.6.0 to 16.9.0
|
||||||
|
|
||||||
## 2.0.3
|
## 2.0.3
|
||||||
### Fixes
|
### Fixes
|
||||||
- #464 Fix wrong link in the readme
|
- #464 Fix wrong link in the readme
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`,
|
|||||||
| `slug` | Specify the slug manually (Enterprise use) | Optional
|
| `slug` | Specify the slug manually (Enterprise use) | Optional
|
||||||
| `url` | Change the upload host (Enterprise use) | Optional
|
| `url` | Change the upload host (Enterprise use) | Optional
|
||||||
| `verbose` | Specify whether the Codecov output should be verbose | Optional
|
| `verbose` | Specify whether the Codecov output should be verbose | Optional
|
||||||
|
| `version` | Specify which version of the Codecov Uploader should be used. Defaults to `latest` | Optional
|
||||||
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
|
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
|
||||||
|
|
||||||
### Example `workflow.yml` with Codecov Action
|
### Example `workflow.yml` with Codecov Action
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ inputs:
|
|||||||
verbose:
|
verbose:
|
||||||
description: 'Specify whether the Codecov output should be verbose'
|
description: 'Specify whether the Codecov output should be verbose'
|
||||||
required: false
|
required: false
|
||||||
|
version:
|
||||||
|
description: 'Specify which version of the Codecov Uploader should be used. Defaults to `latest`'
|
||||||
|
required: false
|
||||||
working-directory:
|
working-directory:
|
||||||
description: 'Directory in which to execute codecov.sh'
|
description: 'Directory in which to execute codecov.sh'
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
106
dist/index.js
vendored
106
dist/index.js
vendored
@@ -134,7 +134,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
||||||
const command_1 = __nccwpck_require__(5241);
|
const command_1 = __nccwpck_require__(5241);
|
||||||
const file_command_1 = __nccwpck_require__(717);
|
const file_command_1 = __nccwpck_require__(717);
|
||||||
const utils_1 = __nccwpck_require__(5278);
|
const utils_1 = __nccwpck_require__(5278);
|
||||||
@@ -312,19 +312,30 @@ exports.debug = debug;
|
|||||||
/**
|
/**
|
||||||
* Adds an error issue
|
* Adds an error issue
|
||||||
* @param message error issue message. Errors will be converted to string via toString()
|
* @param message error issue message. Errors will be converted to string via toString()
|
||||||
|
* @param properties optional properties to add to the annotation.
|
||||||
*/
|
*/
|
||||||
function error(message) {
|
function error(message, properties = {}) {
|
||||||
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports.error = error;
|
exports.error = error;
|
||||||
/**
|
/**
|
||||||
* Adds an warning issue
|
* Adds a warning issue
|
||||||
* @param message warning issue message. Errors will be converted to string via toString()
|
* @param message warning issue message. Errors will be converted to string via toString()
|
||||||
|
* @param properties optional properties to add to the annotation.
|
||||||
*/
|
*/
|
||||||
function warning(message) {
|
function warning(message, properties = {}) {
|
||||||
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports.warning = warning;
|
exports.warning = warning;
|
||||||
|
/**
|
||||||
|
* Adds a notice issue
|
||||||
|
* @param message notice issue message. Errors will be converted to string via toString()
|
||||||
|
* @param properties optional properties to add to the annotation.
|
||||||
|
*/
|
||||||
|
function notice(message, properties = {}) {
|
||||||
|
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||||
|
}
|
||||||
|
exports.notice = notice;
|
||||||
/**
|
/**
|
||||||
* Writes info to log with console.log.
|
* Writes info to log with console.log.
|
||||||
* @param message info message
|
* @param message info message
|
||||||
@@ -458,7 +469,7 @@ exports.issueCommand = issueCommand;
|
|||||||
// We use any as a valid input type
|
// We use any as a valid input type
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.toCommandValue = void 0;
|
exports.toCommandProperties = exports.toCommandValue = void 0;
|
||||||
/**
|
/**
|
||||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||||
* @param input input to sanitize into a string
|
* @param input input to sanitize into a string
|
||||||
@@ -473,6 +484,25 @@ function toCommandValue(input) {
|
|||||||
return JSON.stringify(input);
|
return JSON.stringify(input);
|
||||||
}
|
}
|
||||||
exports.toCommandValue = toCommandValue;
|
exports.toCommandValue = toCommandValue;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param annotationProperties
|
||||||
|
* @returns The command properties to send with the actual annotation command
|
||||||
|
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
|
||||||
|
*/
|
||||||
|
function toCommandProperties(annotationProperties) {
|
||||||
|
if (!Object.keys(annotationProperties).length) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
title: annotationProperties.title,
|
||||||
|
line: annotationProperties.startLine,
|
||||||
|
endLine: annotationProperties.endLine,
|
||||||
|
col: annotationProperties.startColumn,
|
||||||
|
endColumn: annotationProperties.endColumn
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.toCommandProperties = toCommandProperties;
|
||||||
//# sourceMappingURL=utils.js.map
|
//# sourceMappingURL=utils.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -12829,7 +12859,7 @@ function wrappy (fn, cb) {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 3997:
|
/***/ 5765:
|
||||||
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
|
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -12849,7 +12879,7 @@ var core = __nccwpck_require__(2186);
|
|||||||
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
|
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
|
||||||
var github = __nccwpck_require__(5438);
|
var github = __nccwpck_require__(5438);
|
||||||
;// CONCATENATED MODULE: ./package.json
|
;// CONCATENATED MODULE: ./package.json
|
||||||
const package_namespaceObject = {"i8":"2.0.3"};
|
const package_namespaceObject = {"i8":"2.1.0"};
|
||||||
;// CONCATENATED MODULE: ./src/buildExec.ts
|
;// CONCATENATED MODULE: ./src/buildExec.ts
|
||||||
|
|
||||||
|
|
||||||
@@ -12884,8 +12914,9 @@ const buildExec = () => {
|
|||||||
const searchDir = core.getInput('directory');
|
const searchDir = core.getInput('directory');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const verbose = isTrue(core.getInput('verbose'));
|
let uploaderVersion = core.getInput('version');
|
||||||
const url = core.getInput('url');
|
const url = core.getInput('url');
|
||||||
|
const verbose = isTrue(core.getInput('verbose'));
|
||||||
const workingDir = core.getInput('working-directory');
|
const workingDir = core.getInput('working-directory');
|
||||||
const execArgs = [];
|
const execArgs = [];
|
||||||
execArgs.push('-n', `${name}`, '-Q', `github-action-${package_namespaceObject.i8}`);
|
execArgs.push('-n', `${name}`, '-Q', `github-action-${package_namespaceObject.i8}`);
|
||||||
@@ -12982,7 +13013,10 @@ const buildExec = () => {
|
|||||||
if (workingDir) {
|
if (workingDir) {
|
||||||
options.cwd = workingDir;
|
options.cwd = workingDir;
|
||||||
}
|
}
|
||||||
return { execArgs, options, failCi, os };
|
if (uploaderVersion == '') {
|
||||||
|
uploaderVersion = 'latest';
|
||||||
|
}
|
||||||
|
return { execArgs, options, failCi, os, uploaderVersion };
|
||||||
};
|
};
|
||||||
/* harmony default export */ const src_buildExec = (buildExec);
|
/* harmony default export */ const src_buildExec = (buildExec);
|
||||||
|
|
||||||
@@ -13023,8 +13057,8 @@ const getPlatform = (os) => {
|
|||||||
core.info('==> Could not detect OS or provided OS is invalid. Defaulting to linux');
|
core.info('==> Could not detect OS or provided OS is invalid. Defaulting to linux');
|
||||||
return 'linux';
|
return 'linux';
|
||||||
};
|
};
|
||||||
const getBaseUrl = (platform) => {
|
const getBaseUrl = (platform, version) => {
|
||||||
return `https://uploader.codecov.io/latest/${platform}/${getUploaderName(platform)}`;
|
return `https://uploader.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -13051,15 +13085,16 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const verify = (filename, platform) => __awaiter(void 0, void 0, void 0, function* () {
|
const verify = (filename, platform, version) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const uploaderName = getUploaderName(platform);
|
const uploaderName = getUploaderName(platform);
|
||||||
// Read in public key
|
// Read in public key
|
||||||
const publicKeyArmored = yield external_fs_.readFileSync(__nccwpck_require__.ab + "pgp_keys.asc", 'utf-8');
|
const publicKeyArmored = yield external_fs_.readFileSync(__nccwpck_require__.ab + "pgp_keys.asc", 'utf-8');
|
||||||
// Get SHASUM and SHASUM signature files
|
// Get SHASUM and SHASUM signature files
|
||||||
const shasumRes = yield lib(`${getBaseUrl(platform)}.SHA256SUM`);
|
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
|
||||||
|
const shasumRes = yield lib(`${getBaseUrl(platform, version)}.SHA256SUM`);
|
||||||
const shasum = yield shasumRes.text();
|
const shasum = yield shasumRes.text();
|
||||||
const shaSigRes = yield lib(`${getBaseUrl(platform)}.SHA256SUM.sig`);
|
const shaSigRes = yield lib(`${getBaseUrl(platform, version)}.SHA256SUM.sig`);
|
||||||
const shaSig = yield shaSigRes.text();
|
const shaSig = yield shaSigRes.text();
|
||||||
// Verify shasum
|
// Verify shasum
|
||||||
const verified = yield openpgp_min/* verify */.T({
|
const verified = yield openpgp_min/* verify */.T({
|
||||||
@@ -13099,6 +13134,35 @@ const verify = (filename, platform) => __awaiter(void 0, void 0, void 0, functio
|
|||||||
});
|
});
|
||||||
/* harmony default export */ const validate = (verify);
|
/* harmony default export */ const validate = (verify);
|
||||||
|
|
||||||
|
;// CONCATENATED MODULE: ./src/version.ts
|
||||||
|
var version_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const versionInfo = (platform, version) => version_awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
if (version) {
|
||||||
|
core.info(`==> Running version ${version}`);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const metadataRes = yield lib(`https://uploader.codecov.io/${platform}/latest`, {
|
||||||
|
headers: { 'Accept': 'application/json' },
|
||||||
|
});
|
||||||
|
const metadata = yield metadataRes.json();
|
||||||
|
core.info(`==> Running version ${metadata['version']}`);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
core.info(`Could not pull latest version information: ${err}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
/* harmony default export */ const version = (versionInfo);
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./src/index.ts
|
;// CONCATENATED MODULE: ./src/index.ts
|
||||||
var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
@@ -13116,12 +13180,13 @@ var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argu
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let failCi;
|
let failCi;
|
||||||
try {
|
try {
|
||||||
const { execArgs, options, failCi, os } = src_buildExec();
|
const { execArgs, options, failCi, os, uploaderVersion } = src_buildExec();
|
||||||
const platform = getPlatform(os);
|
const platform = getPlatform(os);
|
||||||
const filename = external_path_.join(__dirname, getUploaderName(platform));
|
const filename = external_path_.join(__dirname, getUploaderName(platform));
|
||||||
external_https_.get(getBaseUrl(platform), (res) => {
|
external_https_.get(getBaseUrl(platform, uploaderVersion), (res) => {
|
||||||
// Image will be stored at this path
|
// Image will be stored at this path
|
||||||
const filePath = external_fs_.createWriteStream(filename);
|
const filePath = external_fs_.createWriteStream(filename);
|
||||||
res.pipe(filePath);
|
res.pipe(filePath);
|
||||||
@@ -13130,7 +13195,8 @@ try {
|
|||||||
setFailure(`Codecov: Failed to write uploader binary: ${err.message}`, true);
|
setFailure(`Codecov: Failed to write uploader binary: ${err.message}`, true);
|
||||||
}).on('finish', () => src_awaiter(void 0, void 0, void 0, function* () {
|
}).on('finish', () => src_awaiter(void 0, void 0, void 0, function* () {
|
||||||
filePath.close();
|
filePath.close();
|
||||||
yield validate(filename, platform);
|
yield validate(filename, platform, uploaderVersion);
|
||||||
|
yield version(platform, uploaderVersion);
|
||||||
yield external_fs_.chmodSync(filename, '777');
|
yield external_fs_.chmodSync(filename, '777');
|
||||||
const unlink = () => {
|
const unlink = () => {
|
||||||
external_fs_.unlink(filename, (err) => {
|
external_fs_.unlink(filename, (err) => {
|
||||||
@@ -13372,7 +13438,7 @@ module.exports = require("zlib");
|
|||||||
/******/ // startup
|
/******/ // startup
|
||||||
/******/ // Load entry module and return exports
|
/******/ // Load entry module and return exports
|
||||||
/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined
|
/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined
|
||||||
/******/ var __webpack_exports__ = __nccwpck_require__(3997);
|
/******/ var __webpack_exports__ = __nccwpck_require__(5765);
|
||||||
/******/ module.exports = __webpack_exports__;
|
/******/ module.exports = __webpack_exports__;
|
||||||
/******/
|
/******/
|
||||||
/******/ })()
|
/******/ })()
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "2.0.3",
|
"version": "2.1.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "2.0.3",
|
"version": "2.1.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.5.0",
|
"@actions/core": "^1.5.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "2.0.3",
|
"version": "2.1.0",
|
||||||
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ const buildExec = () => {
|
|||||||
const searchDir = core.getInput('directory');
|
const searchDir = core.getInput('directory');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const verbose = isTrue(core.getInput('verbose'));
|
let uploaderVersion = core.getInput('version');
|
||||||
const url = core.getInput('url');
|
const url = core.getInput('url');
|
||||||
|
const verbose = isTrue(core.getInput('verbose'));
|
||||||
const workingDir = core.getInput('working-directory');
|
const workingDir = core.getInput('working-directory');
|
||||||
|
|
||||||
const execArgs = [];
|
const execArgs = [];
|
||||||
@@ -147,7 +148,11 @@ const buildExec = () => {
|
|||||||
options.cwd = workingDir;
|
options.cwd = workingDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {execArgs, options, failCi, os};
|
if (uploaderVersion == '') {
|
||||||
|
uploaderVersion = 'latest';
|
||||||
|
}
|
||||||
|
|
||||||
|
return {execArgs, options, failCi, os, uploaderVersion};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default buildExec;
|
export default buildExec;
|
||||||
|
|||||||
@@ -37,13 +37,22 @@ test('getPlatform', () => {
|
|||||||
|
|
||||||
test('getBaseUrl', () => {
|
test('getBaseUrl', () => {
|
||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
return getBaseUrl(platform);
|
return getBaseUrl(platform, 'latest');
|
||||||
})).toEqual([
|
})).toEqual([
|
||||||
'https://uploader.codecov.io/latest/alpine/codecov',
|
'https://uploader.codecov.io/latest/alpine/codecov',
|
||||||
'https://uploader.codecov.io/latest/linux/codecov',
|
'https://uploader.codecov.io/latest/linux/codecov',
|
||||||
'https://uploader.codecov.io/latest/macos/codecov',
|
'https://uploader.codecov.io/latest/macos/codecov',
|
||||||
'https://uploader.codecov.io/latest/windows/codecov.exe',
|
'https://uploader.codecov.io/latest/windows/codecov.exe',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
expect(PLATFORMS.map((platform) => {
|
||||||
|
return getBaseUrl(platform, 'v0.1.0_8880');
|
||||||
|
})).toEqual([
|
||||||
|
'https://uploader.codecov.io/v0.1.0_8880/alpine/codecov',
|
||||||
|
'https://uploader.codecov.io/v0.1.0_8880/linux/codecov',
|
||||||
|
'https://uploader.codecov.io/v0.1.0_8880/macos/codecov',
|
||||||
|
'https://uploader.codecov.io/v0.1.0_8880/windows/codecov.exe',
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('isWindows', () => {
|
test('isWindows', () => {
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ const getPlatform = (os?: string): string => {
|
|||||||
return 'linux';
|
return 'linux';
|
||||||
};
|
};
|
||||||
|
|
||||||
const getBaseUrl = (platform: string): string => {
|
const getBaseUrl = (platform: string, version: string): string => {
|
||||||
return `https://uploader.codecov.io/latest/${platform}/${getUploaderName(platform)}`;
|
return `https://uploader.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|||||||
@@ -13,15 +13,16 @@ import {
|
|||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
import verify from './validate';
|
import verify from './validate';
|
||||||
|
import versionInfo from './version';
|
||||||
|
|
||||||
let failCi;
|
let failCi;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {execArgs, options, failCi, os} = buildExec();
|
const {execArgs, options, failCi, os, uploaderVersion} = buildExec();
|
||||||
const platform = getPlatform(os);
|
const platform = getPlatform(os);
|
||||||
|
|
||||||
const filename = path.join( __dirname, getUploaderName(platform));
|
const filename = path.join( __dirname, getUploaderName(platform));
|
||||||
https.get(getBaseUrl(platform), (res) => {
|
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
|
||||||
// Image will be stored at this path
|
// Image will be stored at this path
|
||||||
const filePath = fs.createWriteStream(filename);
|
const filePath = fs.createWriteStream(filename);
|
||||||
res.pipe(filePath);
|
res.pipe(filePath);
|
||||||
@@ -34,7 +35,8 @@ try {
|
|||||||
}).on('finish', async () => {
|
}).on('finish', async () => {
|
||||||
filePath.close();
|
filePath.close();
|
||||||
|
|
||||||
await verify(filename, platform);
|
await verify(filename, platform, uploaderVersion);
|
||||||
|
await versionInfo(platform, uploaderVersion);
|
||||||
await fs.chmodSync(filename, '777');
|
await fs.chmodSync(filename, '777');
|
||||||
|
|
||||||
const unlink = () => {
|
const unlink = () => {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
setFailure,
|
setFailure,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
const verify = async (filename: string, platform: string) => {
|
const verify = async (filename: string, platform: string, version: string) => {
|
||||||
try {
|
try {
|
||||||
const uploaderName = getUploaderName(platform);
|
const uploaderName = getUploaderName(platform);
|
||||||
|
|
||||||
@@ -23,10 +23,15 @@ const verify = async (filename: string, platform: string) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Get SHASUM and SHASUM signature files
|
// Get SHASUM and SHASUM signature files
|
||||||
const shasumRes = await fetch( `${getBaseUrl(platform)}.SHA256SUM`);
|
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
|
||||||
|
const shasumRes = await fetch(
|
||||||
|
`${getBaseUrl(platform, version)}.SHA256SUM`,
|
||||||
|
);
|
||||||
const shasum = await shasumRes.text();
|
const shasum = await shasumRes.text();
|
||||||
|
|
||||||
const shaSigRes = await fetch( `${getBaseUrl(platform)}.SHA256SUM.sig`);
|
const shaSigRes = await fetch(
|
||||||
|
`${getBaseUrl(platform, version)}.SHA256SUM.sig`,
|
||||||
|
);
|
||||||
const shaSig = await shaSigRes.text();
|
const shaSig = await shaSigRes.text();
|
||||||
|
|
||||||
// Verify shasum
|
// Verify shasum
|
||||||
|
|||||||
19
src/version.ts
Normal file
19
src/version.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as fetch from 'node-fetch';
|
||||||
|
|
||||||
|
const versionInfo = async (platform: string, version?: string) => {
|
||||||
|
if (version) {
|
||||||
|
core.info(`==> Running version ${version}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const metadataRes = await fetch( `https://uploader.codecov.io/${platform}/latest`, {
|
||||||
|
headers: {'Accept': 'application/json'},
|
||||||
|
});
|
||||||
|
const metadata = await metadataRes.json();
|
||||||
|
core.info(`==> Running version ${metadata['version']}`);
|
||||||
|
} catch (err) {
|
||||||
|
core.info(`Could not pull latest version information: ${err}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export default versionInfo;
|
||||||
Reference in New Issue
Block a user