mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-01-31 06:22:49 +08:00
Support toml spec 1.0.0 (#245)
iarna/toml is unmaintained. Replaced by smol-toml which is maintained and has the same api Fixes: #242
This commit is contained in:
parent
4e3dbecc19
commit
b5f58b2abc
@ -6,5 +6,14 @@ readme = "README.md"
|
|||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
||||||
|
[dependency-groups]
|
||||||
|
dev = [
|
||||||
|
"reuse==5.0.2",
|
||||||
|
{include-group = "lint"},
|
||||||
|
]
|
||||||
|
lint = [
|
||||||
|
"flake8==4.0.1",
|
||||||
|
]
|
||||||
|
|
||||||
[tool.uv]
|
[tool.uv]
|
||||||
required-version = "==0.5.14"
|
required-version = "==0.5.14"
|
||||||
|
325
dist/save-cache/index.js
generated
vendored
325
dist/save-cache/index.js
generated
vendored
@ -91444,15 +91444,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|||||||
return result;
|
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 }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.STATE_CACHE_MATCHED_KEY = exports.STATE_CACHE_KEY = void 0;
|
exports.STATE_CACHE_MATCHED_KEY = exports.STATE_CACHE_KEY = void 0;
|
||||||
exports.restoreCache = restoreCache;
|
exports.restoreCache = restoreCache;
|
||||||
@ -91465,71 +91456,65 @@ const exec = __importStar(__nccwpck_require__(5236));
|
|||||||
exports.STATE_CACHE_KEY = "cache-key";
|
exports.STATE_CACHE_KEY = "cache-key";
|
||||||
exports.STATE_CACHE_MATCHED_KEY = "cache-matched-key";
|
exports.STATE_CACHE_MATCHED_KEY = "cache-matched-key";
|
||||||
const CACHE_VERSION = "1";
|
const CACHE_VERSION = "1";
|
||||||
function restoreCache() {
|
async function restoreCache() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
const cacheKey = await computeKeys();
|
||||||
const cacheKey = yield computeKeys();
|
let matchedKey;
|
||||||
let matchedKey;
|
core.info(`Trying to restore uv cache from GitHub Actions cache with key: ${cacheKey}`);
|
||||||
core.info(`Trying to restore uv cache from GitHub Actions cache with key: ${cacheKey}`);
|
try {
|
||||||
try {
|
matchedKey = await cache.restoreCache([inputs_1.cacheLocalPath], cacheKey);
|
||||||
matchedKey = yield cache.restoreCache([inputs_1.cacheLocalPath], cacheKey);
|
}
|
||||||
}
|
catch (err) {
|
||||||
catch (err) {
|
const message = err.message;
|
||||||
const message = err.message;
|
core.warning(message);
|
||||||
core.warning(message);
|
core.setOutput("cache-hit", false);
|
||||||
core.setOutput("cache-hit", false);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
core.saveState(exports.STATE_CACHE_KEY, cacheKey);
|
||||||
core.saveState(exports.STATE_CACHE_KEY, cacheKey);
|
handleMatchResult(matchedKey, cacheKey);
|
||||||
handleMatchResult(matchedKey, cacheKey);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
function computeKeys() {
|
async function computeKeys() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
let cacheDependencyPathHash = "-";
|
||||||
let cacheDependencyPathHash = "-";
|
if (inputs_1.cacheDependencyGlob !== "") {
|
||||||
if (inputs_1.cacheDependencyGlob !== "") {
|
core.info(`Searching files using cache dependency glob: ${inputs_1.cacheDependencyGlob.split("\n").join(",")}`);
|
||||||
core.info(`Searching files using cache dependency glob: ${inputs_1.cacheDependencyGlob.split("\n").join(",")}`);
|
cacheDependencyPathHash += await (0, hash_files_1.hashFiles)(inputs_1.cacheDependencyGlob, true);
|
||||||
cacheDependencyPathHash += yield (0, hash_files_1.hashFiles)(inputs_1.cacheDependencyGlob, true);
|
|
||||||
if (cacheDependencyPathHash === "-") {
|
|
||||||
core.warning(`No file matched to [${inputs_1.cacheDependencyGlob.split("\n").join(",")}]. The cache will never get invalidated. Make sure you have checked out the target repository and configured the cache-dependency-glob input correctly.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cacheDependencyPathHash === "-") {
|
if (cacheDependencyPathHash === "-") {
|
||||||
cacheDependencyPathHash = "-no-dependency-glob";
|
core.warning(`No file matched to [${inputs_1.cacheDependencyGlob.split("\n").join(",")}]. The cache will never get invalidated. Make sure you have checked out the target repository and configured the cache-dependency-glob input correctly.`);
|
||||||
}
|
}
|
||||||
const suffix = inputs_1.cacheSuffix ? `-${inputs_1.cacheSuffix}` : "";
|
}
|
||||||
const pythonVersion = yield getPythonVersion();
|
if (cacheDependencyPathHash === "-") {
|
||||||
return `setup-uv-${CACHE_VERSION}-${(0, platforms_1.getArch)()}-${(0, platforms_1.getPlatform)()}-${pythonVersion}${cacheDependencyPathHash}${suffix}`;
|
cacheDependencyPathHash = "-no-dependency-glob";
|
||||||
});
|
}
|
||||||
|
const suffix = inputs_1.cacheSuffix ? `-${inputs_1.cacheSuffix}` : "";
|
||||||
|
const pythonVersion = await getPythonVersion();
|
||||||
|
return `setup-uv-${CACHE_VERSION}-${(0, platforms_1.getArch)()}-${(0, platforms_1.getPlatform)()}-${pythonVersion}${cacheDependencyPathHash}${suffix}`;
|
||||||
}
|
}
|
||||||
function getPythonVersion() {
|
async function getPythonVersion() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
if (inputs_1.pythonVersion !== "") {
|
||||||
if (inputs_1.pythonVersion !== "") {
|
return inputs_1.pythonVersion;
|
||||||
return inputs_1.pythonVersion;
|
}
|
||||||
}
|
let output = "";
|
||||||
let output = "";
|
const options = {
|
||||||
const options = {
|
silent: !core.isDebug(),
|
||||||
silent: !core.isDebug(),
|
listeners: {
|
||||||
listeners: {
|
stdout: (data) => {
|
||||||
stdout: (data) => {
|
output += data.toString();
|
||||||
output += data.toString();
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
},
|
||||||
try {
|
};
|
||||||
const execArgs = ["python", "find"];
|
try {
|
||||||
yield exec.exec("uv", execArgs, options);
|
const execArgs = ["python", "find"];
|
||||||
const pythonPath = output.trim();
|
await exec.exec("uv", execArgs, options);
|
||||||
output = "";
|
const pythonPath = output.trim();
|
||||||
yield exec.exec(pythonPath, ["--version"], options);
|
output = "";
|
||||||
// output is like "Python 3.8.10"
|
await exec.exec(pythonPath, ["--version"], options);
|
||||||
return output.split(" ")[1].trim();
|
// output is like "Python 3.8.10"
|
||||||
}
|
return output.split(" ")[1].trim();
|
||||||
catch (error) {
|
}
|
||||||
const err = error;
|
catch (error) {
|
||||||
core.debug(`Failed to get python version from uv. Error: ${err.message}`);
|
const err = error;
|
||||||
return "unknown";
|
core.debug(`Failed to get python version from uv. Error: ${err.message}`);
|
||||||
}
|
return "unknown";
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
function handleMatchResult(matchedKey, primaryKey) {
|
function handleMatchResult(matchedKey, primaryKey) {
|
||||||
if (!matchedKey) {
|
if (!matchedKey) {
|
||||||
@ -91583,22 +91568,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|||||||
return result;
|
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());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
||||||
var m = o[Symbol.asyncIterator], i;
|
|
||||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
||||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
||||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.hashFiles = hashFiles;
|
exports.hashFiles = hashFiles;
|
||||||
const crypto = __importStar(__nccwpck_require__(7598));
|
const crypto = __importStar(__nccwpck_require__(7598));
|
||||||
@ -91615,49 +91584,34 @@ const glob_1 = __nccwpck_require__(7206);
|
|||||||
* @param pattern The glob pattern to match files.
|
* @param pattern The glob pattern to match files.
|
||||||
* @param verbose Whether to log the files being hashed.
|
* @param verbose Whether to log the files being hashed.
|
||||||
*/
|
*/
|
||||||
function hashFiles(pattern_1) {
|
async function hashFiles(pattern, verbose = false) {
|
||||||
return __awaiter(this, arguments, void 0, function* (pattern, verbose = false) {
|
const globber = await (0, glob_1.create)(pattern);
|
||||||
var _a, e_1, _b, _c;
|
let hasMatch = false;
|
||||||
const globber = yield (0, glob_1.create)(pattern);
|
const writeDelegate = verbose ? core.info : core.debug;
|
||||||
let hasMatch = false;
|
const result = crypto.createHash("sha256");
|
||||||
const writeDelegate = verbose ? core.info : core.debug;
|
let count = 0;
|
||||||
const result = crypto.createHash("sha256");
|
for await (const file of globber.globGenerator()) {
|
||||||
let count = 0;
|
writeDelegate(file);
|
||||||
try {
|
if (fs.statSync(file).isDirectory()) {
|
||||||
for (var _d = true, _e = __asyncValues(globber.globGenerator()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
writeDelegate(`Skip directory '${file}'.`);
|
||||||
_c = _f.value;
|
continue;
|
||||||
_d = false;
|
|
||||||
const file = _c;
|
|
||||||
writeDelegate(file);
|
|
||||||
if (fs.statSync(file).isDirectory()) {
|
|
||||||
writeDelegate(`Skip directory '${file}'.`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const hash = crypto.createHash("sha256");
|
|
||||||
const pipeline = util.promisify(stream.pipeline);
|
|
||||||
yield pipeline(fs.createReadStream(file), hash);
|
|
||||||
result.write(hash.digest());
|
|
||||||
count++;
|
|
||||||
if (!hasMatch) {
|
|
||||||
hasMatch = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
const hash = crypto.createHash("sha256");
|
||||||
finally {
|
const pipeline = util.promisify(stream.pipeline);
|
||||||
try {
|
await pipeline(fs.createReadStream(file), hash);
|
||||||
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
result.write(hash.digest());
|
||||||
}
|
count++;
|
||||||
finally { if (e_1) throw e_1.error; }
|
if (!hasMatch) {
|
||||||
|
hasMatch = true;
|
||||||
}
|
}
|
||||||
result.end();
|
}
|
||||||
if (hasMatch) {
|
result.end();
|
||||||
writeDelegate(`Found ${count} files to hash.`);
|
if (hasMatch) {
|
||||||
return result.digest("hex");
|
writeDelegate(`Found ${count} files to hash.`);
|
||||||
}
|
return result.digest("hex");
|
||||||
writeDelegate("No matches found for glob");
|
}
|
||||||
return "";
|
writeDelegate("No matches found for glob");
|
||||||
});
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -91701,15 +91655,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|||||||
return result;
|
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 }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.run = run;
|
exports.run = run;
|
||||||
const cache = __importStar(__nccwpck_require__(5116));
|
const cache = __importStar(__nccwpck_require__(5116));
|
||||||
@ -91718,69 +91663,63 @@ const exec = __importStar(__nccwpck_require__(5236));
|
|||||||
const fs = __importStar(__nccwpck_require__(3024));
|
const fs = __importStar(__nccwpck_require__(3024));
|
||||||
const restore_cache_1 = __nccwpck_require__(5391);
|
const restore_cache_1 = __nccwpck_require__(5391);
|
||||||
const inputs_1 = __nccwpck_require__(9612);
|
const inputs_1 = __nccwpck_require__(9612);
|
||||||
function run() {
|
async function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
try {
|
||||||
try {
|
if (inputs_1.enableCache) {
|
||||||
if (inputs_1.enableCache) {
|
await saveCache();
|
||||||
yield saveCache();
|
// node will stay alive if any promises are not resolved,
|
||||||
// node will stay alive if any promises are not resolved,
|
// which is a possibility if HTTP requests are dangling
|
||||||
// which is a possibility if HTTP requests are dangling
|
// due to retries or timeouts. We know that if we got here
|
||||||
// due to retries or timeouts. We know that if we got here
|
// that all promises that we care about have successfully
|
||||||
// that all promises that we care about have successfully
|
// resolved, so simply exit with success.
|
||||||
// resolved, so simply exit with success.
|
process.exit(0);
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
}
|
||||||
const err = error;
|
catch (error) {
|
||||||
core.setFailed(err.message);
|
const err = error;
|
||||||
}
|
core.setFailed(err.message);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
function saveCache() {
|
async function saveCache() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
const cacheKey = core.getState(restore_cache_1.STATE_CACHE_KEY);
|
||||||
const cacheKey = core.getState(restore_cache_1.STATE_CACHE_KEY);
|
const matchedKey = core.getState(restore_cache_1.STATE_CACHE_MATCHED_KEY);
|
||||||
const matchedKey = core.getState(restore_cache_1.STATE_CACHE_MATCHED_KEY);
|
if (!cacheKey) {
|
||||||
if (!cacheKey) {
|
core.warning("Error retrieving cache key from state.");
|
||||||
core.warning("Error retrieving cache key from state.");
|
return;
|
||||||
return;
|
}
|
||||||
|
if (matchedKey === cacheKey) {
|
||||||
|
core.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (inputs_1.pruneCache) {
|
||||||
|
await pruneCache();
|
||||||
|
}
|
||||||
|
core.info(`Saving cache path: ${inputs_1.cacheLocalPath}`);
|
||||||
|
if (!fs.existsSync(inputs_1.cacheLocalPath) && !inputs_1.ignoreNothingToCache) {
|
||||||
|
throw new Error(`Cache path ${inputs_1.cacheLocalPath} does not exist on disk. This likely indicates that there are no dependencies to cache. Consider disabling the cache input if it is not needed.`);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await cache.saveCache([inputs_1.cacheLocalPath], cacheKey);
|
||||||
|
core.info(`cache saved with the key: ${cacheKey}`);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (e instanceof Error &&
|
||||||
|
e.message ===
|
||||||
|
"Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.") {
|
||||||
|
core.info("No cacheable paths were found. Ignoring because ignore-nothing-to-save is enabled.");
|
||||||
}
|
}
|
||||||
if (matchedKey === cacheKey) {
|
else {
|
||||||
core.info(`Cache hit occurred on key ${cacheKey}, not saving cache.`);
|
throw e;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (inputs_1.pruneCache) {
|
}
|
||||||
yield pruneCache();
|
|
||||||
}
|
|
||||||
core.info(`Saving cache path: ${inputs_1.cacheLocalPath}`);
|
|
||||||
if (!fs.existsSync(inputs_1.cacheLocalPath) && !inputs_1.ignoreNothingToCache) {
|
|
||||||
throw new Error(`Cache path ${inputs_1.cacheLocalPath} does not exist on disk. This likely indicates that there are no dependencies to cache. Consider disabling the cache input if it is not needed.`);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
yield cache.saveCache([inputs_1.cacheLocalPath], cacheKey);
|
|
||||||
core.info(`cache saved with the key: ${cacheKey}`);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
if (e instanceof Error &&
|
|
||||||
e.message ===
|
|
||||||
"Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.") {
|
|
||||||
core.info("No cacheable paths were found. Ignoring because ignore-nothing-to-save is enabled.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
function pruneCache() {
|
async function pruneCache() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
const options = {
|
||||||
const options = {
|
silent: !core.isDebug(),
|
||||||
silent: !core.isDebug(),
|
};
|
||||||
};
|
const execArgs = ["cache", "prune", "--ci"];
|
||||||
const execArgs = ["cache", "prune", "--ci"];
|
core.info("Pruning cache...");
|
||||||
core.info("Pruning cache...");
|
await exec.exec("uv", execArgs, options);
|
||||||
yield exec.exec("uv", execArgs, options);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
3641
dist/setup/index.js
generated
vendored
3641
dist/setup/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
116
dist/update-known-checksums/index.js
generated
vendored
116
dist/update-known-checksums/index.js
generated
vendored
@ -34751,39 +34751,28 @@ var __importStar = (this && this.__importStar) || (function () {
|
|||||||
return result;
|
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 }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.updateChecksums = updateChecksums;
|
exports.updateChecksums = updateChecksums;
|
||||||
const node_fs_1 = __nccwpck_require__(3024);
|
const node_fs_1 = __nccwpck_require__(3024);
|
||||||
const tc = __importStar(__nccwpck_require__(3472));
|
const tc = __importStar(__nccwpck_require__(3472));
|
||||||
const known_checksums_1 = __nccwpck_require__(2764);
|
const known_checksums_1 = __nccwpck_require__(2764);
|
||||||
function updateChecksums(filePath, downloadUrls) {
|
async function updateChecksums(filePath, downloadUrls) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
await node_fs_1.promises.rm(filePath);
|
||||||
yield node_fs_1.promises.rm(filePath);
|
await node_fs_1.promises.appendFile(filePath, "// AUTOGENERATED_DO_NOT_EDIT\nexport const KNOWN_CHECKSUMS: { [key: string]: string } = {\n");
|
||||||
yield node_fs_1.promises.appendFile(filePath, "// AUTOGENERATED_DO_NOT_EDIT\nexport const KNOWN_CHECKSUMS: { [key: string]: string } = {\n");
|
let firstLine = true;
|
||||||
let firstLine = true;
|
for (const downloadUrl of downloadUrls) {
|
||||||
for (const downloadUrl of downloadUrls) {
|
const key = getKey(downloadUrl);
|
||||||
const key = getKey(downloadUrl);
|
if (key === undefined) {
|
||||||
if (key === undefined) {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const checksum = yield getOrDownloadChecksum(key, downloadUrl);
|
|
||||||
if (!firstLine) {
|
|
||||||
yield node_fs_1.promises.appendFile(filePath, ",\n");
|
|
||||||
}
|
|
||||||
yield node_fs_1.promises.appendFile(filePath, ` "${key}":\n "${checksum}"`);
|
|
||||||
firstLine = false;
|
|
||||||
}
|
}
|
||||||
yield node_fs_1.promises.appendFile(filePath, ",\n};\n");
|
const checksum = await getOrDownloadChecksum(key, downloadUrl);
|
||||||
});
|
if (!firstLine) {
|
||||||
|
await node_fs_1.promises.appendFile(filePath, ",\n");
|
||||||
|
}
|
||||||
|
await node_fs_1.promises.appendFile(filePath, ` "${key}":\n "${checksum}"`);
|
||||||
|
firstLine = false;
|
||||||
|
}
|
||||||
|
await node_fs_1.promises.appendFile(filePath, ",\n};\n");
|
||||||
}
|
}
|
||||||
function getKey(downloadUrl) {
|
function getKey(downloadUrl) {
|
||||||
// https://github.com/astral-sh/uv/releases/download/0.3.2/uv-aarch64-apple-darwin.tar.gz.sha256
|
// https://github.com/astral-sh/uv/releases/download/0.3.2/uv-aarch64-apple-darwin.tar.gz.sha256
|
||||||
@ -34796,25 +34785,21 @@ function getKey(downloadUrl) {
|
|||||||
const version = parts[parts.length - 2];
|
const version = parts[parts.length - 2];
|
||||||
return `${name}-${version}`;
|
return `${name}-${version}`;
|
||||||
}
|
}
|
||||||
function getOrDownloadChecksum(key, downloadUrl) {
|
async function getOrDownloadChecksum(key, downloadUrl) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
let checksum = "";
|
||||||
let checksum = "";
|
if (key in known_checksums_1.KNOWN_CHECKSUMS) {
|
||||||
if (key in known_checksums_1.KNOWN_CHECKSUMS) {
|
checksum = known_checksums_1.KNOWN_CHECKSUMS[key];
|
||||||
checksum = known_checksums_1.KNOWN_CHECKSUMS[key];
|
}
|
||||||
}
|
else {
|
||||||
else {
|
const content = await downloadAssetContent(downloadUrl);
|
||||||
const content = yield downloadAssetContent(downloadUrl);
|
checksum = content.split(" ")[0].trim();
|
||||||
checksum = content.split(" ")[0].trim();
|
}
|
||||||
}
|
return checksum;
|
||||||
return checksum;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
function downloadAssetContent(downloadUrl) {
|
async function downloadAssetContent(downloadUrl) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
const downloadPath = await tc.downloadTool(downloadUrl);
|
||||||
const downloadPath = yield tc.downloadTool(downloadUrl);
|
const content = await node_fs_1.promises.readFile(downloadPath, "utf8");
|
||||||
const content = yield node_fs_1.promises.readFile(downloadPath, "utf8");
|
return content;
|
||||||
return content;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -34858,39 +34843,28 @@ var __importStar = (this && this.__importStar) || (function () {
|
|||||||
return result;
|
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 }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const github = __importStar(__nccwpck_require__(3228));
|
const github = __importStar(__nccwpck_require__(3228));
|
||||||
const core = __importStar(__nccwpck_require__(7484));
|
const core = __importStar(__nccwpck_require__(7484));
|
||||||
const constants_1 = __nccwpck_require__(6156);
|
const constants_1 = __nccwpck_require__(6156);
|
||||||
const semver = __importStar(__nccwpck_require__(9318));
|
const semver = __importStar(__nccwpck_require__(9318));
|
||||||
const update_known_checksums_1 = __nccwpck_require__(6182);
|
const update_known_checksums_1 = __nccwpck_require__(6182);
|
||||||
function run() {
|
async function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
const checksumFilePath = process.argv.slice(2)[0];
|
||||||
const checksumFilePath = process.argv.slice(2)[0];
|
const github_token = process.argv.slice(2)[1];
|
||||||
const github_token = process.argv.slice(2)[1];
|
const octokit = github.getOctokit(github_token, { baseUrl: constants_1.GITHUB_COM_API });
|
||||||
const octokit = github.getOctokit(github_token, { baseUrl: constants_1.GITHUB_COM_API });
|
const response = await octokit.paginate(octokit.rest.repos.listReleases, {
|
||||||
const response = yield octokit.paginate(octokit.rest.repos.listReleases, {
|
owner: constants_1.OWNER,
|
||||||
owner: constants_1.OWNER,
|
repo: constants_1.REPO,
|
||||||
repo: constants_1.REPO,
|
|
||||||
});
|
|
||||||
const downloadUrls = response.flatMap((release) => release.assets
|
|
||||||
.filter((asset) => asset.name.endsWith(".sha256"))
|
|
||||||
.map((asset) => asset.browser_download_url));
|
|
||||||
yield (0, update_known_checksums_1.updateChecksums)(checksumFilePath, downloadUrls);
|
|
||||||
const latestVersion = response
|
|
||||||
.map((release) => release.tag_name)
|
|
||||||
.sort(semver.rcompare)[0];
|
|
||||||
core.setOutput("latest-version", latestVersion);
|
|
||||||
});
|
});
|
||||||
|
const downloadUrls = response.flatMap((release) => release.assets
|
||||||
|
.filter((asset) => asset.name.endsWith(".sha256"))
|
||||||
|
.map((asset) => asset.browser_download_url));
|
||||||
|
await (0, update_known_checksums_1.updateChecksums)(checksumFilePath, downloadUrls);
|
||||||
|
const latestVersion = response
|
||||||
|
.map((release) => release.tag_name)
|
||||||
|
.sort(semver.rcompare)[0];
|
||||||
|
core.setOutput("latest-version", latestVersion);
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
30
package-lock.json
generated
30
package-lock.json
generated
@ -16,8 +16,8 @@
|
|||||||
"@actions/glob": "^0.5.0",
|
"@actions/glob": "^0.5.0",
|
||||||
"@actions/io": "^1.1.3",
|
"@actions/io": "^1.1.3",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^2.0.1",
|
||||||
"@iarna/toml": "^2.2.5",
|
"@octokit/rest": "^21.1.0",
|
||||||
"@octokit/rest": "^21.1.0"
|
"smol-toml": "^1.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "1.9.4",
|
"@biomejs/biome": "1.9.4",
|
||||||
@ -1105,11 +1105,6 @@
|
|||||||
"node": ">=14"
|
"node": ">=14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@iarna/toml": {
|
|
||||||
"version": "2.2.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz",
|
|
||||||
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="
|
|
||||||
},
|
|
||||||
"node_modules/@istanbuljs/load-nyc-config": {
|
"node_modules/@istanbuljs/load-nyc-config": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||||
@ -4577,6 +4572,17 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/smol-toml": {
|
||||||
|
"version": "1.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.3.1.tgz",
|
||||||
|
"integrity": "sha512-tEYNll18pPKHroYSmLLrksq233j021G0giwW7P3D24jC54pQ5W5BXMsQ/Mvw1OJCmEYDgY+lrzT+3nNUtoNfXQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/cyyynthia"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/source-map": {
|
"node_modules/source-map": {
|
||||||
"version": "0.6.1",
|
"version": "0.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
@ -5940,11 +5946,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
|
||||||
"integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA=="
|
"integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA=="
|
||||||
},
|
},
|
||||||
"@iarna/toml": {
|
|
||||||
"version": "2.2.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz",
|
|
||||||
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="
|
|
||||||
},
|
|
||||||
"@istanbuljs/load-nyc-config": {
|
"@istanbuljs/load-nyc-config": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||||
@ -8607,6 +8608,11 @@
|
|||||||
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
|
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"smol-toml": {
|
||||||
|
"version": "1.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.3.1.tgz",
|
||||||
|
"integrity": "sha512-tEYNll18pPKHroYSmLLrksq233j021G0giwW7P3D24jC54pQ5W5BXMsQ/Mvw1OJCmEYDgY+lrzT+3nNUtoNfXQ=="
|
||||||
|
},
|
||||||
"source-map": {
|
"source-map": {
|
||||||
"version": "0.6.1",
|
"version": "0.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
"@actions/io": "^1.1.3",
|
"@actions/io": "^1.1.3",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^2.0.1",
|
||||||
"@octokit/rest": "^21.1.0",
|
"@octokit/rest": "^21.1.0",
|
||||||
"@iarna/toml": "^2.2.5"
|
"smol-toml": "^1.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "1.9.4",
|
"@biomejs/biome": "1.9.4",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import * as toml from "@iarna/toml";
|
import * as toml from "smol-toml";
|
||||||
|
|
||||||
export function getUvVersionFromConfigFile(
|
export function getUvVersionFromConfigFile(
|
||||||
filePath: string,
|
filePath: string,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
|
"target": "ES2022" /* 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'. */,
|
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
||||||
"outDir": "./lib" /* Redirect output structure to the directory. */,
|
"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. */,
|
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user