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:
|
with:
|
||||||
path: artifacts
|
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
|
- name: Checkout code for git log
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -511,79 +519,72 @@ jobs:
|
|||||||
mkdir -p r2-upload/unstable/latest
|
mkdir -p r2-upload/unstable/latest
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy and rename artifacts with metadata
|
# Helper function to copy artifact
|
||||||
if [ -f artifacts/android-apk/app-release.apk ]; then
|
copy_artifact() {
|
||||||
cp artifacts/android-apk/app-release.apk \
|
local src_path="$1"
|
||||||
"r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}.apk"
|
local dest_name="$2"
|
||||||
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
local platform="$3"
|
||||||
cp artifacts/android-apk/app-release.apk \
|
|
||||||
"r2-upload/unstable/latest/meshcore-sar-latest.apk"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f artifacts/android-appbundle/app-release.aab ]; then
|
if [ -f "$src_path" ]; then
|
||||||
cp artifacts/android-appbundle/app-release.aab \
|
echo "✅ Copying $platform: $src_path"
|
||||||
"r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}.aab"
|
cp "$src_path" \
|
||||||
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
"r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/$dest_name"
|
||||||
cp artifacts/android-appbundle/app-release.aab \
|
|
||||||
"r2-upload/unstable/latest/meshcore-sar-latest.aab"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f artifacts/macos-dmg/MeshCore-SAR.dmg ]; then
|
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
||||||
cp artifacts/macos-dmg/MeshCore-SAR.dmg \
|
local latest_name="${dest_name/${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}/latest}"
|
||||||
"r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}.dmg"
|
cp "$src_path" "r2-upload/unstable/latest/$latest_name"
|
||||||
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
fi
|
||||||
cp artifacts/macos-dmg/MeshCore-SAR.dmg \
|
return 0
|
||||||
"r2-upload/unstable/latest/meshcore-sar-latest.dmg"
|
else
|
||||||
|
echo "⚠️ Skipping $platform: $src_path not found"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
if [ -f artifacts/windows-executable/MeshCore-SAR-Windows.zip ]; then
|
# Copy Android APK
|
||||||
cp artifacts/windows-executable/MeshCore-SAR-Windows.zip \
|
copy_artifact \
|
||||||
"r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}-windows.zip"
|
"artifacts/android-apk/app-release.apk" \
|
||||||
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
"meshcore-sar-${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}.apk" \
|
||||||
cp artifacts/windows-executable/MeshCore-SAR-Windows.zip \
|
"Android APK"
|
||||||
"r2-upload/unstable/latest/meshcore-sar-latest-windows.zip"
|
|
||||||
fi
|
# Copy Android App Bundle
|
||||||
fi
|
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
|
# Copy commits data
|
||||||
if [ -f commits.json ]; then
|
if [ -f commits.json ]; then
|
||||||
|
echo "✅ Copying commits.json"
|
||||||
cp commits.json "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/"
|
cp commits.json "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/"
|
||||||
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
||||||
cp commits.json "r2-upload/unstable/latest/"
|
cp commits.json "r2-upload/unstable/latest/"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "⚠️ commits.json not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a build manifest
|
echo ""
|
||||||
cat > "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/manifest.json" <<EOF
|
echo "=== Preparation Summary ==="
|
||||||
{
|
echo "Files prepared in r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}:"
|
||||||
"build_id": "${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}",
|
ls -lh "r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }}/" || echo " (none)"
|
||||||
"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
|
|
||||||
|
|
||||||
# Create manifest for 'latest' if main branch
|
|
||||||
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then
|
||||||
cat > "r2-upload/unstable/latest/manifest.json" <<EOF
|
echo ""
|
||||||
{
|
echo "Files prepared in r2-upload/unstable/latest:"
|
||||||
"build_id": "${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}",
|
ls -lh "r2-upload/unstable/latest/" || echo " (none)"
|
||||||
"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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Generate index.html
|
- name: Generate index.html
|
||||||
@@ -936,7 +937,9 @@ jobs:
|
|||||||
|
|
||||||
# Add commit history section
|
# Add commit history section
|
||||||
if [ -f "$BUILD_DIR/commits.json" ]; then
|
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>
|
||||||
|
|
||||||
<div class="commits-section">
|
<div class="commits-section">
|
||||||
@@ -957,42 +960,39 @@ jobs:
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Load and display commits
|
// Embedded commits data (no fetch needed)
|
||||||
fetch('commits.json')
|
const commitsData = ${COMMITS_DATA};
|
||||||
.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
list.innerHTML = commits.map(commit => {
|
// Display commits
|
||||||
const date = new Date(commit.date);
|
(function() {
|
||||||
const dateStr = date.toLocaleString('en-US', {
|
const list = document.getElementById('commits-list');
|
||||||
year: 'numeric',
|
if (!commitsData || commitsData.length === 0) {
|
||||||
month: 'short',
|
list.innerHTML = '<p style="color: #888;">No commit data available</p>';
|
||||||
day: 'numeric',
|
return;
|
||||||
hour: '2-digit',
|
}
|
||||||
minute: '2-digit'
|
|
||||||
});
|
|
||||||
|
|
||||||
return \`
|
list.innerHTML = commitsData.map(commit => {
|
||||||
<div class="commit-item">
|
const date = new Date(commit.date);
|
||||||
<div class="commit-header">
|
const dateStr = date.toLocaleString('en-US', {
|
||||||
<span class="commit-hash">\${commit.hash}</span>
|
year: 'numeric',
|
||||||
<span class="commit-date">\${dateStr}</span>
|
month: 'short',
|
||||||
</div>
|
day: 'numeric',
|
||||||
<div class="commit-message">\${commit.message}</div>
|
hour: '2-digit',
|
||||||
<div class="commit-author">by \${commit.author}</div>
|
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>
|
</div>
|
||||||
\`;
|
<div class="commit-message">\${commit.message}</div>
|
||||||
}).join('');
|
<div class="commit-author">by \${commit.author}</div>
|
||||||
})
|
</div>
|
||||||
.catch(error => {
|
\`;
|
||||||
document.getElementById('commits-list').innerHTML =
|
}).join('');
|
||||||
'<p style="color: #888;">Failed to load commits</p>';
|
})();
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1035,6 +1035,52 @@ jobs:
|
|||||||
ls -lah "$LATEST_DIR/"
|
ls -lah "$LATEST_DIR/"
|
||||||
fi
|
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
|
- name: Upload build-specific artifacts to Cloudflare R2
|
||||||
uses: ryand56/r2-upload-action@latest
|
uses: ryand56/r2-upload-action@latest
|
||||||
with:
|
with:
|
||||||
|
|||||||
Reference in New Issue
Block a user