mirror of
https://github.com/torlando-tech/pyxis.git
synced 2026-03-29 05:19:50 +00:00
Merge pull request #8 from torlando-tech/fix/flasher-versioned-releases
Fix web flasher versioned releases (CORS)
This commit is contained in:
86
.github/workflows/release-firmware.yml
vendored
86
.github/workflows/release-firmware.yml
vendored
@@ -51,6 +51,44 @@ jobs:
|
||||
BOOT_APP0=$(find ~/.platformio -name "boot_app0.bin" | head -1)
|
||||
cp "$BOOT_APP0" docs/flasher/firmware/
|
||||
|
||||
# For tagged releases, also deploy to a versioned path on GitHub Pages
|
||||
# so the flasher can fetch them same-origin (GitHub release downloads lack CORS)
|
||||
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
||||
TAG="${GITHUB_REF#refs/tags/}"
|
||||
mkdir -p "docs/flasher/firmware/releases/${TAG}"
|
||||
cp .pio/build/tdeck/bootloader.bin "docs/flasher/firmware/releases/${TAG}/"
|
||||
cp .pio/build/tdeck/partitions.bin "docs/flasher/firmware/releases/${TAG}/"
|
||||
cp .pio/build/tdeck/firmware.bin "docs/flasher/firmware/releases/${TAG}/"
|
||||
cp "$BOOT_APP0" "docs/flasher/firmware/releases/${TAG}/"
|
||||
fi
|
||||
|
||||
- name: Download existing release assets for GitHub Pages
|
||||
run: |
|
||||
# Fetch all published releases and download their firmware assets
|
||||
# so versioned firmware is available same-origin on GitHub Pages.
|
||||
# With keep_files: true, each release only needs to be downloaded once.
|
||||
for tag in $(gh api repos/${{ github.repository }}/releases --jq '.[].tag_name'); do
|
||||
dir="docs/flasher/firmware/releases/${tag}"
|
||||
# Skip if we already have this version's firmware (e.g., current tagged build)
|
||||
if [ -f "${dir}/firmware.bin" ]; then
|
||||
echo "Skipping ${tag} — already present"
|
||||
continue
|
||||
fi
|
||||
mkdir -p "${dir}"
|
||||
echo "Downloading assets for ${tag}..."
|
||||
for asset in bootloader.bin partitions.bin boot_app0.bin firmware.bin; do
|
||||
url="https://github.com/${{ github.repository }}/releases/download/${tag}/${asset}"
|
||||
if curl -sL -o "${dir}/${asset}" -w '%{http_code}' "${url}" | grep -qx 200; then
|
||||
echo " ${asset} OK"
|
||||
else
|
||||
rm -f "${dir}/${asset}"
|
||||
echo " ${asset} not found"
|
||||
fi
|
||||
done
|
||||
done
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Generate manifest files
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.VERSION }}"
|
||||
@@ -88,12 +126,58 @@ jobs:
|
||||
}
|
||||
EOF
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
- name: Generate root landing page from README
|
||||
run: |
|
||||
mkdir -p docs/root
|
||||
pip install markdown
|
||||
python3 -c "
|
||||
import markdown, pathlib
|
||||
md = pathlib.Path('README.md').read_text()
|
||||
body = markdown.markdown(md, extensions=['fenced_code', 'tables'])
|
||||
html = '''<!DOCTYPE html>
|
||||
<html lang=\"en\">
|
||||
<head>
|
||||
<meta charset=\"UTF-8\">
|
||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
||||
<title>Pyxis — LXMF Messenger for T-Deck</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
max-width: 800px; margin: 0 auto; padding: 2rem 1rem; line-height: 1.6;
|
||||
background: #0f172a; color: #e2e8f0; }
|
||||
a { color: #3b82f6; }
|
||||
h1, h2 { color: #3b82f6; }
|
||||
code { background: rgba(255,255,255,0.1); padding: 0.15em 0.4em; border-radius: 4px; font-size: 0.9em; }
|
||||
.nav { text-align: center; margin: 2rem 0; }
|
||||
.nav a { display: inline-block; padding: 0.75rem 1.5rem; background: #3b82f6; color: white;
|
||||
text-decoration: none; border-radius: 8px; margin: 0.5rem; font-weight: 500; }
|
||||
.nav a:hover { background: #2563eb; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
''' + body + '''
|
||||
<div class=\"nav\">
|
||||
<a href=\"flasher/\">Web Flasher</a>
|
||||
<a href=\"https://github.com/torlando-tech/pyxis\">GitHub</a>
|
||||
<a href=\"https://github.com/torlando-tech/pyxis/releases\">Releases</a>
|
||||
</div>
|
||||
</body></html>'''
|
||||
pathlib.Path('docs/root/index.html').write_text(html)
|
||||
"
|
||||
|
||||
- name: Deploy root landing page
|
||||
uses: peaceiris/actions-gh-pages@v4
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./docs/root
|
||||
keep_files: true
|
||||
|
||||
- name: Deploy flasher to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v4
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./docs/flasher
|
||||
destination_dir: flasher
|
||||
keep_files: true
|
||||
|
||||
- name: Create GitHub Release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
|
||||
Reference in New Issue
Block a user