mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-05-17 14:44:46 +00:00
Create version-manifest.json on uv release (#399)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Release Drafter / ✏️ Draft release (push) Waiting to run
test / lint (push) Waiting to run
test / test-default-version (macos-14) (push) Waiting to run
test / test-default-version (macos-latest) (push) Waiting to run
test / test-default-version (ubuntu-latest) (push) Waiting to run
test / test-default-version (windows-latest) (push) Waiting to run
test / test-specific-version (0.3) (push) Waiting to run
test / test-specific-version (0.3.0) (push) Waiting to run
test / test-specific-version (0.3.2) (push) Waiting to run
test / test-specific-version (0.3.x) (push) Waiting to run
test / test-specific-version (>=0.3.0) (push) Waiting to run
test / test-semver-range (selfhosted-ubuntu-arm64) (push) Waiting to run
test / test-semver-range (ubuntu-latest) (push) Waiting to run
test / test-pep440-version (push) Waiting to run
test / test-pyproject-file-version (push) Waiting to run
test / test-malformed-pyproject-file-fallback (push) Waiting to run
test / test-uv-file-version (push) Waiting to run
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Waiting to run
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Waiting to run
test / test-with-explicit-token (push) Waiting to run
test / test-uvx (push) Waiting to run
test / test-tool-install (macos-14) (push) Waiting to run
test / test-tool-install (macos-latest) (push) Waiting to run
test / test-tool-install (ubuntu-latest) (push) Waiting to run
test / test-tool-install (windows-latest) (push) Waiting to run
test / test-tilde-expansion-tool-dirs (push) Waiting to run
test / test-python-version (macos-latest) (push) Waiting to run
test / test-python-version (ubuntu-latest) (push) Waiting to run
test / test-python-version (windows-latest) (push) Waiting to run
test / test-activate-environment (macos-latest) (push) Waiting to run
test / test-activate-environment (ubuntu-latest) (push) Waiting to run
test / test-activate-environment (windows-latest) (push) Waiting to run
test / test-musl (push) Waiting to run
test / test-setup-cache (auto, selfhosted-ubuntu-arm64) (push) Waiting to run
test / test-setup-cache (auto, ubuntu-latest) (push) Waiting to run
test / test-setup-cache (auto, windows-latest) (push) Waiting to run
test / test-setup-cache (false, selfhosted-ubuntu-arm64) (push) Waiting to run
test / test-setup-cache (false, ubuntu-latest) (push) Waiting to run
test / test-setup-cache (false, windows-latest) (push) Waiting to run
test / test-setup-cache (true, selfhosted-ubuntu-arm64) (push) Waiting to run
test / test-setup-cache (true, ubuntu-latest) (push) Waiting to run
test / test-setup-cache (true, windows-latest) (push) Waiting to run
test / test-restore-cache (auto, selfhosted-ubuntu-arm64) (push) Blocked by required conditions
test / test-restore-cache (auto, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (auto, windows-latest) (push) Blocked by required conditions
test / test-restore-cache (false, selfhosted-ubuntu-arm64) (push) Blocked by required conditions
test / test-restore-cache (false, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (false, windows-latest) (push) Blocked by required conditions
test / test-restore-cache (true, selfhosted-ubuntu-arm64) (push) Blocked by required conditions
test / test-restore-cache (true, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (true, windows-latest) (push) Blocked by required conditions
test / test-setup-cache-requirements-txt (push) Waiting to run
test / test-restore-cache-requirements-txt (push) Blocked by required conditions
test / test-setup-cache-dependency-glob (push) Waiting to run
test / test-restore-cache-dependency-glob (push) Blocked by required conditions
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Waiting to run
test / test-cache-local (map[expected-cache-dir:/home/ubuntu/.cache/uv os:selfhosted-ubuntu-arm64]) (push) Waiting to run
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Waiting to run
test / test-setup-cache-local (push) Waiting to run
test / test-restore-cache-local (push) Blocked by required conditions
test / test-tilde-expansion-cache-local-path (push) Waiting to run
test / test-tilde-expansion-cache-dependency-glob (push) Waiting to run
test / cleanup-tilde-expansion-tests (push) Blocked by required conditions
test / test-no-python-version (push) Waiting to run
test / all-tests-passed (push) Blocked by required conditions
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Release Drafter / ✏️ Draft release (push) Waiting to run
test / lint (push) Waiting to run
test / test-default-version (macos-14) (push) Waiting to run
test / test-default-version (macos-latest) (push) Waiting to run
test / test-default-version (ubuntu-latest) (push) Waiting to run
test / test-default-version (windows-latest) (push) Waiting to run
test / test-specific-version (0.3) (push) Waiting to run
test / test-specific-version (0.3.0) (push) Waiting to run
test / test-specific-version (0.3.2) (push) Waiting to run
test / test-specific-version (0.3.x) (push) Waiting to run
test / test-specific-version (>=0.3.0) (push) Waiting to run
test / test-semver-range (selfhosted-ubuntu-arm64) (push) Waiting to run
test / test-semver-range (ubuntu-latest) (push) Waiting to run
test / test-pep440-version (push) Waiting to run
test / test-pyproject-file-version (push) Waiting to run
test / test-malformed-pyproject-file-fallback (push) Waiting to run
test / test-uv-file-version (push) Waiting to run
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Waiting to run
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Waiting to run
test / test-with-explicit-token (push) Waiting to run
test / test-uvx (push) Waiting to run
test / test-tool-install (macos-14) (push) Waiting to run
test / test-tool-install (macos-latest) (push) Waiting to run
test / test-tool-install (ubuntu-latest) (push) Waiting to run
test / test-tool-install (windows-latest) (push) Waiting to run
test / test-tilde-expansion-tool-dirs (push) Waiting to run
test / test-python-version (macos-latest) (push) Waiting to run
test / test-python-version (ubuntu-latest) (push) Waiting to run
test / test-python-version (windows-latest) (push) Waiting to run
test / test-activate-environment (macos-latest) (push) Waiting to run
test / test-activate-environment (ubuntu-latest) (push) Waiting to run
test / test-activate-environment (windows-latest) (push) Waiting to run
test / test-musl (push) Waiting to run
test / test-setup-cache (auto, selfhosted-ubuntu-arm64) (push) Waiting to run
test / test-setup-cache (auto, ubuntu-latest) (push) Waiting to run
test / test-setup-cache (auto, windows-latest) (push) Waiting to run
test / test-setup-cache (false, selfhosted-ubuntu-arm64) (push) Waiting to run
test / test-setup-cache (false, ubuntu-latest) (push) Waiting to run
test / test-setup-cache (false, windows-latest) (push) Waiting to run
test / test-setup-cache (true, selfhosted-ubuntu-arm64) (push) Waiting to run
test / test-setup-cache (true, ubuntu-latest) (push) Waiting to run
test / test-setup-cache (true, windows-latest) (push) Waiting to run
test / test-restore-cache (auto, selfhosted-ubuntu-arm64) (push) Blocked by required conditions
test / test-restore-cache (auto, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (auto, windows-latest) (push) Blocked by required conditions
test / test-restore-cache (false, selfhosted-ubuntu-arm64) (push) Blocked by required conditions
test / test-restore-cache (false, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (false, windows-latest) (push) Blocked by required conditions
test / test-restore-cache (true, selfhosted-ubuntu-arm64) (push) Blocked by required conditions
test / test-restore-cache (true, ubuntu-latest) (push) Blocked by required conditions
test / test-restore-cache (true, windows-latest) (push) Blocked by required conditions
test / test-setup-cache-requirements-txt (push) Waiting to run
test / test-restore-cache-requirements-txt (push) Blocked by required conditions
test / test-setup-cache-dependency-glob (push) Waiting to run
test / test-restore-cache-dependency-glob (push) Blocked by required conditions
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Waiting to run
test / test-cache-local (map[expected-cache-dir:/home/ubuntu/.cache/uv os:selfhosted-ubuntu-arm64]) (push) Waiting to run
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Waiting to run
test / test-setup-cache-local (push) Waiting to run
test / test-restore-cache-local (push) Blocked by required conditions
test / test-tilde-expansion-cache-local-path (push) Waiting to run
test / test-tilde-expansion-cache-dependency-glob (push) Waiting to run
test / cleanup-tilde-expansion-tests (push) Blocked by required conditions
test / test-no-python-version (push) Waiting to run
test / all-tests-passed (push) Blocked by required conditions
This commit is contained in:
parent
023b8ec2bc
commit
a4f1f549e9
8 changed files with 20515 additions and 60 deletions
2
.github/release-drafter.yml
vendored
2
.github/release-drafter.yml
vendored
|
@ -19,7 +19,7 @@ categories:
|
||||||
labels:
|
labels:
|
||||||
- "maintenance"
|
- "maintenance"
|
||||||
- "ci"
|
- "ci"
|
||||||
- "update-known-checksums"
|
- "update-known-versions"
|
||||||
- title: "📚 Documentation"
|
- title: "📚 Documentation"
|
||||||
labels:
|
labels:
|
||||||
- "documentation"
|
- "documentation"
|
||||||
|
|
24
.github/workflows/update-known-checksums.yml
vendored
24
.github/workflows/update-known-checksums.yml
vendored
|
@ -1,4 +1,4 @@
|
||||||
name: "Update known checksums"
|
name: "Update known versions"
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
schedule:
|
schedule:
|
||||||
|
@ -15,23 +15,23 @@ jobs:
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: "20"
|
node-version: "20"
|
||||||
- name: Update known checksums
|
- name: Update known versions
|
||||||
id: update-known-checksums
|
id: update-known-versions
|
||||||
run:
|
run:
|
||||||
node dist/update-known-checksums/index.js
|
node dist/update-known-versions/index.js
|
||||||
src/download/checksum/known-checksums.ts ${{ secrets.GITHUB_TOKEN }}
|
src/download/checksum/known-versions.ts ${{ secrets.GITHUB_TOKEN }}
|
||||||
- run: npm install && npm run all
|
- run: npm install && npm run all
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
|
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
|
||||||
with:
|
with:
|
||||||
commit-message: "chore: update known checksums"
|
commit-message: "chore: update known versions"
|
||||||
title:
|
title:
|
||||||
"chore: update known checksums for ${{
|
"chore: update known versions for ${{
|
||||||
steps.update-known-checksums.outputs.latest-version }}"
|
steps.update-known-versions.outputs.latest-version }}"
|
||||||
body:
|
body:
|
||||||
"chore: update known checksums for ${{
|
"chore: update known versions for ${{
|
||||||
steps.update-known-checksums.outputs.latest-version }}"
|
steps.update-known-versions.outputs.latest-version }}"
|
||||||
base: main
|
base: main
|
||||||
labels: "automated-pr,update-known-checksums"
|
labels: "automated-pr,update-known-versions"
|
||||||
branch: update-known-checksums-pr
|
branch: update-known-versions-pr
|
||||||
delete-branch: true
|
delete-branch: true
|
||||||
|
|
111
dist/update-known-checksums/index.js → dist/update-known-versions/index.js
generated
vendored
111
dist/update-known-checksums/index.js → dist/update-known-versions/index.js
generated
vendored
|
@ -61824,7 +61824,84 @@ async function downloadAssetContent(downloadUrl) {
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 5653:
|
/***/ 4000:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"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 () {
|
||||||
|
var ownKeys = function(o) {
|
||||||
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||||
|
var ar = [];
|
||||||
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||||
|
return ar;
|
||||||
|
};
|
||||||
|
return ownKeys(o);
|
||||||
|
};
|
||||||
|
return function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.getLatestKnownVersion = getLatestKnownVersion;
|
||||||
|
exports.updateVersionManifest = updateVersionManifest;
|
||||||
|
const node_fs_1 = __nccwpck_require__(3024);
|
||||||
|
const core = __importStar(__nccwpck_require__(7484));
|
||||||
|
const semver = __importStar(__nccwpck_require__(9318));
|
||||||
|
async function getLatestKnownVersion(versionManifestFile) {
|
||||||
|
const data = await node_fs_1.promises.readFile(versionManifestFile);
|
||||||
|
const versionManifestEntries = JSON.parse(data.toString());
|
||||||
|
return versionManifestEntries.reduce((a, b) => semver.gt(a.version, b.version) ? a : b).version;
|
||||||
|
}
|
||||||
|
async function updateVersionManifest(versionManifestFile, downloadUrls) {
|
||||||
|
const versionManifest = [];
|
||||||
|
for (const downloadUrl of downloadUrls) {
|
||||||
|
const urlParts = downloadUrl.split("/");
|
||||||
|
const version = urlParts[urlParts.length - 2];
|
||||||
|
const artifactName = urlParts[urlParts.length - 1];
|
||||||
|
if (!artifactName.startsWith("uv-")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (artifactName.startsWith("uv-installer")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const artifactParts = artifactName.split(".")[0].split("-");
|
||||||
|
versionManifest.push({
|
||||||
|
version: version,
|
||||||
|
artifactName: artifactName,
|
||||||
|
arch: artifactParts[1],
|
||||||
|
platform: artifactName.split(`uv-${artifactParts[1]}-`)[1].split(".")[0],
|
||||||
|
downloadUrl: downloadUrl,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
core.debug(`Updating version manifest: ${JSON.stringify(versionManifest)}`);
|
||||||
|
await node_fs_1.promises.writeFile(versionManifestFile, JSON.stringify(versionManifest));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 7416:
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
@ -61868,24 +61945,36 @@ const core = __importStar(__nccwpck_require__(7484));
|
||||||
const octokit_1 = __nccwpck_require__(3352);
|
const octokit_1 = __nccwpck_require__(3352);
|
||||||
const constants_1 = __nccwpck_require__(6156);
|
const constants_1 = __nccwpck_require__(6156);
|
||||||
const update_known_checksums_1 = __nccwpck_require__(6182);
|
const update_known_checksums_1 = __nccwpck_require__(6182);
|
||||||
|
const version_manifest_1 = __nccwpck_require__(4000);
|
||||||
async function run() {
|
async function run() {
|
||||||
const checksumFilePath = process.argv.slice(2)[0];
|
const checksumFilePath = process.argv.slice(2)[0];
|
||||||
const github_token = process.argv.slice(2)[1];
|
const versionsManifestFilePath = process.argv.slice(2)[1];
|
||||||
|
const githubToken = process.argv.slice(2)[2];
|
||||||
const octokit = new octokit_1.Octokit({
|
const octokit = new octokit_1.Octokit({
|
||||||
auth: github_token,
|
auth: githubToken,
|
||||||
});
|
});
|
||||||
const response = await octokit.paginate(octokit.rest.repos.listReleases, {
|
const { data: latestRelease } = await octokit.rest.repos.getLatestRelease({
|
||||||
owner: constants_1.OWNER,
|
owner: constants_1.OWNER,
|
||||||
repo: constants_1.REPO,
|
repo: constants_1.REPO,
|
||||||
});
|
});
|
||||||
const downloadUrls = response.flatMap((release) => release.assets
|
const latestKnownVersion = await (0, version_manifest_1.getLatestKnownVersion)(versionsManifestFilePath);
|
||||||
|
if (semver.lte(latestRelease.tag_name, latestKnownVersion)) {
|
||||||
|
core.info(`Latest release (${latestRelease.tag_name}) is not newer than the latest known version (${latestKnownVersion}). Skipping update.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const releases = await octokit.paginate(octokit.rest.repos.listReleases, {
|
||||||
|
owner: constants_1.OWNER,
|
||||||
|
repo: constants_1.REPO,
|
||||||
|
});
|
||||||
|
const checksumDownloadUrls = releases.flatMap((release) => release.assets
|
||||||
.filter((asset) => asset.name.endsWith(".sha256"))
|
.filter((asset) => asset.name.endsWith(".sha256"))
|
||||||
.map((asset) => asset.browser_download_url));
|
.map((asset) => asset.browser_download_url));
|
||||||
await (0, update_known_checksums_1.updateChecksums)(checksumFilePath, downloadUrls);
|
await (0, update_known_checksums_1.updateChecksums)(checksumFilePath, checksumDownloadUrls);
|
||||||
const latestVersion = response
|
const artifactDownloadUrls = releases.flatMap((release) => release.assets
|
||||||
.map((release) => release.tag_name)
|
.filter((asset) => !asset.name.endsWith(".sha256"))
|
||||||
.sort(semver.rcompare)[0];
|
.map((asset) => asset.browser_download_url));
|
||||||
core.setOutput("latest-version", latestVersion);
|
await (0, version_manifest_1.updateVersionManifest)(versionsManifestFilePath, artifactDownloadUrls);
|
||||||
|
core.setOutput("latest-version", latestRelease.tag_name);
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
@ -67976,7 +68065,7 @@ legacyRestEndpointMethods.VERSION = VERSION;
|
||||||
/******/ // startup
|
/******/ // startup
|
||||||
/******/ // Load entry module and return exports
|
/******/ // Load entry module and return exports
|
||||||
/******/ // This entry module is referenced by other modules so it can't be inlined
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
||||||
/******/ var __webpack_exports__ = __nccwpck_require__(5653);
|
/******/ var __webpack_exports__ = __nccwpck_require__(7416);
|
||||||
/******/ module.exports = __webpack_exports__;
|
/******/ module.exports = __webpack_exports__;
|
||||||
/******/
|
/******/
|
||||||
/******/ })()
|
/******/ })()
|
|
@ -9,10 +9,10 @@
|
||||||
"format": "biome format --fix",
|
"format": "biome format --fix",
|
||||||
"format-check": "biome format",
|
"format-check": "biome format",
|
||||||
"lint": "biome lint --fix",
|
"lint": "biome lint --fix",
|
||||||
"package": "ncc build -o dist/setup src/setup-uv.ts && ncc build -o dist/save-cache src/save-cache.ts && ncc build -o dist/update-known-checksums src/update-known-checksums.ts",
|
"package": "ncc build -o dist/setup src/setup-uv.ts && ncc build -o dist/save-cache src/save-cache.ts && ncc build -o dist/update-known-versions src/update-known-versions.ts",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"act": "act pull_request -W .github/workflows/test.yml --container-architecture linux/amd64 -s GITHUB_TOKEN=\"$(gh auth token)\"",
|
"act": "act pull_request -W .github/workflows/test.yml --container-architecture linux/amd64 -s GITHUB_TOKEN=\"$(gh auth token)\"",
|
||||||
"update-known-checksums": "RUNNER_TEMP=known_checksums node dist/update-known-checksums/index.js src/download/checksum/known-checksums.ts \"$(gh auth token)\"",
|
"update-known-versions": "RUNNER_TEMP=known_versions node dist/update-known-versions/index.js src/download/checksum/known-versions.ts \"$(gh auth token)\"",
|
||||||
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
|
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
52
src/download/version-manifest.ts
Normal file
52
src/download/version-manifest.ts
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
import { promises as fs } from "node:fs";
|
||||||
|
import * as core from "@actions/core";
|
||||||
|
import * as semver from "semver";
|
||||||
|
|
||||||
|
interface VersionManifestEntry {
|
||||||
|
version: string;
|
||||||
|
artifactName: string;
|
||||||
|
arch: string;
|
||||||
|
platform: string;
|
||||||
|
downloadUrl: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getLatestKnownVersion(
|
||||||
|
versionManifestFile: string,
|
||||||
|
): Promise<string> {
|
||||||
|
const data = await fs.readFile(versionManifestFile);
|
||||||
|
const versionManifestEntries: VersionManifestEntry[] = JSON.parse(
|
||||||
|
data.toString(),
|
||||||
|
);
|
||||||
|
return versionManifestEntries.reduce((a, b) =>
|
||||||
|
semver.gt(a.version, b.version) ? a : b,
|
||||||
|
).version;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateVersionManifest(
|
||||||
|
versionManifestFile: string,
|
||||||
|
downloadUrls: string[],
|
||||||
|
): Promise<void> {
|
||||||
|
const versionManifest: VersionManifestEntry[] = [];
|
||||||
|
|
||||||
|
for (const downloadUrl of downloadUrls) {
|
||||||
|
const urlParts = downloadUrl.split("/");
|
||||||
|
const version = urlParts[urlParts.length - 2];
|
||||||
|
const artifactName = urlParts[urlParts.length - 1];
|
||||||
|
if (!artifactName.startsWith("uv-")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (artifactName.startsWith("uv-installer")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const artifactParts = artifactName.split(".")[0].split("-");
|
||||||
|
versionManifest.push({
|
||||||
|
version: version,
|
||||||
|
artifactName: artifactName,
|
||||||
|
arch: artifactParts[1],
|
||||||
|
platform: artifactName.split(`uv-${artifactParts[1]}-`)[1].split(".")[0],
|
||||||
|
downloadUrl: downloadUrl,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
core.debug(`Updating version manifest: ${JSON.stringify(versionManifest)}`);
|
||||||
|
await fs.writeFile(versionManifestFile, JSON.stringify(versionManifest));
|
||||||
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
import * as semver from "semver";
|
|
||||||
import * as core from "@actions/core";
|
|
||||||
import { Octokit } from "./utils/octokit";
|
|
||||||
|
|
||||||
import { OWNER, REPO } from "./utils/constants";
|
|
||||||
|
|
||||||
import { updateChecksums } from "./download/checksum/update-known-checksums";
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
|
||||||
const checksumFilePath = process.argv.slice(2)[0];
|
|
||||||
const github_token = process.argv.slice(2)[1];
|
|
||||||
|
|
||||||
const octokit = new Octokit({
|
|
||||||
auth: github_token,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await octokit.paginate(octokit.rest.repos.listReleases, {
|
|
||||||
owner: OWNER,
|
|
||||||
repo: REPO,
|
|
||||||
});
|
|
||||||
const downloadUrls: string[] = response.flatMap((release) =>
|
|
||||||
release.assets
|
|
||||||
.filter((asset) => asset.name.endsWith(".sha256"))
|
|
||||||
.map((asset) => asset.browser_download_url),
|
|
||||||
);
|
|
||||||
await updateChecksums(checksumFilePath, downloadUrls);
|
|
||||||
|
|
||||||
const latestVersion = response
|
|
||||||
.map((release) => release.tag_name)
|
|
||||||
.sort(semver.rcompare)[0];
|
|
||||||
core.setOutput("latest-version", latestVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
run();
|
|
60
src/update-known-versions.ts
Normal file
60
src/update-known-versions.ts
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
import * as semver from "semver";
|
||||||
|
import * as core from "@actions/core";
|
||||||
|
import { Octokit } from "./utils/octokit";
|
||||||
|
|
||||||
|
import { OWNER, REPO } from "./utils/constants";
|
||||||
|
|
||||||
|
import { updateChecksums } from "./download/checksum/update-known-checksums";
|
||||||
|
import {
|
||||||
|
updateVersionManifest,
|
||||||
|
getLatestKnownVersion,
|
||||||
|
} from "./download/version-manifest";
|
||||||
|
|
||||||
|
async function run(): Promise<void> {
|
||||||
|
const checksumFilePath = process.argv.slice(2)[0];
|
||||||
|
const versionsManifestFilePath = process.argv.slice(2)[1];
|
||||||
|
const githubToken = process.argv.slice(2)[2];
|
||||||
|
|
||||||
|
const octokit = new Octokit({
|
||||||
|
auth: githubToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { data: latestRelease } = await octokit.rest.repos.getLatestRelease({
|
||||||
|
owner: OWNER,
|
||||||
|
repo: REPO,
|
||||||
|
});
|
||||||
|
|
||||||
|
const latestKnownVersion = await getLatestKnownVersion(
|
||||||
|
versionsManifestFilePath,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (semver.lte(latestRelease.tag_name, latestKnownVersion)) {
|
||||||
|
core.info(
|
||||||
|
`Latest release (${latestRelease.tag_name}) is not newer than the latest known version (${latestKnownVersion}). Skipping update.`,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const releases = await octokit.paginate(octokit.rest.repos.listReleases, {
|
||||||
|
owner: OWNER,
|
||||||
|
repo: REPO,
|
||||||
|
});
|
||||||
|
const checksumDownloadUrls: string[] = releases.flatMap((release) =>
|
||||||
|
release.assets
|
||||||
|
.filter((asset) => asset.name.endsWith(".sha256"))
|
||||||
|
.map((asset) => asset.browser_download_url),
|
||||||
|
);
|
||||||
|
await updateChecksums(checksumFilePath, checksumDownloadUrls);
|
||||||
|
|
||||||
|
const artifactDownloadUrls: string[] = releases.flatMap((release) =>
|
||||||
|
release.assets
|
||||||
|
.filter((asset) => !asset.name.endsWith(".sha256"))
|
||||||
|
.map((asset) => asset.browser_download_url),
|
||||||
|
);
|
||||||
|
|
||||||
|
await updateVersionManifest(versionsManifestFilePath, artifactDownloadUrls);
|
||||||
|
|
||||||
|
core.setOutput("latest-version", latestRelease.tag_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
20288
version-manifest.json
Normal file
20288
version-manifest.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue