|
39 | 39 | fi |
40 | 40 |
|
41 | 41 | echo "All versions aligned: $PKG_VERSION" |
| 42 | + - name: Check managed Codex asset hash |
| 43 | + run: | |
| 44 | + set -euo pipefail |
| 45 | + HASH_FILE="skills/df-codex-assets/assets/hash.txt" |
| 46 | + COMPUTED_HASH=$(bun skills/df-codex-assets/scripts/df-codex-assets.ts compute) |
| 47 | + STORED_HASH=$(tr -d '[:space:]' < "$HASH_FILE") |
| 48 | +
|
| 49 | + echo "stored hash: $STORED_HASH" |
| 50 | + echo "computed hash: $COMPUTED_HASH" |
| 51 | +
|
| 52 | + if [ "$COMPUTED_HASH" != "$STORED_HASH" ]; then |
| 53 | + echo "::error::Managed Codex asset hash is stale." |
| 54 | + echo "::error::Correct hash: $COMPUTED_HASH" |
| 55 | + echo "::error::Update with: bun skills/df-codex-assets/scripts/df-codex-assets.ts compute > $HASH_FILE" |
| 56 | + exit 1 |
| 57 | + fi |
| 58 | + - name: Check managed Codex assets on version tag |
| 59 | + run: | |
| 60 | + set -euo pipefail |
| 61 | + VERSION=$(bun -e "console.log(require('./package.json').version)") |
| 62 | + TAG="v${VERSION}" |
| 63 | + REPO=$(bun -e "const p=require('./.codex-plugin/plugin.json'); const repo=String(p.repository||'https://github.com/LiTeXz/devflow-skills'); const m=repo.match(/github\\.com[:/]([^/]+\\/[^/.#]+)(?:\\.git)?/); console.log(m ? m[1] : 'LiTeXz/devflow-skills')") |
| 64 | + HASH_FILE="skills/df-codex-assets/assets/hash.txt" |
| 65 | + STORED_HASH=$(tr -d '[:space:]' < "$HASH_FILE") |
| 66 | +
|
| 67 | + if ! git ls-remote --exit-code --tags "https://github.com/${REPO}.git" "refs/tags/${TAG}" >/dev/null 2>&1; then |
| 68 | + echo "::error::Required managed asset tag ${TAG} does not exist in ${REPO}." |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | +
|
| 72 | + TMP_DIR=$(mktemp -d) |
| 73 | + cleanup() { |
| 74 | + rm -rf "$TMP_DIR" |
| 75 | + } |
| 76 | + trap cleanup EXIT |
| 77 | +
|
| 78 | + while IFS= read -r path; do |
| 79 | + mkdir -p "$TMP_DIR/$(dirname "$path")" |
| 80 | + url="https://raw.githubusercontent.com/${REPO}/${TAG}/${path}" |
| 81 | + if ! curl --fail --show-error --location "$url" --output "$TMP_DIR/$path"; then |
| 82 | + echo "::error::Missing managed asset on ${TAG}: ${path}" |
| 83 | + exit 1 |
| 84 | + fi |
| 85 | + done < <(bun -e "import { MANAGED_ASSET_PATHS } from './skills/df-codex-assets/scripts/df-codex-assets.ts'; console.log(MANAGED_ASSET_PATHS.join('\\n'))") |
| 86 | +
|
| 87 | + mkdir -p "$TMP_DIR/skills/df-codex-assets/scripts" "$TMP_DIR/skills/df-codex-assets/assets" |
| 88 | + cp skills/df-codex-assets/scripts/df-codex-assets.ts "$TMP_DIR/skills/df-codex-assets/scripts/df-codex-assets.ts" |
| 89 | + cp "$HASH_FILE" "$TMP_DIR/$HASH_FILE" |
| 90 | +
|
| 91 | + TAG_HASH=$(PLUGIN_ROOT="$TMP_DIR" bun "$TMP_DIR/skills/df-codex-assets/scripts/df-codex-assets.ts" compute) |
| 92 | + echo "tag: $TAG" |
| 93 | + echo "tag hash: $TAG_HASH" |
| 94 | + echo "stored hash: $STORED_HASH" |
| 95 | +
|
| 96 | + if [ "$TAG_HASH" != "$STORED_HASH" ]; then |
| 97 | + echo "::error::Managed Codex assets on ${TAG} do not match ${HASH_FILE}." |
| 98 | + echo "::error::Tag hash: $TAG_HASH" |
| 99 | + echo "::error::Stored hash: $STORED_HASH" |
| 100 | + exit 1 |
| 101 | + fi |
0 commit comments