Skip to content

Commit 90c3573

Browse files
committed
ci: a versioned release is complete only with its APK and mapping; the tagged build adds whichever is missing (Qodo on #183)
1 parent b6e980b commit 90c3573

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,24 +159,29 @@ jobs:
159159
cp decoder-v2-mapping.txt "$MAP"
160160
ASSETS+=("$MAP")
161161
fi
162-
# An existing release is complete only with its APK (Qodo on #158)
163-
has_apk() {
164-
gh release view "$TAG" --json assets -q '.assets[].name' 2>/dev/null | grep -qx "$APK"
162+
# An existing release is complete only with its APK (Qodo on #158) and, when this build
163+
# has one, its mapping (Qodo on #183). Fills MISSING with what it lacks
164+
complete() {
165+
local have
166+
have=$(gh release view "$TAG" --json assets -q '.assets[].name' 2>/dev/null) || have=""
167+
MISSING=()
168+
for a in "${ASSETS[@]}"; do grep -qx "$a" <<< "$have" || MISSING+=("$a"); done
169+
[ ${#MISSING[@]} -eq 0 ]
165170
}
166-
# Only the build of the tagged commit may add the missing APK (Qodo on #158)
167-
repair_apk() {
171+
# Only the build of the tagged commit may add the missing files (Qodo on #158)
172+
repair() {
168173
TAGGED=$(gh api "repos/${{ github.repository }}/commits/$TAG" -q .sha)
169174
if [ "$TAGGED" = "$(git rev-parse HEAD)" ]; then
170-
gh release upload "$TAG" "${ASSETS[@]}" --clobber
175+
gh release upload "$TAG" "${MISSING[@]}" --clobber
171176
else
172-
echo "::warning::$TAG has no $APK and points to ${TAGGED:0:7}, not this build"
177+
echo "::warning::$TAG has no ${MISSING[*]} and points to ${TAGGED:0:7}, not this build"
173178
fi
174179
}
175180
if gh release view "$TAG" >/dev/null 2>&1; then
176-
if has_apk; then
181+
if complete; then
177182
echo "Release $TAG exists: only latest was updated"
178183
else
179-
repair_apk
184+
repair
180185
fi
181186
exit 0
182187
fi
@@ -195,9 +200,9 @@ jobs:
195200
if ! gh release create "$TAG" "${ASSETS[@]}" --target "$(git rev-parse HEAD)" \
196201
--title "OpenIPC Decoder ${VER}" --latest=false "${NOTES[@]}"; then
197202
# Another build of the same version created it meanwhile, or the upload failed:
198-
# the release must exist and carry the APK, else the step fails
203+
# the release must exist and carry the APK and the mapping, else the step fails
199204
gh release view "$TAG" >/dev/null
200-
has_apk || repair_apk
205+
complete || repair
201206
fi
202207
203208
- name: Telegram

0 commit comments

Comments
 (0)