diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 0e705c2..66edd6b 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -10,46 +10,11 @@ on: - cron: '0 0 * * *' # daily at 00:00 UTC jobs: - test-latest-versions: - strategy: - matrix: - version: - - latest - - '*' - - '' - - '0.1.1' - skip-cache: - - true - - false - uses: ./.github/workflows/test-marathon-cloud.yaml - with: - version: ${{ matrix.version }} - skip-cache: ${{ matrix.skip-cache }} - with-github-token: 'true' - secrets: inherit - test-specified-versions-no-github-token: strategy: matrix: version: - - '0.1.0' - - '0.1.1' - skip-cache: - - true - - false - uses: ./.github/workflows/test-marathon-cloud.yaml - with: - version: ${{ matrix.version }} - skip-cache: ${{ matrix.skip-cache }} - with-github-token: 'false' - secrets: inherit - - test-specified-versions-with-github-token: - strategy: - matrix: - version: - - '0.1.0' - - '0.1.1' + - '1.0.0' skip-cache: - true - false @@ -57,5 +22,4 @@ jobs: with: version: ${{ matrix.version }} skip-cache: ${{ matrix.skip-cache }} - with-github-token: 'true' secrets: inherit diff --git a/.github/workflows/test-marathon-cloud.yaml b/.github/workflows/test-marathon-cloud.yaml index bab4c2b..c3565d1 100644 --- a/.github/workflows/test-marathon-cloud.yaml +++ b/.github/workflows/test-marathon-cloud.yaml @@ -7,15 +7,10 @@ on: version: description: 'marathon-cloud version to use' required: true - default: '*' skip-cache: description: 'skip cache?' required: false default: 'false' - with-github-token: - description: 'with github token?' - required: false - default: 'true' # for integration testing workflow_call: inputs: @@ -23,42 +18,12 @@ on: type: string description: 'marathon-cloud version to use' required: true - default: '*' skip-cache: type: string description: 'skip cache?' required: false default: 'false' - with-github-token: - type: string - description: 'with github token?' - required: false - default: 'true' - jobs: - test-with-github-token: - strategy: - matrix: - # TODO(hbc): add ARM64 runners - os: [ubuntu-latest, macos-latest, windows-latest] - runs-on: ${{ matrix.os }} - if: ${{ inputs.with-github-token == 'true' }} - - steps: - - uses: actions/checkout@v3 - name: Checkout code - - uses: ./ # use current branch - name: Setup marathon-cloud - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ACTIONS_STEP_DEBUG: true - with: - version: ${{ inputs.version }} - skip-cache: ${{ inputs.skip-cache }} - - run: | - marathon-cloud --help - name: Invoke marathon-cloud - test-without-github-token: strategy: matrix: diff --git a/lib/index.js b/lib/index.js index 486468a..6195f03 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6587,59 +6587,14 @@ exports["default"] = _default; /***/ }), /***/ 1772: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ ((__unused_webpack_module, exports) => { "use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__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()); - }); -}; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.releaseArtifactURL = exports.resolveLatestVersion = exports.isLatestVersion = void 0; -const core = __importStar(__nccwpck_require__(2186)); +exports.releaseArtifactURL = void 0; const REPO_OWNER = 'MarathonLabs'; const REPO = 'marathon-cloud-cli'; -function isLatestVersion(version) { - const v = version.toLowerCase(); - return v === 'latest' || v === '*' || v === ''; -} -exports.isLatestVersion = isLatestVersion; -function resolveLatestVersion() { - return __awaiter(this, void 0, void 0, function* () { - core.warning(`setup-marathon-cloud@v1 supports marathon-cloud cli up to 0.3.X. To use marathon-cloud cli v1+ use setup-marathon-cloud@v2`); - return '0.3.11'; - }); -} -exports.resolveLatestVersion = resolveLatestVersion; function releaseArtifactURL(paths) { return `https://github.com/${REPO_OWNER}/${REPO}/releases/download/${paths.join('/')}`; } @@ -6762,16 +6717,16 @@ function resolvePlatform() { const platform = process.platform; const arch = process.arch; if (platform === 'darwin') { - return 'darwin_all'; + return 'universal-apple-darwin'; } else if (platform === 'linux' && arch === 'x64') { - return 'linux_amd64'; + return 'x86_64-unknown-linux-gnu'; } else if (platform === 'linux' && arch === 'arm64') { - return 'linux_arm64'; + return 'aarch64-unknown-linux-gnu'; } else if (platform === 'win32' && arch === 'x64') { - return 'windows_amd64'; + return 'x86_64-pc-windows-msvc'; } else { throw new Error(`Unsupported platform: ${platform}_${arch}`); @@ -6780,21 +6735,16 @@ function resolvePlatform() { // getReleaseArtifact retrieves a release artifact with specified version and platform. // platform is resolved automatically if not specified. function getReleaseArtifact(version, platform) { - return __awaiter(this, void 0, void 0, function* () { - if ((0, gh_1.isLatestVersion)(version)) { - version = yield (0, gh_1.resolveLatestVersion)(); - } - platform = platform || resolvePlatform(); - const extension = resolveExtension(platform); - const artifactName = `${TOOL_NAME}_${platform}-${version}.${extension}`; - return { - version, - platform, - artifactName, - artifactUrl: (0, gh_1.releaseArtifactURL)([version, artifactName]), - checksumUrl: (0, gh_1.releaseArtifactURL)([version, `checksums.txt`]), - }; - }); + platform = platform || resolvePlatform(); + const extension = resolveExtension(platform); + const artifactName = `${TOOL_NAME}-v${version}-${platform}.${extension}`; + return { + version, + platform, + artifactName, + artifactUrl: (0, gh_1.releaseArtifactURL)([version, artifactName]), + checksumUrl: (0, gh_1.releaseArtifactURL)([version, `checksums.txt`]), + }; } exports.getReleaseArtifact = getReleaseArtifact; function resolveBinaryPath(artifact, dir) { @@ -6835,11 +6785,13 @@ function downloadAndCache(artifact) { core.debug(`Downloaded ${artifact.checksumUrl} to ${artifactChecksum}`); yield verifyChecksum(artifactZipball, artifact.artifactName, artifactChecksum); core.debug(`Verified checksum of ${artifactZipball}`); - const artifactFolder = os_1.platform.name.startsWith('win') + const extractedPath = os_1.platform.name.startsWith('win') ? yield tc.extractZip(artifactZipball) : yield tc.extractTar(artifactZipball); - core.debug(`Extracted ${artifactZipball} to ${artifactFolder}`); - const cachedDir = yield tc.cacheDir(artifactFolder, TOOL_NAME, artifact.version); + core.debug(`Extracted ${artifactZipball} to ${extractedPath}`); + const archiveName = fs.readdirSync(extractedPath)[0]; + const archivePath = path_1.default.join(extractedPath, archiveName); + const cachedDir = yield tc.cacheDir(archivePath, TOOL_NAME, artifact.version); const rv = resolveBinaryPath(artifact, cachedDir); core.debug(`Cached ${TOOL_NAME} to ${rv}`); return rv; @@ -6868,7 +6820,9 @@ function setupArtifact(artifact, skipCache) { exports.setupArtifact = setupArtifact; function resolveExtension(platform) { switch (platform) { - case 'windows_amd64': + case 'x86_64-pc-windows-gnu': + case 'x86_64-pc-windows-msvc': + case 'i686-pc-windows-msvc': return 'zip'; default: return 'tar.gz'; @@ -6918,6 +6872,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", ({ value: true })); const core = __importStar(__nccwpck_require__(2186)); const release_1 = __nccwpck_require__(7776); +const semver_1 = __nccwpck_require__(8593); const inputNameVersion = 'version'; const inputNameSkipCache = 'skip-cache'; function main() { @@ -6925,9 +6880,14 @@ function main() { const version = core.getInput(inputNameVersion); const skipCache = core.getInput(inputNameSkipCache) === 'true'; core.debug(`version: ${version} skip-cache: ${skipCache}`); - const artifact = yield (0, release_1.getReleaseArtifact)(version); - core.debug(`Resolved artifact: ${JSON.stringify(artifact)}`); - yield (0, release_1.setupArtifact)(artifact, skipCache); + if ((0, semver_1.validateMajorVersion)(version, '1')) { + const artifact = yield (0, release_1.getReleaseArtifact)(version); + core.debug(`Resolved artifact: ${JSON.stringify(artifact)}`); + yield (0, release_1.setupArtifact)(artifact, skipCache); + } + else { + core.setFailed(`Unsupported cli version ${version}. This action supports version ${1}`); + } }); } try { @@ -6938,6 +6898,22 @@ catch (e) { } +/***/ }), + +/***/ 8593: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.validateMajorVersion = void 0; +function validateMajorVersion(versionString, supported) { + const majorVersion = versionString.split('.')[0]; + return majorVersion === supported; +} +exports.validateMajorVersion = validateMajorVersion; + + /***/ }), /***/ 9491: diff --git a/package-lock.json b/package-lock.json index 316cc49..97f6f0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,13 +16,13 @@ "devDependencies": { "@types/jest": "^29.5.12", "@types/node": "^20.11.16", - "@typescript-eslint/eslint-plugin": "^6.20.0", - "@typescript-eslint/parser": "^6.20.0", + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", "@vercel/ncc": "^0.38.1", "eslint": "^8.56.0", "husky": "^9.0.10", "jest": "^29.7.0", - "prettier": "^3.2.4", + "prettier": "^3.2.5", "pretty-quick": "^4.0.0", "ts-jest": "^29.1.2", "typescript": "^5.3.3" @@ -1601,16 +1601,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.20.0.tgz", - "integrity": "sha512-fTwGQUnjhoYHeSF6m5pWNkzmDDdsKELYrOBxhjMrofPqCkoC2k3B2wvGHFxa1CTIqkEn88nlW1HVMztjo2K8Hg==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz", + "integrity": "sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.20.0", - "@typescript-eslint/type-utils": "6.20.0", - "@typescript-eslint/utils": "6.20.0", - "@typescript-eslint/visitor-keys": "6.20.0", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/type-utils": "6.21.0", + "@typescript-eslint/utils": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -1651,15 +1651,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.20.0.tgz", - "integrity": "sha512-bYerPDF/H5v6V76MdMYhjwmwgMA+jlPVqjSDq2cRqMi8bP5sR3Z+RLOiOMad3nsnmDVmn2gAFCyNgh/dIrfP/w==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.21.0.tgz", + "integrity": "sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.20.0", - "@typescript-eslint/types": "6.20.0", - "@typescript-eslint/typescript-estree": "6.20.0", - "@typescript-eslint/visitor-keys": "6.20.0", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4" }, "engines": { @@ -1679,13 +1679,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.20.0.tgz", - "integrity": "sha512-p4rvHQRDTI1tGGMDFQm+GtxP1ZHyAh64WANVoyEcNMpaTFn3ox/3CcgtIlELnRfKzSs/DwYlDccJEtr3O6qBvA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz", + "integrity": "sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.20.0", - "@typescript-eslint/visitor-keys": "6.20.0" + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1696,13 +1696,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.20.0.tgz", - "integrity": "sha512-qnSobiJQb1F5JjN0YDRPHruQTrX7ICsmltXhkV536mp4idGAYrIyr47zF/JmkJtEcAVnIz4gUYJ7gOZa6SmN4g==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz", + "integrity": "sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.20.0", - "@typescript-eslint/utils": "6.20.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/utils": "6.21.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -1723,9 +1723,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.20.0.tgz", - "integrity": "sha512-MM9mfZMAhiN4cOEcUOEx+0HmuaW3WBfukBZPCfwSqFnQy0grXYtngKCqpQN339X3RrwtzspWJrpbrupKYUSBXQ==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.21.0.tgz", + "integrity": "sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1736,13 +1736,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.20.0.tgz", - "integrity": "sha512-RnRya9q5m6YYSpBN7IzKu9FmLcYtErkDkc8/dKv81I9QiLLtVBHrjz+Ev/crAqgMNW2FCsoZF4g2QUylMnJz+g==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz", + "integrity": "sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.20.0", - "@typescript-eslint/visitor-keys": "6.20.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1788,9 +1788,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -1803,17 +1803,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.20.0.tgz", - "integrity": "sha512-/EKuw+kRu2vAqCoDwDCBtDRU6CTKbUmwwI7SH7AashZ+W+7o8eiyy6V2cdOqN49KsTcASWsC5QeghYuRDTyOOg==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.21.0.tgz", + "integrity": "sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.20.0", - "@typescript-eslint/types": "6.20.0", - "@typescript-eslint/typescript-estree": "6.20.0", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", "semver": "^7.5.4" }, "engines": { @@ -1828,9 +1828,9 @@ } }, "node_modules/@typescript-eslint/utils/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -1843,12 +1843,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.20.0.tgz", - "integrity": "sha512-E8Cp98kRe4gKHjJD4NExXKz/zOJ1A2hhZc+IMVD6i7w4yjIvh6VyuRI0gRtxAsXtoC35uGMaQ9rjI2zJaXDEAw==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz", + "integrity": "sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/types": "6.21.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -4408,9 +4408,9 @@ } }, "node_modules/prettier": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.4.tgz", - "integrity": "sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" diff --git a/package.json b/package.json index a5b2ded..3e8f768 100644 --- a/package.json +++ b/package.json @@ -34,13 +34,13 @@ "devDependencies": { "@types/jest": "^29.5.12", "@types/node": "^20.11.16", - "@typescript-eslint/eslint-plugin": "^6.20.0", - "@typescript-eslint/parser": "^6.20.0", + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", "@vercel/ncc": "^0.38.1", "eslint": "^8.56.0", "husky": "^9.0.10", "jest": "^29.7.0", - "prettier": "^3.2.4", + "prettier": "^3.2.5", "pretty-quick": "^4.0.0", "ts-jest": "^29.1.2", "typescript": "^5.3.3" diff --git a/src/release.test.ts b/src/release.test.ts new file mode 100644 index 0000000..a823b61 --- /dev/null +++ b/src/release.test.ts @@ -0,0 +1,24 @@ +import { getReleaseArtifact } from './release'; + +test('getReleaseArtifact', () => { + expect( + getReleaseArtifact('1.0.0', 'universal-apple-darwin').artifactUrl, + ).toBe( + 'https://github.com/MarathonLabs/marathon-cloud-cli/releases/download/1.0.0/marathon-cloud-v1.0.0-universal-apple-darwin.tar.gz', + ); + expect( + getReleaseArtifact('1.0.0', 'x86_64-unknown-linux-gnu').artifactUrl, + ).toBe( + 'https://github.com/MarathonLabs/marathon-cloud-cli/releases/download/1.0.0/marathon-cloud-v1.0.0-x86_64-unknown-linux-gnu.tar.gz', + ); + expect( + getReleaseArtifact('1.0.0', 'aarch64-unknown-linux-gnu').artifactUrl, + ).toBe( + 'https://github.com/MarathonLabs/marathon-cloud-cli/releases/download/1.0.0/marathon-cloud-v1.0.0-aarch64-unknown-linux-gnu.tar.gz', + ); + expect( + getReleaseArtifact('1.0.0', 'x86_64-pc-windows-msvc').artifactUrl, + ).toBe( + 'https://github.com/MarathonLabs/marathon-cloud-cli/releases/download/1.0.0/marathon-cloud-v1.0.0-x86_64-pc-windows-msvc.zip', + ); +}); diff --git a/src/release.ts b/src/release.ts index e2a4e8b..cc5c268 100644 --- a/src/release.ts +++ b/src/release.ts @@ -53,14 +53,14 @@ export interface BinaryArtifact { // getReleaseArtifact retrieves a release artifact with specified version and platform. // platform is resolved automatically if not specified. -export async function getReleaseArtifact( +export function getReleaseArtifact( version: string, platform?: Platform, -): Promise { +): BinaryArtifact { platform = platform || resolvePlatform(); const extension = resolveExtension(platform); - const artifactName = `${TOOL_NAME}_v${version}-${platform}.${extension}`; + const artifactName = `${TOOL_NAME}-v${version}-${platform}.${extension}`; return { version, @@ -128,16 +128,14 @@ async function downloadAndCache(artifact: BinaryArtifact): Promise { ); core.debug(`Verified checksum of ${artifactZipball}`); - const artifactFolder = platform.name.startsWith('win') + const extractedPath = platform.name.startsWith('win') ? await tc.extractZip(artifactZipball) : await tc.extractTar(artifactZipball); - core.debug(`Extracted ${artifactZipball} to ${artifactFolder}`); + core.debug(`Extracted ${artifactZipball} to ${extractedPath}`); + const archiveName = fs.readdirSync(extractedPath)[0]; + const archivePath = path.join(extractedPath, archiveName); - const cachedDir = await tc.cacheDir( - artifactFolder, - TOOL_NAME, - artifact.version, - ); + const cachedDir = await tc.cacheDir(archivePath, TOOL_NAME, artifact.version); const rv = resolveBinaryPath(artifact, cachedDir); core.debug(`Cached ${TOOL_NAME} to ${rv}`); diff --git a/tsconfig.json b/tsconfig.json index 5fc2286..ba64835 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -98,6 +98,6 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */, - }, + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } }