Add output: bun-download-checksum

This commit is contained in:
tcely 2026-03-14 19:49:49 -04:00
parent ed0aa9a333
commit 5a086524e2
No known key found for this signature in database
GPG Key ID: 9F1DAF9D9070430F
3 changed files with 14 additions and 11 deletions

View File

@ -90,10 +90,11 @@ If you need to override the download URL, you can use the `bun-download-url` inp
## Outputs ## Outputs
| Name | Description | Example | | Name | Description | Example |
| ------------------ | ------------------------------------------ | ------------------------------------------------------------------ | | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `bun-version` | The output from `bun --version`. | `1.0.0` | | `bun-version` | The output from `bun --version`. | `1.0.0` |
| `bun-revision` | The output from `bun --revision`. | `1.0.0+822a00c4` | | `bun-revision` | The output from `bun --revision`. | `1.0.0+822a00c4` |
| `bun-path` | The path to the Bun executable. | `/path/to/bun` | | `bun-path` | The path to the Bun executable. | `/path/to/bun` |
| `bun-download-url` | The URL from which Bun was downloaded. | `https://bun.sh/download/latest/linux/x64?avx2=true&profile=false` | | `bun-download-checksum` | The verified checksum of the archive from which Bun was extracted. May be empty on cache hits from previous action versions. | `sha256:a7bc4cdea1ef255a83adbf39c7aafcd30e09f2b8f74deec4b10ee318bc024d1f` |
| `cache-hit` | If the Bun executable was read from cache. | `true` | | `bun-download-url` | The URL from which Bun was downloaded. | `https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64-musl-baseline.zip` |
| `cache-hit` | If the Bun executable was read from cache. | `true` |

View File

@ -51,6 +51,8 @@ outputs:
description: The revision of Bun that was installed. description: The revision of Bun that was installed.
bun-path: bun-path:
description: The path to the Bun executable. description: The path to the Bun executable.
bun-download-checksum:
description: The verified checksum of the archive from which Bun was extracted. May be empty on cache hits from previous action versions.
bun-download-url: bun-download-url:
description: The URL from which Bun was downloaded. description: The URL from which Bun was downloaded.
cache-hit: cache-hit:

View File

@ -1,6 +1,6 @@
import { createHash } from "node:crypto"; import { createHash } from "node:crypto";
import { readFileSync, unlinkSync } from "node:fs"; import { readFileSync, unlinkSync } from "node:fs";
import { info, warning } from "@actions/core"; import { info, warning, setOutput } from "@actions/core";
import { GITHUB_DIGEST_THRESHOLD } from "./github-api"; import { GITHUB_DIGEST_THRESHOLD } from "./github-api";
import { fetchAssetMetadata, getHexFromDigest } from "./github-asset"; import { fetchAssetMetadata, getHexFromDigest } from "./github-asset";
import { getVerifiedManifest } from "./manifest"; import { getVerifiedManifest } from "./manifest";
@ -80,7 +80,6 @@ export async function verifyAsset(
* for custom/mirror URLs where parseAssetUrl() cannot resolve metadata. * for custom/mirror URLs where parseAssetUrl() cannot resolve metadata.
* Real security mismatches are always re-thrown. * Real security mismatches are always re-thrown.
*/ */
let digest_matched = false;
let manifestBaseUrl = ""; let manifestBaseUrl = "";
try { try {
const metadata = await fetchAssetMetadata(downloadUrl, token); const metadata = await fetchAssetMetadata(downloadUrl, token);
@ -114,8 +113,8 @@ export async function verifyAsset(
`Security Mismatch: GitHub API digest (${githubHash}) differs from local hash (${actualHash})!`, `Security Mismatch: GitHub API digest (${githubHash}) differs from local hash (${actualHash})!`,
); );
} }
digest_matched = true;
info(`GitHub API digest matched! (${metadata.digest})`); info(`GitHub API digest matched! (${metadata.digest})`);
setOutput("bun-download-checksum", `${metadata.digest}`);
} else { } else {
warning( warning(
`GitHub digest missing for asset updated on ${updatedAt.toISOString()}`, `GitHub digest missing for asset updated on ${updatedAt.toISOString()}`,
@ -198,7 +197,8 @@ export async function verifyAsset(
); );
} }
info(`Successfully verified ${assetName} (PGP + SHA256)`); info(`Successfully verified ${assetName} (PGP + ${manifestFile})`);
setOutput("bun-download-checksum", `${algorithm}:${manifestHash}`);
} }
function silentUnlink(filePath: string): void { function silentUnlink(filePath: string): void {