From 0d12ca0ae71503d06120cb0dff51fc5769554b3b Mon Sep 17 00:00:00 2001 From: Janez T Date: Wed, 22 Oct 2025 16:51:42 +0200 Subject: [PATCH] feat: Add download page details and structure for build artifacts in R2 setup documentation --- .github/R2_SETUP.md | 53 ++++- .github/workflows/build-multiplatform.yml | 265 ++++++++++++++++++++-- 2 files changed, 296 insertions(+), 22 deletions(-) diff --git a/.github/R2_SETUP.md b/.github/R2_SETUP.md index 8abd8c3..e8de5d4 100644 --- a/.github/R2_SETUP.md +++ b/.github/R2_SETUP.md @@ -7,9 +7,11 @@ This document describes how to configure Cloudflare R2 for automatic artifact up The CI/CD pipeline uploads build artifacts (APK, AAB, DMG, Windows ZIP) to a Cloudflare R2 bucket in the `unstable/` directory for every successful build. This provides: - **Automatic artifact hosting** for all branches and commits +- **Latest builds** from main branch always available at `unstable/latest/` - **Version tracking** with timestamps and commit hashes - **Public download URLs** (optional) for testers and developers - **Build manifests** with metadata for each build +- **Commit history** showing last 10 commits for each build ## Required GitHub Secrets @@ -122,22 +124,48 @@ Artifacts are uploaded with the following structure: ``` unstable/ +├── latest/ # ⭐ Always has the latest main branch build +│ ├── index.html # 🌐 Download page with last 10 commits +│ ├── meshcore-sar-latest.apk +│ ├── meshcore-sar-latest.aab +│ ├── meshcore-sar-latest.dmg +│ ├── meshcore-sar-latest-windows.zip +│ ├── manifest.json +│ └── commits.json # Last 10 commit messages ├── main-abc1234/ # Branch + commit hash +│ ├── index.html # 🌐 Download page with last 10 commits │ ├── meshcore-sar-main-abc1234-20241022-143022.apk │ ├── meshcore-sar-main-abc1234-20241022-143022.aab │ ├── meshcore-sar-main-abc1234-20241022-143022.dmg │ ├── meshcore-sar-main-abc1234-20241022-143022-windows.zip -│ └── manifest.json +│ ├── manifest.json +│ └── commits.json # Last 10 commit messages ├── v1.2.3/ # Release tag +│ ├── index.html # 🌐 Download page with last 10 commits │ ├── meshcore-sar-v1.2.3-20241022-150045.apk │ ├── meshcore-sar-v1.2.3-20241022-150045.aab │ ├── meshcore-sar-v1.2.3-20241022-150045.dmg │ ├── meshcore-sar-v1.2.3-20241022-150045-windows.zip -│ └── manifest.json +│ ├── manifest.json +│ └── commits.json # Last 10 commit messages └── develop-def5678/ └── ... ``` +### Download Page (index.html) + +Each build includes a beautiful, responsive HTML download page with: +- **Build Information**: Build ID, timestamp, commit hash, workflow run number +- **Download Buttons**: One-click downloads for all available platforms +- **File Sizes**: Displayed for each artifact +- **Commit History**: Last 10 commit messages with hash, date, author, and message +- **Direct Links**: Links to manifest.json, commits.json, and GitHub repository +- **Mobile Responsive**: Works perfectly on phones, tablets, and desktops + +Access the download pages: +- **Latest main branch build**: `https://meshcore-sar.dz0ny.dev/unstable/latest/` +- **Specific build**: `https://meshcore-sar.dz0ny.dev/unstable//` + ### Manifest Example Each build includes a `manifest.json` file: @@ -160,6 +188,27 @@ Each build includes a `manifest.json` file: } ``` +### Commits Data (commits.json) + +Each build includes a `commits.json` file with the last 10 commits: + +```json +[ + { + "hash": "abc1234", + "date": "2024-10-22 14:30:22 +0000", + "message": "feat: Add Fastlane TestFlight setup documentation", + "author": "John Doe" + }, + { + "hash": "def5678", + "date": "2024-10-22 12:15:10 +0000", + "message": "fix: Correctly set BASE_URL for unstable build artifacts", + "author": "Jane Smith" + } +] +``` + ## Testing the Setup 1. Push a commit to your repository (or re-run an existing workflow) diff --git a/.github/workflows/build-multiplatform.yml b/.github/workflows/build-multiplatform.yml index fb5952c..6c51b10 100644 --- a/.github/workflows/build-multiplatform.yml +++ b/.github/workflows/build-multiplatform.yml @@ -461,6 +461,11 @@ jobs: with: path: artifacts + - name: Checkout code for git log + uses: actions/checkout@v4 + with: + fetch-depth: 10 # Fetch last 10 commits + - name: Generate build metadata id: metadata run: | @@ -480,32 +485,75 @@ jobs: echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT echo "commit_short=$COMMIT_SHORT" >> $GITHUB_OUTPUT echo "build_prefix=$BUILD_PREFIX" >> $GITHUB_OUTPUT + echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT echo "Build prefix: $BUILD_PREFIX" + - name: Extract last 10 commits + id: commits + run: | + # Get last 10 commit messages with hash and date + git log -10 --pretty=format:'{"hash":"%h","date":"%ci","message":"%s","author":"%an"}' | \ + jq -s '.' > commits.json + + # Also create a simple text version for easier parsing + git log -10 --pretty=format:'%h|%ci|%s|%an' > commits.txt + + cat commits.json + echo "Commits extracted to commits.json" + - name: Prepare artifacts for upload run: | - # Create a structured directory for R2 + # Create directories for R2 mkdir -p r2-upload/unstable/${{ steps.metadata.outputs.build_prefix }} + # For main branch, also prepare the 'latest' directory + if [ "${{ steps.metadata.outputs.branch_name }}" == "main" ]; then + 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 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 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" + 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 commits data + if [ -f commits.json ]; then + 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 fi # Create a build manifest @@ -514,32 +562,50 @@ jobs: "build_id": "${{ steps.metadata.outputs.build_prefix }}-${{ steps.metadata.outputs.timestamp }}", "commit": "${{ github.sha }}", "commit_short": "${{ steps.metadata.outputs.commit_short }}", - "branch": "${GITHUB_REF#refs/heads/}", + "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 | jq -R . | jq -s .) + "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 + cat > "r2-upload/unstable/latest/manifest.json" < "$BUILD_DIR/index.html" <<'HTMLEOF' + # Generate download links HTML + cat > "$BUILD_DIR/index.html" <<'HTMLEOF' @@ -690,11 +756,72 @@ jobs: .footer a:hover { text-decoration: underline; } + .commits-section { + margin-top: 30px; + padding-top: 20px; + border-top: 2px solid #f0f0f0; + } + .commits-section h2 { + color: #333; + font-size: 24px; + margin-bottom: 20px; + } + #commits-list { + display: flex; + flex-direction: column; + gap: 12px; + } + .commit-item { + background: #f8f9fa; + border-left: 4px solid #667eea; + border-radius: 6px; + padding: 15px; + transition: all 0.2s ease; + } + .commit-item:hover { + background: #e9ecef; + border-left-color: #764ba2; + transform: translateX(2px); + } + .commit-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; + flex-wrap: wrap; + gap: 10px; + } + .commit-hash { + font-family: 'Monaco', 'Courier New', monospace; + background: #667eea; + color: white; + padding: 4px 10px; + border-radius: 4px; + font-size: 13px; + font-weight: 600; + } + .commit-date { + color: #888; + font-size: 12px; + } + .commit-message { + color: #333; + font-size: 15px; + line-height: 1.5; + margin-bottom: 6px; + font-weight: 500; + } + .commit-author { + color: #666; + font-size: 13px; + font-style: italic; + } @media (max-width: 600px) { .container { padding: 20px; } h1 { font-size: 24px; } .download-card { flex-direction: column; align-items: flex-start; } .download-btn { margin-top: 15px; width: 100%; text-align: center; } + .commit-header { flex-direction: column; align-items: flex-start; } } @@ -807,8 +934,72 @@ jobs: HTMLEOF fi - # Close HTML - cat >> "$BUILD_DIR/index.html" <<'HTMLEOF' + # Add commit history section + if [ -f "$BUILD_DIR/commits.json" ]; then + cat >> "$BUILD_DIR/index.html" <<'HTMLEOF' + + +
+

📝 Last 10 Commits

+
Loading commits...
+
+ + + + + + + + HTMLEOF + else + # No commits file, close HTML normally + cat >> "$BUILD_DIR/index.html" <<'HTMLEOF'