fix(deploy): push_to_gitea.sh points to .0.82 + supports GITEA_TOKEN
The old script hit 192.168.1.86:3000 which never existed on this LAN. Real Gitea lives on 192.168.0.82:3000. Also prefer GITEA_TOKEN over embedding a password; GITEA_PASS remains as a fallback.
This commit is contained in:
75
deploy/push_to_gitea.sh
Normal file → Executable file
75
deploy/push_to_gitea.sh
Normal file → Executable file
@@ -1,56 +1,39 @@
|
||||
#!/bin/bash
|
||||
# Push DauphinCraft vers Gitea .86
|
||||
# Push DauphinCraft vers Gitea .0.82
|
||||
# Usage: GITEA_TOKEN=xxx bash deploy/push_to_gitea.sh (recommandé)
|
||||
# ou : GITEA_USER=... GITEA_PASS=... bash deploy/push_to_gitea.sh
|
||||
set -e
|
||||
|
||||
GITEA_URL="${GITEA_URL:-http://192.168.1.86:3000}"
|
||||
GITEA_USER="${GITEA_USER:-flagabat}"
|
||||
GITEA_PASS="${GITEA_PASS:-SuperTeam2026!}"
|
||||
GITEA_URL="${GITEA_URL:-http://192.168.0.82:3000}"
|
||||
GITEA_USER="${GITEA_USER:-floppyrj45}"
|
||||
REPO_NAME="${REPO_NAME:-dauphincraft}"
|
||||
PROJECT_DIR="${PROJECT_DIR:-$(dirname "$0")/..}"
|
||||
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
# 1. Créer repo via API (idempotent)
|
||||
echo "=== Création repo $REPO_NAME ==="
|
||||
curl -s -u "$GITEA_USER:$GITEA_PASS" -X POST "$GITEA_URL/api/v1/user/repos" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"name\":\"$REPO_NAME\",\"description\":\"DauphinCraft — Minecraft-like sous-marin\",\"private\":false,\"auto_init\":false}" \
|
||||
| head -5 || true
|
||||
|
||||
# 2. Ajouter remote Gitea
|
||||
GITEA_REMOTE="$GITEA_URL/$GITEA_USER/$REPO_NAME.git"
|
||||
git remote remove gitea 2>/dev/null || true
|
||||
git remote add gitea "http://$GITEA_USER:$GITEA_PASS@${GITEA_REMOTE#http://}"
|
||||
|
||||
# 3. Push
|
||||
echo "=== Push master vers Gitea ==="
|
||||
git push -u gitea master
|
||||
|
||||
# 4. Créer release v0.1.0 via API
|
||||
echo "=== Création release v0.1.0 ==="
|
||||
RELEASE_JSON=$(curl -s -u "$GITEA_USER:$GITEA_PASS" -X POST "$GITEA_URL/api/v1/repos/$GITEA_USER/$REPO_NAME/releases" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"tag_name":"v0.1.0","target_commitish":"master","name":"v0.1.0 — First beta","body":"## Première beta publique\n\n- Monde voxel procédural sous-marin\n- Dauphin contrôleur, écholocation\n- Inventaire + 5 recettes craft\n- Mobs: poissons, méduses, requin\n- Multijoueur ENet 16 joueurs\n- Ambiance shaders + audio CC0\n\nDownload Windows + Serveur Linux ci-dessous.","draft":false,"prerelease":true}')
|
||||
echo "$RELEASE_JSON" | head -10
|
||||
RELEASE_ID=$(echo "$RELEASE_JSON" | grep -oP '"id":\s*\K\d+' | head -1)
|
||||
|
||||
# 5. Upload artifacts
|
||||
if [ -n "$RELEASE_ID" ]; then
|
||||
echo "=== Upload client Windows ==="
|
||||
[ -f builds/DauphinCraft.exe ] && curl -s -u "$GITEA_USER:$GITEA_PASS" -X POST \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_USER/$REPO_NAME/releases/$RELEASE_ID/assets?name=DauphinCraft-v0.1-win64.exe" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@builds/DauphinCraft.exe" | head -3
|
||||
[ -f builds/DauphinCraft.pck ] && curl -s -u "$GITEA_USER:$GITEA_PASS" -X POST \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_USER/$REPO_NAME/releases/$RELEASE_ID/assets?name=DauphinCraft-v0.1.pck" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@builds/DauphinCraft.pck" | head -3
|
||||
echo "=== Upload serveur Linux ==="
|
||||
[ -f builds/DauphinCraft-Server-v0.1.tar.gz ] && curl -s -u "$GITEA_USER:$GITEA_PASS" -X POST \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_USER/$REPO_NAME/releases/$RELEASE_ID/assets?name=DauphinCraft-Server-v0.1.tar.gz" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@builds/DauphinCraft-Server-v0.1.tar.gz" | head -3
|
||||
if [ -n "$GITEA_TOKEN" ]; then
|
||||
AUTH_HEADER=(-H "Authorization: token $GITEA_TOKEN")
|
||||
REMOTE_AUTH="$GITEA_USER:$GITEA_TOKEN"
|
||||
elif [ -n "$GITEA_PASS" ]; then
|
||||
AUTH_HEADER=(-u "$GITEA_USER:$GITEA_PASS")
|
||||
REMOTE_AUTH="$GITEA_USER:$GITEA_PASS"
|
||||
else
|
||||
echo "ERREUR: fournir GITEA_TOKEN ou GITEA_PASS" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Terminé ==="
|
||||
echo "Release URL: $GITEA_URL/$GITEA_USER/$REPO_NAME/releases"
|
||||
echo "=== Création repo $REPO_NAME (idempotent) ==="
|
||||
curl -s "${AUTH_HEADER[@]}" -X POST "$GITEA_URL/api/v1/user/repos" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"name\":\"$REPO_NAME\",\"description\":\"DauphinCraft — Minecraft-like sous-marin\",\"private\":false,\"auto_init\":false}" \
|
||||
>/dev/null || true
|
||||
|
||||
GITEA_HOSTPATH="${GITEA_URL#http://}"
|
||||
GITEA_HOSTPATH="${GITEA_HOSTPATH#https://}"
|
||||
git remote remove gitea 2>/dev/null || true
|
||||
git remote add gitea "http://${REMOTE_AUTH}@${GITEA_HOSTPATH}/$GITEA_USER/$REPO_NAME.git"
|
||||
|
||||
echo "=== Push master ==="
|
||||
git push -u gitea master
|
||||
|
||||
echo "=== OK: $GITEA_URL/$GITEA_USER/$REPO_NAME ==="
|
||||
|
||||
Reference in New Issue
Block a user