@@ -198,7 +198,7 @@ jobs:
198198 needs : [build-light, build-heavy]
199199 runs-on : ubuntu-latest
200200 if : always() && (github.event_name != 'schedule' || github.ref == 'refs/heads/update/components')
201- continue-on-error : true
201+ continue-on-error : ${{ github.ref != 'refs/heads/main' }}
202202 steps :
203203
204204 # Clone Repository (pull_request_target)
@@ -231,7 +231,60 @@ jobs:
231231 fi
232232 done
233233
234+ - name : Generate a token for Rekku
235+ id : generate-rekku-token
236+ uses : actions/create-github-app-token@v1
237+ with :
238+ app-id : ${{ vars.REKKU_APP_ID }}
239+ private-key : ${{ secrets.REKKU_PRIVATE_KEY }}
240+ repositories : " components"
241+ owner : " RetroDECK"
242+
243+ # This will generate desired_versions.sh based on the current state of the components
244+ # Useful to "lock" the versions in future builds or to bring it to main (manually)
245+ - name : Generate desired_versions.sh (snapshot)
246+ env :
247+ GITHUB_TOKEN : ${{ steps.generate-rekku-token.outputs.token }}
248+ run : |
249+ set -e
250+ automation-tools/alchemist/generate_desired_versions.sh -f automation-tools/alchemist/desired_versions.sh
251+ latest_generated="$(ls -1t automation-tools/alchemist/desired_versions_*.sh | head -n 1)"
252+ if [ -z "$latest_generated" ] || [ ! -f "$latest_generated" ]; then
253+ echo "[ERROR] desired_versions generator did not produce an output file" >&2
254+ exit 1
255+ fi
256+ cp -f "$latest_generated" desired_versions.sh
257+
258+ - name : Fallback missing component artifacts from releases (non-main)
259+ if : github.ref != 'refs/heads/main'
260+ env :
261+ GITHUB_TOKEN : ${{ steps.generate-rekku-token.outputs.token }}
262+ GITHUB_REPOSITORY : ${{ github.repository }}
263+ MATCH_LABEL : cooker
264+ FALLBACK_COMPONENTS_FILE : fallback_components.txt
265+ MISSING_COMPONENTS_FILE : missing_components.txt
266+ run : |
267+ bash automation-tools/fallback_release_artifacts.sh
268+
269+ - name : Fail on missing artifacts (main only)
270+ if : github.ref == 'refs/heads/main'
271+ run : |
272+ set -e
273+ MISSING_ARTIFACTS=()
274+ for folder in $(find . -maxdepth 2 -mindepth 2 -type f \( -name 'component_recipe.json' -o -name 'component_manifest.json' \) -printf '%h\n' | sed 's|^\./||' | sort -u); do
275+ if [ ! -d "$folder/artifacts" ] || ! find "$folder/artifacts" -maxdepth 1 -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.gz" -o -name "*.tar" -o -name "*.7z" -o -name "*.appimage" \) | grep -q .; then
276+ MISSING_ARTIFACTS+=("$folder")
277+ fi
278+ done
279+ if [ ${#MISSING_ARTIFACTS[@]} -ne 0 ]; then
280+ echo "[ERROR] Missing artifacts on main; failing build. Missing:" >&2
281+ printf '%s\n' "${MISSING_ARTIFACTS[@]}" >&2
282+ exit 1
283+ fi
284+
234285 - name : Generate components_version_list.md
286+ env :
287+ FALLBACK_COMPONENTS_FILE : fallback_components.txt
235288 run : |
236289 # Loop through each <component_name> folder
237290 for component_dir in */; do
@@ -240,6 +293,11 @@ jobs:
240293 continue
241294 fi
242295
296+ # Only process real components
297+ if [[ ! -f "${component_dir}component_recipe.json" && ! -f "${component_dir}component_manifest.json" ]]; then
298+ continue
299+ fi
300+
243301 # Path to artifacts directory
244302 artifacts_dir="${component_dir}artifacts"
245303
@@ -280,15 +338,6 @@ jobs:
280338
281339 # Show the resulting components_version_list.md file
282340 cat components_version_list.md
283- - name : Generate a token for Rekku
284- id : generate-rekku-token
285- uses : actions/create-github-app-token@v1
286- with :
287- app-id : ${{ vars.REKKU_APP_ID }}
288- private-key : ${{ secrets.REKKU_PRIVATE_KEY }}
289- repositories : " components"
290- owner : " RetroDECK"
291-
292341 - name : Get Branch Name
293342 run : |
294343 if [[ "$GITHUB_EVENT_NAME" == "pull_request" || "$GITHUB_EVENT_NAME" == "pull_request_target" ]]; then
@@ -348,6 +397,16 @@ jobs:
348397 echo "This is a RetroDECK Components Artifacts release from [this commit](https://github.com/${{ github.repository }}/commit/${{ github.sha }}), from branch [${{ env.BRANCH_NAME }}](https://github.com/RetroDECK/RetroDECK/tree/feat/${{ env.BRANCH_NAME }})." >> "$RELEASE_BODY_FILE"
349398 echo "" >> "$RELEASE_BODY_FILE"
350399
400+ # Fallback warnings (if any)
401+ if [ -f "fallback_components.txt" ] && [ -s "fallback_components.txt" ]; then
402+ echo "[WARNING] Fallback artifacts were used for the following components:" >> "$RELEASE_BODY_FILE"
403+ while IFS='|' read -r comp tag; do
404+ [ -z "$comp" ] && continue
405+ echo "- $comp (from release $tag)" >> "$RELEASE_BODY_FILE"
406+ done < fallback_components.txt
407+ echo "" >> "$RELEASE_BODY_FILE"
408+ fi
409+
351410 # Append the contents of components_version_list.md to the release body
352411 cat components_version_list.md >> "$RELEASE_BODY_FILE"
353412 echo "" >> "$RELEASE_BODY_FILE"
@@ -356,7 +415,7 @@ jobs:
356415 MISSING_ARTIFACTS=()
357416
358417 # Iterate through folders in the repo root
359- for folder in $(find . -maxdepth 1 -mindepth 1 -type d -not -name '.* ' -not -name 'automation-tools' -not -name 'downloaded-artifacts' -exec basename {} \; ); do
418+ for folder in $(find . -maxdepth 2 -mindepth 2 -type f \( -name 'component_recipe.json ' -o -name 'component_manifest.json' \) -printf '%h\n' | sed 's|^\./||' | sort -u ); do
360419 if [ ! -d "$folder/artifacts" ] || ! find "$folder/artifacts" -maxdepth 1 -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.gz" -o -name "*.tar" -o -name "*.7z" -o -name "*.appimage" \) | grep -q .; then
361420 MISSING_ARTIFACTS+=("$folder")
362421 fi
@@ -420,7 +479,7 @@ jobs:
420479 tag : " ${{ env.TAG }}"
421480 name : " RetroDECK Components ${{ env.TAG }}"
422481 body : ${{ steps.generate-body.outputs.RELEASE_BODY }}
423- artifacts : " */artifacts/*,!*/artifacts/component_version,components_version_list.md"
482+ artifacts : " */artifacts/*,!*/artifacts/component_version,components_version_list.md,desired_versions.sh "
424483 allowUpdates : true
425484 omitBodyDuringUpdate : true
426485 makeLatest : ${{ env.MAKE_LATEST }}
@@ -456,6 +515,16 @@ jobs:
456515 echo "## RetroDECK Components Artifacts" > pr_body.md
457516 echo "" >> pr_body.md
458517 echo "This pull request updates the RetroDECK components artifacts to version ${{ env.TAG }}." >> pr_body.md
518+ echo "" >> pr_body.md
519+
520+ if [ -f "fallback_components.txt" ] && [ -s "fallback_components.txt" ]; then
521+ echo "### WARNING: Fallback artifacts used" >> pr_body.md
522+ while IFS='|' read -r comp tag; do
523+ [ -z "$comp" ] && continue
524+ echo "- $comp (from release $tag)" >> pr_body.md
525+ done < fallback_components.txt
526+ echo "" >> pr_body.md
527+ fi
459528
460529 echo "## Changes:" >> pr_body.md
461530 echo "$(cat commits_list.txt)" >> pr_body.md
0 commit comments