Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Commit d6ee16f

Browse files
committed
fix srcbuild upload
1 parent c7b296c commit d6ee16f

1 file changed

Lines changed: 65 additions & 63 deletions

File tree

.github/workflows/matrix_builds.yaml

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -303,70 +303,72 @@ jobs:
303303
set +x ; set +e
304304
#--------------#
305305
##Set ENV
306-
if [[ "${SKIP_SRCBUILD_UPLOAD}" != "YES" ]]; then
307-
#GHCRPKG_TAG_SRCBUILD="srcbuild.$(date --utc +"%y%m%dT%H%M%S" | tr -d '[:space:]')-${{ env.GHCRPKG_TAG }}"
308-
GHCRPKG_TAG_SRCBUILD="${{ env.GHCRPKG_TAG }}"
309-
GHCRPKG_URL_SRCBUILD="${{ env.GHCRPKG_LOCAL }}/${{ env.PKG_FAMILY_LOCAL }}-srcbuild-${{ env.BUILD_ID }}"
310-
export GHCRPKG_TAG_SRCBUILD GHCRPKG_URL_SRCBUILD
311-
echo "GHCRPKG_TAG_SRCBUILD=${GHCRPKG_TAG_SRCBUILD}" >> "${GITHUB_ENV}"
312-
echo "GHCRPKG_URL_SRCBUILD=${GHCRPKG_URL_SRCBUILD}" >> "${GITHUB_ENV}"
313-
fi
314-
##Push
315-
if [[ -n "${GHCRPKG_TAG_SRCBUILD+x}" ]]; then
316-
pushd "/tmp" &>/dev/null
317-
if [[ -s "./BUILD_ARTIFACTS.7z" && $(stat -c%s "./BUILD_ARTIFACTS.7z") -gt 1000 ]]; then
318-
realpath "./BUILD_ARTIFACTS.7z" && du -sh "./BUILD_ARTIFACTS.7z"
319-
ls -sh "${{ env.SBUILD_OUTDIR }}"
320-
ghcr_push_cmd()
321-
{
322-
for i in {1..10}; do
323-
unset ghcr_push ; ghcr_push=(oras push --disable-path-validation)
324-
ghcr_push+=(--config "/dev/null:application/vnd.oci.empty.v1+json")
325-
ghcr_push+=(--annotation "com.github.package.type=container")
326-
ghcr_push+=(--annotation "dev.pkgforge.soar.build_ghcrpkg-tag=${{ env.GHCRPKG_TAG }}")
327-
ghcr_push+=(--annotation "dev.pkgforge.soar.build_gha=${{ env.BUILD_GHACTIONS }}")
328-
ghcr_push+=(--annotation "dev.pkgforge.soar.build_id=${{ env.BUILD_ID }}")
329-
ghcr_push+=(--annotation "dev.pkgforge.soar.ghcr_pkg=${{ env.GHCRPKG_URL }}:${{ env.GHCRPKG_TAG }}")
330-
ghcr_push+=(--annotation "dev.pkgforge.soar.push_date=${{ env.PKG_DATE }}")
331-
ghcr_push+=(--annotation "dev.pkgforge.soar.version=${{ env.PKG_VERSION }}")
332-
ghcr_push+=(--annotation "org.opencontainers.image.created=${{ env.PKG_DATE }}")
333-
ghcr_push+=(--annotation "org.opencontainers.image.description=SRCBUILD for ${{ env.GHCRPKG_URL }}")
334-
ghcr_push+=(--annotation "org.opencontainers.image.licenses=blessing")
335-
ghcr_push+=(--annotation "org.opencontainers.image.ref.name=${{ env.PKG_VERSION }}")
336-
ghcr_push+=(--annotation "org.opencontainers.image.revision=${{ env.PKG_VERSION }}")
337-
ghcr_push+=(--annotation "org.opencontainers.image.source=${{ env.PKG_WEBPAGE }}")
338-
ghcr_push+=(--annotation "org.opencontainers.image.title=SRCBUILD-${{ env.PKG_FAMILY_LOCAL }}")
339-
ghcr_push+=(--annotation "org.opencontainers.image.url=${{ env.PKG_SRCURL }}")
340-
ghcr_push+=(--annotation "org.opencontainers.image.vendor=pkgforge")
341-
ghcr_push+=(--annotation "org.opencontainers.image.version=${{ env.PKG_VERSION }}")
342-
ghcr_push+=("${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}")
343-
[[ -f "./BUILD_ARTIFACTS.7z" && -s "./BUILD_ARTIFACTS.7z" ]] && ghcr_push+=("./BUILD_ARTIFACTS.7z")
344-
"${ghcr_push[@]}" ; sleep 5
345-
#Check
346-
if [[ "$(oras manifest fetch "${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}" | jq -r '.annotations["dev.pkgforge.soar.push_date"]' | tr -d '[:space:]')" == "${{ env.PKG_DATE }}" ]]; then
347-
echo -e "\n[+] (ARTIFACTS) Registry --> https://${GHCRPKG_URL_SRCBUILD}\n"
348-
break
349-
else
350-
echo -e "\n[-] Failed to Push Artifact to ${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD} (Retrying ${i}/10)\n"
351-
fi
352-
sleep "$(shuf -i 500-4500 -n 1)e-3"
353-
done
354-
}
355-
export -f ghcr_push_cmd
356-
ghcr_push_cmd
357-
if [[ "$(oras manifest fetch "${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}" | jq -r '.annotations["dev.pkgforge.soar.push_date"]' | tr -d '[:space:]')" != "${{ env.PKG_DATE }}" ]]; then
358-
echo -e "\n[✗] Failed to Push Artifact to ${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}\n"
359-
echo -e "\n[-] Retrying ...\n"
360-
ghcr_push_cmd
361-
if [[ "$(oras manifest fetch "${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}" | jq -r '.annotations["dev.pkgforge.soar.push_date"]' | tr -d '[:space:]')" != "${{ env.PKG_DATE }}" ]]; then
362-
oras manifest fetch "${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}" | jq .
363-
echo -e "\n[✗] Failed to Push Artifact to ${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}\n"
364-
return 1 || exit 1
306+
if [[ -n "${{ env.BUILD_ID }}" ]] && [[ "${{ env.BUILD_ID }}" =~ ^[^[:space:]]+$ ]]; then
307+
if [[ "${SKIP_SRCBUILD_UPLOAD}" != "YES" ]]; then
308+
#GHCRPKG_TAG_SRCBUILD="srcbuild.$(date --utc +"%y%m%dT%H%M%S" | tr -d '[:space:]')-${{ env.GHCRPKG_TAG }}"
309+
GHCRPKG_TAG_SRCBUILD="${{ env.GHCRPKG_TAG }}"
310+
GHCRPKG_URL_SRCBUILD="${{ env.GHCRPKG_LOCAL }}/${{ env.PKG_FAMILY_LOCAL }}-srcbuild-${{ env.BUILD_ID }}"
311+
export GHCRPKG_TAG_SRCBUILD GHCRPKG_URL_SRCBUILD
312+
echo "GHCRPKG_TAG_SRCBUILD=${GHCRPKG_TAG_SRCBUILD}" >> "${GITHUB_ENV}"
313+
echo "GHCRPKG_URL_SRCBUILD=${GHCRPKG_URL_SRCBUILD}" >> "${GITHUB_ENV}"
314+
fi
315+
##Push
316+
if [[ -n "${GHCRPKG_TAG_SRCBUILD+x}" ]]; then
317+
pushd "/tmp" &>/dev/null
318+
if [[ -s "./BUILD_ARTIFACTS.7z" && $(stat -c%s "./BUILD_ARTIFACTS.7z") -gt 1000 ]]; then
319+
realpath "./BUILD_ARTIFACTS.7z" && du -sh "./BUILD_ARTIFACTS.7z"
320+
ls -sh "${{ env.SBUILD_OUTDIR }}"
321+
ghcr_push_cmd()
322+
{
323+
for i in {1..10}; do
324+
unset ghcr_push ; ghcr_push=(oras push --disable-path-validation)
325+
ghcr_push+=(--config "/dev/null:application/vnd.oci.empty.v1+json")
326+
ghcr_push+=(--annotation "com.github.package.type=container")
327+
ghcr_push+=(--annotation "dev.pkgforge.soar.build_ghcrpkg-tag=${{ env.GHCRPKG_TAG }}")
328+
ghcr_push+=(--annotation "dev.pkgforge.soar.build_gha=${{ env.BUILD_GHACTIONS }}")
329+
ghcr_push+=(--annotation "dev.pkgforge.soar.build_id=${{ env.BUILD_ID }}")
330+
ghcr_push+=(--annotation "dev.pkgforge.soar.ghcr_pkg=${{ env.GHCRPKG_URL }}:${{ env.GHCRPKG_TAG }}")
331+
ghcr_push+=(--annotation "dev.pkgforge.soar.push_date=${{ env.PKG_DATE }}")
332+
ghcr_push+=(--annotation "dev.pkgforge.soar.version=${{ env.PKG_VERSION }}")
333+
ghcr_push+=(--annotation "org.opencontainers.image.created=${{ env.PKG_DATE }}")
334+
ghcr_push+=(--annotation "org.opencontainers.image.description=SRCBUILD for ${{ env.GHCRPKG_URL }}")
335+
ghcr_push+=(--annotation "org.opencontainers.image.licenses=blessing")
336+
ghcr_push+=(--annotation "org.opencontainers.image.ref.name=${{ env.PKG_VERSION }}")
337+
ghcr_push+=(--annotation "org.opencontainers.image.revision=${{ env.PKG_VERSION }}")
338+
ghcr_push+=(--annotation "org.opencontainers.image.source=${{ env.PKG_WEBPAGE }}")
339+
ghcr_push+=(--annotation "org.opencontainers.image.title=SRCBUILD-${{ env.PKG_FAMILY_LOCAL }}")
340+
ghcr_push+=(--annotation "org.opencontainers.image.url=${{ env.PKG_SRCURL }}")
341+
ghcr_push+=(--annotation "org.opencontainers.image.vendor=pkgforge")
342+
ghcr_push+=(--annotation "org.opencontainers.image.version=${{ env.PKG_VERSION }}")
343+
ghcr_push+=("${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}")
344+
[[ -f "./BUILD_ARTIFACTS.7z" && -s "./BUILD_ARTIFACTS.7z" ]] && ghcr_push+=("./BUILD_ARTIFACTS.7z")
345+
"${ghcr_push[@]}" ; sleep 5
346+
#Check
347+
if [[ "$(oras manifest fetch "${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}" | jq -r '.annotations["dev.pkgforge.soar.push_date"]' | tr -d '[:space:]')" == "${{ env.PKG_DATE }}" ]]; then
348+
echo -e "\n[+] (ARTIFACTS) Registry --> https://${GHCRPKG_URL_SRCBUILD}\n"
349+
break
350+
else
351+
echo -e "\n[-] Failed to Push Artifact to ${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD} (Retrying ${i}/10)\n"
365352
fi
366-
fi
367-
fi
368-
fi
369-
popd >/dev/null 2>&1
353+
sleep "$(shuf -i 500-4500 -n 1)e-3"
354+
done
355+
}
356+
export -f ghcr_push_cmd
357+
ghcr_push_cmd
358+
if [[ "$(oras manifest fetch "${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}" | jq -r '.annotations["dev.pkgforge.soar.push_date"]' | tr -d '[:space:]')" != "${{ env.PKG_DATE }}" ]]; then
359+
echo -e "\n[✗] Failed to Push Artifact to ${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}\n"
360+
echo -e "\n[-] Retrying ...\n"
361+
ghcr_push_cmd
362+
if [[ "$(oras manifest fetch "${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}" | jq -r '.annotations["dev.pkgforge.soar.push_date"]' | tr -d '[:space:]')" != "${{ env.PKG_DATE }}" ]]; then
363+
oras manifest fetch "${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}" | jq .
364+
echo -e "\n[✗] Failed to Push Artifact to ${GHCRPKG_URL_SRCBUILD}:${GHCRPKG_TAG_SRCBUILD}\n"
365+
return 1 || exit 1
366+
fi
367+
fi
368+
fi
369+
fi
370+
popd >/dev/null 2>&1
371+
fi
370372
continue-on-error: true
371373

372374
##Logs & Artifacts

0 commit comments

Comments
 (0)