@@ -89,31 +89,40 @@ jobs:
8989 # (LeXwDeX/opencode-dag-config) into a release asset. dev/main do not manage
9090 # these templates anymore — the config repo is the single source of truth.
9191 # Read-only: no commits, no pushes, so branch protection never blocks it.
92+ #
93+ # Validate-before-package: the releasing runtime commit runs its directory
94+ # validator against the config repo HEAD BEFORE any copy/package step. Any
95+ # invalid template — or an unavailable validator — fails the job (fail
96+ # closed), so an unchecked archive can never be uploaded or embedded.
9297 package-templates :
9398 name : Package Reference Templates
9499 if : github.event_name == 'workflow_dispatch'
95100 runs-on : ubuntu-latest
96101 permissions :
97102 contents : read
98103 steps :
104+ - name : Checkout Runtime (releasing commit)
105+ uses : actions/checkout@v4
106+
99107 - name : Clone Config Repo
100108 uses : actions/checkout@v4
101109 with :
102110 repository : LeXwDeX/opencode-dag-config
103111 path : dag-config
104112
105- - name : Package Templates
113+ - name : Setup Bun
114+ uses : ./.github/actions/setup-bun
115+ with :
116+ save-cache : false
117+
118+ - name : Install Runtime Dependencies
119+ run : bun install --frozen-lockfile
120+
121+ - name : Validate and Package Templates (fail closed)
122+ working-directory : packages/opencode
106123 run : |
107- mkdir -p dist
108- shopt -s nullglob
109- files=(dag-config/*.yaml)
110- if [ ${#files[@]} -gt 0 ]; then
111- cp "${files[@]}" dist/
112- else
113- echo "::warning::No templates found in opencode-dag-config root; packaging empty archive"
114- fi
115- tar -czf dag-templates.tar.gz -C dist .
116- echo "Templates packaged: $(ls dist | wc -l) files"
124+ echo "Packaging config commit $(git -C "$GITHUB_WORKSPACE/dag-config" rev-parse HEAD) with runtime commit $(git rev-parse HEAD)"
125+ bun run script/package-dag-templates.ts "$GITHUB_WORKSPACE/dag-config" "$GITHUB_WORKSPACE/dag-templates.tar.gz"
117126
118127 - name : Upload Templates Artifact
119128 uses : actions/upload-artifact@v4
@@ -224,15 +233,9 @@ jobs:
224233 for dir in opencode-*/; do
225234 base="${dir%/}"
226235 if [[ "$base" == *linux* ]]; then
227- tar -czf "${ base}.tar.gz" -C "${base}/bin" .
236+ bun run ../script/package-cli-artifact.ts "$base" "${base}.tar.gz"
228237 else
229- cd "${base}/bin"
230- if command -v zip &>/dev/null; then
231- zip -r "../../${base}.zip" .
232- else
233- pwsh -Command "Compress-Archive -Path '*' -DestinationPath '../../${base}.zip'" 2>/dev/null || 7z a "../../${base}.zip" . || true
234- fi
235- cd ../..
238+ bun run ../script/package-cli-artifact.ts "$base" "${base}.zip"
236239 fi
237240 done
238241
0 commit comments