Skip to content

Commit 58600a5

Browse files
committed
2 parents 6d362b8 + 553a35b commit 58600a5

2 files changed

Lines changed: 69 additions & 10 deletions

File tree

.github/workflows/build-distribute.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ on:
66
branches:
77
- dev-v2
88
workflow_call:
9-
inputs:
10-
create_release:
11-
description: 'Create a GitHub release (disabled by default for dry-run/PR builds)'
12-
default: false
13-
type: boolean
9+
workflow_dispatch:
1410
permissions:
1511
contents: write
1612
id-token: write
@@ -78,7 +74,7 @@ jobs:
7874
create-release:
7975
needs: build-and-release
8076
runs-on: ubuntu-latest
81-
if: success() && (github.event_name != 'workflow_call' || inputs.create_release == true)
77+
if: success() && github.event_name == 'workflow_dispatch'
8278
steps:
8379
- name: Checkout
8480
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
@@ -96,17 +92,17 @@ jobs:
9692
- name: Reorganize artifacts
9793
run: |
9894
./scripts/distribute.sh reorganize-artifacts
95+
- name: Consolidate release artifacts
96+
run: |
97+
./scripts/distribute.sh consolidate-release
9998
- name: Create or update release
10099
uses: softprops/action-gh-release@2bb465e97f322d3cb2a965294d483e0d26a67aa9 # v3.0.1
101100
with:
102101
tag_name: ${{ steps.version.outputs.version }}
103102
name: "${{ steps.version.outputs.version }}"
104103
generate_release_notes: true
105104
files: |
106-
distribute/x64/*
107-
distribute/arm64/*
108-
distribute/arm/*
109-
distribute/x86/*
105+
distribute/release/*
110106
draft: false
111107
prerelease: true
112108
env:

scripts/distribute.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,68 @@ 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+
ARCH_DIRS=(distribute/x64 distribute/arm64 distribute/arm distribute/x86)
178+
mkdir -p "${RELEASE_DIR}"
179+
echo "Consolidating release artifacts into ${RELEASE_DIR}..."
180+
181+
# Find first available arch directory to source common files from.
182+
FIRST_ARCH_DIR=""
183+
for arch_dir in "${ARCH_DIRS[@]}"; do
184+
if [[ -d "${arch_dir}" ]]; then
185+
FIRST_ARCH_DIR="${arch_dir}"
186+
break
187+
fi
188+
done
189+
190+
if [[ -z "${FIRST_ARCH_DIR}" ]]; then
191+
echo "Error: No architecture directories found under distribute/" >&2
192+
exit 1
193+
fi
194+
195+
# Copy common files (everything except arch-specific binaries and checksums)
196+
# from the first arch directory.
197+
shopt -s nullglob
198+
for f in "${FIRST_ARCH_DIR}"/*; do
199+
filename="$(basename "${f}")"
200+
if [[ "${filename}" == apt_query-* ]] || [[ "${filename}" == checksums.txt ]]; then
201+
continue
202+
fi
203+
cp "${f}" "${RELEASE_DIR}/"
204+
echo "Copied common file: ${filename}"
205+
done
206+
shopt -u nullglob
207+
208+
# Copy architecture-specific binaries from every arch directory.
209+
shopt -s nullglob
210+
for arch_dir in "${ARCH_DIRS[@]}"; do
211+
[[ -d "${arch_dir}" ]] || continue
212+
for binary in "${arch_dir}"/apt_query-*; do
213+
cp "${binary}" "${RELEASE_DIR}/"
214+
echo "Copied binary: $(basename "${binary}")"
215+
done
216+
done
217+
shopt -u nullglob
218+
219+
# Generate a combined checksums file for all release assets.
220+
(cd "${RELEASE_DIR}" && find . -maxdepth 1 -type f ! -name "checksums.txt" \
221+
-exec sha256sum {} + | sed 's|\./||' | sort > checksums.txt)
222+
echo "Generated combined checksums:"
223+
cat "${RELEASE_DIR}/checksums.txt"
224+
225+
echo "Consolidation complete. Release directory contents:"
226+
ls -la "${RELEASE_DIR}/"
227+
;;
228+
167229
*)
168230
echo "Error: Unknown command: ${COMMAND}" >&2
169231
echo "Usage: distribute.sh <command> [args...]" >&2
@@ -175,6 +237,7 @@ case "${COMMAND}" in
175237
echo " generate-checksums <arch>" >&2
176238
echo " verify-build <arch>" >&2
177239
echo " reorganize-artifacts" >&2
240+
echo " consolidate-release" >&2
178241
exit 1
179242
;;
180243

0 commit comments

Comments
 (0)