mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
feat: Enhance artifact handling in CI workflow with verification and manifest generation
This commit is contained in:
230
.github/workflows/build-multiplatform.yml
vendored
230
.github/workflows/build-multiplatform.yml
vendored
@@ -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" <<EOF
|
||||
{
|
||||
"build_id": "${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}",
|
||||
"commit": "${{ github.sha }}",
|
||||
"commit_short": "${{ steps.metadata.outputs.commit_short }}",
|
||||
"branch": "${{ steps.metadata.outputs.branch_name }}",
|
||||
"tag": "${GITHUB_REF#refs/tags/}",
|
||||
"timestamp": "${{ steps.metadata.outputs.timestamp }}",
|
||||
"workflow_run": "${{ github.run_number }}",
|
||||
"artifacts": $(ls -1 r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/ | grep -v manifest.json | grep -v commits.json | jq -R . | jq -s .)
|
||||
}
|
||||
EOF
|
||||
echo ""
|
||||
echo "=== Preparation Summary ==="
|
||||
echo "Files prepared in r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}:"
|
||||
ls -lh "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/" || echo " (none)"
|
||||
|
||||
# Create manifest for 'latest' if main branch
|
||||
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
||||
cat > "r2-upload/unstable/latest/manifest.json" <<EOF
|
||||
{
|
||||
"build_id": "${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}",
|
||||
"commit": "${{ github.sha }}",
|
||||
"commit_short": "${{ steps.metadata.outputs.commit_short }}",
|
||||
"branch": "${{ steps.metadata.outputs.branch_name }}",
|
||||
"tag": "${GITHUB_REF#refs/tags/}",
|
||||
"timestamp": "${{ steps.metadata.outputs.timestamp }}",
|
||||
"workflow_run": "${{ github.run_number }}",
|
||||
"artifacts": $(ls -1 r2-upload/unstable/latest/ | grep -v manifest.json | grep -v commits.json | jq -R . | jq -s .)
|
||||
}
|
||||
EOF
|
||||
echo ""
|
||||
echo "Files prepared in r2-upload/unstable/latest:"
|
||||
ls -lh "r2-upload/unstable/latest/" || echo " (none)"
|
||||
fi
|
||||
|
||||
- name: Generate index.html
|
||||
@@ -936,7 +937,9 @@ jobs:
|
||||
|
||||
# Add commit history section
|
||||
if [ -f "$BUILD_DIR/commits.json" ]; then
|
||||
cat >> "$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" <<HTMLEOF
|
||||
</div>
|
||||
|
||||
<div class="commits-section">
|
||||
@@ -957,42 +960,39 @@ jobs:
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Load and display commits
|
||||
fetch('commits.json')
|
||||
.then(response => response.json())
|
||||
.then(commits => {
|
||||
const list = document.getElementById('commits-list');
|
||||
if (commits.length === 0) {
|
||||
list.innerHTML = '<p style="color: #888;">No commit data available</p>';
|
||||
return;
|
||||
}
|
||||
// Embedded commits data (no fetch needed)
|
||||
const commitsData = ${COMMITS_DATA};
|
||||
|
||||
list.innerHTML = commits.map(commit => {
|
||||
const date = new Date(commit.date);
|
||||
const dateStr = date.toLocaleString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
// Display commits
|
||||
(function() {
|
||||
const list = document.getElementById('commits-list');
|
||||
if (!commitsData || commitsData.length === 0) {
|
||||
list.innerHTML = '<p style="color: #888;">No commit data available</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
return \`
|
||||
<div class="commit-item">
|
||||
<div class="commit-header">
|
||||
<span class="commit-hash">\${commit.hash}</span>
|
||||
<span class="commit-date">\${dateStr}</span>
|
||||
</div>
|
||||
<div class="commit-message">\${commit.message}</div>
|
||||
<div class="commit-author">by \${commit.author}</div>
|
||||
list.innerHTML = commitsData.map(commit => {
|
||||
const date = new Date(commit.date);
|
||||
const dateStr = date.toLocaleString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
|
||||
return \`
|
||||
<div class="commit-item">
|
||||
<div class="commit-header">
|
||||
<span class="commit-hash">\${commit.hash}</span>
|
||||
<span class="commit-date">\${dateStr}</span>
|
||||
</div>
|
||||
\`;
|
||||
}).join('');
|
||||
})
|
||||
.catch(error => {
|
||||
document.getElementById('commits-list').innerHTML =
|
||||
'<p style="color: #888;">Failed to load commits</p>';
|
||||
});
|
||||
<div class="commit-message">\${commit.message}</div>
|
||||
<div class="commit-author">by \${commit.author}</div>
|
||||
</div>
|
||||
\`;
|
||||
}).join('');
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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" <<EOF
|
||||
{
|
||||
"build_id": "${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}",
|
||||
"commit": "${{ github.sha }}",
|
||||
"commit_short": "${{ steps.metadata.outputs.commit_short }}",
|
||||
"branch": "${{ steps.metadata.outputs.branch_name }}",
|
||||
"tag": "${GITHUB_REF#refs/tags/}",
|
||||
"timestamp": "${{ steps.metadata.outputs.timestamp }}",
|
||||
"workflow_run": "${{ github.run_number }}",
|
||||
"artifacts": $(ls -1 r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/ | grep -v manifest.json | grep -v commits.json | jq -R . | jq -s .)
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "Generated manifest for build ${{ steps.metadata.outputs.build_prefix }}"
|
||||
cat "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/manifest.json"
|
||||
|
||||
# Create manifest for 'latest' if main branch
|
||||
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
||||
cat > "r2-upload/unstable/latest/manifest.json" <<EOF
|
||||
{
|
||||
"build_id": "${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}",
|
||||
"commit": "${{ github.sha }}",
|
||||
"commit_short": "${{ steps.metadata.outputs.commit_short }}",
|
||||
"branch": "${{ steps.metadata.outputs.branch_name }}",
|
||||
"tag": "${GITHUB_REF#refs/tags/}",
|
||||
"timestamp": "${{ steps.metadata.outputs.timestamp }}",
|
||||
"workflow_run": "${{ github.run_number }}",
|
||||
"artifacts": $(ls -1 r2-upload/unstable/latest/ | grep -v manifest.json | grep -v commits.json | jq -R . | jq -s .)
|
||||
}
|
||||
EOF
|
||||
echo "Generated manifest for latest"
|
||||
cat "r2-upload/unstable/latest/manifest.json"
|
||||
fi
|
||||
|
||||
# Final debug output
|
||||
echo "=== Final files ready for upload ==="
|
||||
echo "Build-specific directory:"
|
||||
ls -lah "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/"
|
||||
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
||||
echo "Latest directory:"
|
||||
ls -lah "r2-upload/unstable/latest/"
|
||||
fi
|
||||
|
||||
- name: Upload build-specific artifacts to Cloudflare R2
|
||||
uses: ryand56/r2-upload-action@latest
|
||||
with:
|
||||
|
||||
Reference in New Issue
Block a user