From 049199fdfb31d039f7da8b5c0ad0fd8380777855 Mon Sep 17 00:00:00 2001 From: Janez T Date: Wed, 22 Oct 2025 17:18:50 +0200 Subject: [PATCH] feat: Enhance artifact handling in CI workflow with verification and manifest generation --- .github/workflows/build-multiplatform.yml | 230 +++++++++++++--------- 1 file changed, 138 insertions(+), 92 deletions(-) diff --git a/.github/workflows/build-multiplatform.yml b/.github/workflows/build-multiplatform.yml index 6c51b10..b102226 100644 --- a/.github/workflows/build-multiplatform.yml +++ b/.github/workflows/build-multiplatform.yml @@ -461,6 +461,14 @@ jobs: with: path: artifacts + - name: Verify downloaded artifacts + run: | + echo "=== Verifying downloaded artifacts structure ===" + ls -lah artifacts/ || echo "No artifacts directory found!" + echo "" + echo "=== All files in artifacts directory ===" + find artifacts -type f -ls || echo "No files found!" + - name: Checkout code for git log uses: actions/checkout@v4 with: @@ -511,79 +519,72 @@ jobs: mkdir -p r2-upload/unstable/latest fi - # Copy and rename artifacts with metadata - if [ -f artifacts/android-apk/app-release.apk ]; then - cp artifacts/android-apk/app-release.apk \ - "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}.apk" - if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then - cp artifacts/android-apk/app-release.apk \ - "r2-upload/unstable/latest/meshcore-sar-latest.apk" - fi - fi + # Helper function to copy artifact + copy_artifact() { + local src_path="$1" + local dest_name="$2" + local platform="$3" - if [ -f artifacts/android-appbundle/app-release.aab ]; then - cp artifacts/android-appbundle/app-release.aab \ - "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}.aab" - if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then - cp artifacts/android-appbundle/app-release.aab \ - "r2-upload/unstable/latest/meshcore-sar-latest.aab" - fi - fi + if [ -f "$src_path" ]; then + echo "✅ Copying $platform: $src_path" + cp "$src_path" \ + "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/$dest_name" - if [ -f artifacts/macos-dmg/MeshCore-SAR.dmg ]; then - cp artifacts/macos-dmg/MeshCore-SAR.dmg \ - "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}.dmg" - if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then - cp artifacts/macos-dmg/MeshCore-SAR.dmg \ - "r2-upload/unstable/latest/meshcore-sar-latest.dmg" + if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then + local latest_name="${dest_name/${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}/latest}" + cp "$src_path" "r2-upload/unstable/latest/$latest_name" + fi + return 0 + else + echo "⚠️ Skipping $platform: $src_path not found" + return 1 fi - fi + } - if [ -f artifacts/windows-executable/MeshCore-SAR-Windows.zip ]; then - cp artifacts/windows-executable/MeshCore-SAR-Windows.zip \ - "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}-windows.zip" - if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then - cp artifacts/windows-executable/MeshCore-SAR-Windows.zip \ - "r2-upload/unstable/latest/meshcore-sar-latest-windows.zip" - fi - fi + # Copy Android APK + copy_artifact \ + "artifacts/android-apk/app-release.apk" \ + "meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}.apk" \ + "Android APK" + + # Copy Android App Bundle + copy_artifact \ + "artifacts/android-appbundle/app-release.aab" \ + "meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}.aab" \ + "Android App Bundle" + + # Copy macOS DMG + copy_artifact \ + "artifacts/macos-dmg/MeshCore-SAR.dmg" \ + "meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}.dmg" \ + "macOS DMG" + + # Copy Windows ZIP + copy_artifact \ + "artifacts/windows-executable/MeshCore-SAR-Windows.zip" \ + "meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}-windows.zip" \ + "Windows ZIP" # Copy commits data if [ -f commits.json ]; then + echo "✅ Copying commits.json" cp commits.json "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/" if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then cp commits.json "r2-upload/unstable/latest/" fi + else + echo "⚠️ commits.json not found" fi - # Create a build manifest - cat > "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/manifest.json" < "r2-upload/unstable/latest/manifest.json" <> "$BUILD_DIR/index.html" <<'HTMLEOF' + # Read commits JSON and embed it directly in the HTML + COMMITS_DATA=$(cat "$BUILD_DIR/commits.json") + cat >> "$BUILD_DIR/index.html" <
@@ -957,42 +960,39 @@ jobs:
@@ -1035,6 +1035,52 @@ jobs: ls -lah "$LATEST_DIR/" fi + - name: Create build manifests + run: | + # Create manifest for build-specific directory (after index.html is generated) + cat > "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/manifest.json" < "r2-upload/unstable/latest/manifest.json" <