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

This commit is contained in:
Kevin Stillhammer 2025-05-03 19:51:16 +02:00 committed by GitHub
parent 023b8ec2bc
commit a4f1f549e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 20515 additions and 60 deletions

View 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));
}

View file

@ -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();

View 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();