Files
Planification/build.sh
T
Quentin Rouiller 1730758cb4 Distribution: firefox-updates.json + CLAUDE.md (workflow Claude) + nettoyage secrets
- firefox-updates.json à la racine : manifest auto-update Firefox avec entrées
  v2026.5.40 et v2026.5.41 (sha256 NON SIGNÉ pour le moment, à remplacer par
  celui des .xpi signés AMO).
- build.sh : maintient firefox-updates.json automatiquement à chaque build
  (ajoute ou met à jour l'entrée de la version courante avec son sha256
  calculé sur le .xpi produit).
- CLAUDE.md : workflow complet pour Claude Code (build → test → push → wiki →
  signature AMO). Token Gitea jamais dans le fichier (stocké hors repo en
  mémoire Claude .claude/projects/.../memory/gitea_token.md).
- .gitignore : ajout _archives/, .claude/, .env, *.token, secrets.json.
- README.md / CHANGELOG.md : retrait email auteur en clair (renvoi vers
  page wiki Contact, email obfusqué en entités HTML).
2026-04-27 02:55:18 +02:00

90 lines
3.3 KiB
Bash
Executable File

#!/usr/bin/env bash
###############################################################################
# build.sh — génère dist/chromium/, dist/firefox/, et les archives .zip / .xpi
# à partir du code source dans src/.
#
# Usage : ./build.sh
###############################################################################
set -e
# Le script est dans Autres/ — on remonte d'un cran pour se placer à la
# racine du projet, où se trouvent src/ et dist/.
cd "$(dirname "$0")"
VERSION=$(python3 -c "import json; print(json.load(open('src/manifest.json'))['version'])")
echo "==> Build Planification v$VERSION"
rm -rf dist
mkdir -p dist/chromium dist/firefox
# ---- Chromium : copie src/ tel quel (manifest sans gecko_settings) ----
cp -r src/* dist/chromium/
echo " ✓ dist/chromium/ ($(du -sh dist/chromium | cut -f1))"
# ---- Firefox : copie src/ + manifest avec browser_specific_settings ----
cp -r src/* dist/firefox/
python3 - <<EOF
import json
with open('src/manifest.json', 'r') as f: m = json.load(f)
m['browser_specific_settings'] = {
'gecko': {
'id': 'planification@netaplaid.ch',
'strict_min_version': '140.0',
'update_url': 'https://gitea.netaplaid.ch/FroSteel/Planification/raw/branch/main/firefox-updates.json',
'data_collection_permissions': {'required': ['none']}
}
}
with open('dist/firefox/manifest.json', 'w') as f:
json.dump(m, f, indent=2, ensure_ascii=False)
f.write('\n')
EOF
echo " ✓ dist/firefox/ ($(du -sh dist/firefox | cut -f1))"
# ---- Archives ZIP / XPI prêtes à distribuer ----
cd dist/chromium && zip -rq "../planification-v${VERSION}-chromium.zip" . && cd ../..
cd dist/firefox && zip -rq "../planification-v${VERSION}-firefox.xpi" . && cd ../..
echo ""
echo "==> Builds prêts dans dist/"
ls -la dist/*.zip dist/*.xpi 2>/dev/null
# ---- firefox-updates.json : ajout/mise à jour de l'entrée pour cette version
# (sha256 du .xpi NON SIGNÉ — sera remplacé par celui du .xpi signé après AMO).
python3 - <<EOF
import json, hashlib, os
xpi = f"dist/planification-v${VERSION}-firefox.xpi"
with open(xpi, 'rb') as f: sha = hashlib.sha256(f.read()).hexdigest()
JSON_PATH = "firefox-updates.json"
ADDON_ID = "planification@netaplaid.ch"
update_link = f"https://gitea.netaplaid.ch/FroSteel/Planification/releases/download/v${VERSION}/planification-v${VERSION}-firefox.xpi"
if os.path.exists(JSON_PATH):
with open(JSON_PATH) as f: data = json.load(f)
else:
data = {"addons": {ADDON_ID: {"updates": []}}}
addon = data.setdefault("addons", {}).setdefault(ADDON_ID, {"updates": []})
updates = addon.setdefault("updates", [])
# Retirer toute entrée existante pour cette version (idempotent)
updates = [u for u in updates if u.get("version") != "${VERSION}"]
# Ajouter en tête
updates.insert(0, {
"version": "${VERSION}",
"update_link": update_link,
"update_hash": "sha256:" + sha,
})
addon["updates"] = updates
with open(JSON_PATH, 'w') as f:
json.dump(data, f, indent=2, ensure_ascii=False)
f.write('\n')
print(f" ✓ firefox-updates.json mis à jour (sha256 NON SIGNÉ : {sha[:16]}…)")
EOF
echo ""
echo "Pour Chrome : charger dist/chromium/ en mode développeur"
echo "Pour Firefox : signer dist/planification-v${VERSION}-firefox.xpi sur AMO"
echo " Après signature, remplacer le sha256 dans firefox-updates.json par celui du .xpi signé."