#!/bin/bash
set -e

REPO_ROOT="/srv/skinsoft-repo/mcli"
DIST="stable"
COMPONENT="main"
ARCH="amd64"
KEY_ID="9DE1DE82E284ADAE6AD83E72C80454D62CBB5584"

BIN_DIR="$REPO_ROOT/dists/$DIST/$COMPONENT/binary-$ARCH"
cd "$REPO_ROOT/dists/$DIST"

echo "📄 Génération du fichier Release..."
cat > Release <<EOF
Origin: SkinSoft
Label: mcli
Suite: stable
Version: 1.0
Codename: $DIST
Architectures: $ARCH
Components: $COMPONENT
Description: Dépôt APT pour mcli
EOF

echo "📦 Ajout des checksums..."
apt-ftparchive release "$REPO_ROOT/dists/$DIST" >> Release

echo "🔏 Signature GPG..."
gpg --default-key "$KEY_ID" -abs -o Release.gpg Release
gpg --default-key "$KEY_ID" --clearsign -o InRelease Release

echo "✅ Fichier Release signé avec la clé $KEY_ID"
