@@ -164,6 +164,67 @@ case "${COMMAND}" in
164164 echo " Artifact reorganization complete"
165165 ;;
166166
167+ # ##############################################################################
168+ # Consolidate all per-architecture artifacts into a single flat
169+ # distribute/release/ directory for upload to GitHub Releases.
170+ # Common files (shell scripts, action.yml, apt-fast) are copied once from the
171+ # first available architecture directory. Architecture-specific binaries
172+ # (apt_query-*) are copied from every architecture directory. A combined
173+ # checksums.txt is generated at the end.
174+ # ##############################################################################
175+ consolidate-release)
176+ RELEASE_DIR=" distribute/release"
177+ mkdir -p " ${RELEASE_DIR} "
178+ echo " Consolidating release artifacts into ${RELEASE_DIR} ..."
179+
180+ # Find first available arch directory to source common files from.
181+ FIRST_ARCH_DIR=" "
182+ for arch_dir in distribute/x64 distribute/arm64 distribute/arm distribute/x86; do
183+ if [[ -d " ${arch_dir} " ]]; then
184+ FIRST_ARCH_DIR=" ${arch_dir} "
185+ break
186+ fi
187+ done
188+
189+ if [[ -z " ${FIRST_ARCH_DIR} " ]]; then
190+ echo " Error: No architecture directories found under distribute/" >&2
191+ exit 1
192+ fi
193+
194+ # Copy common files (everything except arch-specific binaries and checksums)
195+ # from the first arch directory.
196+ shopt -s nullglob
197+ for f in " ${FIRST_ARCH_DIR} " /* ; do
198+ filename=" $( basename " ${f} " ) "
199+ if [[ " ${filename} " == apt_query-* ]] || [[ " ${filename} " == checksums.txt ]]; then
200+ continue
201+ fi
202+ cp " ${f} " " ${RELEASE_DIR} /"
203+ echo " Copied common file: ${filename} "
204+ done
205+ shopt -u nullglob
206+
207+ # Copy architecture-specific binaries from every arch directory.
208+ shopt -s nullglob
209+ for arch_dir in distribute/x64 distribute/arm64 distribute/arm distribute/x86; do
210+ [[ -d " ${arch_dir} " ]] || continue
211+ for binary in " ${arch_dir} " /apt_query-* ; do
212+ cp " ${binary} " " ${RELEASE_DIR} /"
213+ echo " Copied binary: $( basename " ${binary} " ) "
214+ done
215+ done
216+ shopt -u nullglob
217+
218+ # Generate a combined checksums file for all release assets.
219+ (cd " ${RELEASE_DIR} " && find . -maxdepth 1 -type f ! -name " checksums.txt" \
220+ -exec sha256sum {} + | sed ' s|\./||' | sort > checksums.txt)
221+ echo " Generated combined checksums:"
222+ cat " ${RELEASE_DIR} /checksums.txt"
223+
224+ echo " Consolidation complete. Release directory contents:"
225+ ls -la " ${RELEASE_DIR} /"
226+ ;;
227+
167228 * )
168229 echo " Error: Unknown command: ${COMMAND} " >&2
169230 echo " Usage: distribute.sh <command> [args...]" >&2
@@ -175,6 +236,7 @@ case "${COMMAND}" in
175236 echo " generate-checksums <arch>" >&2
176237 echo " verify-build <arch>" >&2
177238 echo " reorganize-artifacts" >&2
239+ echo " consolidate-release" >&2
178240 exit 1
179241 ;;
180242
0 commit comments