Ajoute un script de release Gitea (scripts/release.sh)
Sur demande uniquement (pas de trigger auto par commit) : build les 2 jars, zip, cree le tag/release via l'API Gitea et y attache le zip. Token passe en variable d'env GITEA_TOKEN, jamais stocke dans le repo. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
0ca99c7e2c
commit
d5f6e0cfb3
@@ -44,6 +44,14 @@ mvn clean package
|
||||
|
||||
Jars produits dans `velocity/target/` et `spigot/target/`.
|
||||
|
||||
### Publier une release (Gitea)
|
||||
|
||||
```
|
||||
GITEA_TOKEN=xxxx ./scripts/release.sh 1.0.1 "Description de la release"
|
||||
```
|
||||
|
||||
Build les 2 jars, les zip dans `dist/VoteNetwork.zip`, crée le tag/release sur Gitea et y attache le zip. Nécessite un token Gitea (Paramètres → Applications → Générer un nouveau jeton, scope `repo`), passé uniquement en variable d'environnement — jamais commité.
|
||||
|
||||
## Configuration
|
||||
|
||||
Chaque composant a son propre fichier, tous deux dans un dossier **`votenetwork`** :
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build les 2 jars, zip, puis cree une release Gitea avec le zip attache.
|
||||
#
|
||||
# Usage :
|
||||
# GITEA_TOKEN=xxxx ./scripts/release.sh 1.0.1 "Description de la release"
|
||||
#
|
||||
# Le token doit avoir le scope "repo" (Parametres -> Applications -> Generer un nouveau jeton).
|
||||
# Ne JAMAIS commit le token. Passe-le uniquement en variable d'environnement.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION="${1:?Usage: release.sh <version> [notes]}"
|
||||
NOTES="${2:-Release ${VERSION}}"
|
||||
|
||||
GITEA_HOST="https://gitea.louconnect.fr"
|
||||
OWNER="Sar_Tron"
|
||||
REPO="VoteNetwork"
|
||||
TAG="v${VERSION}"
|
||||
|
||||
if [ -z "${GITEA_TOKEN:-}" ]; then
|
||||
echo "Erreur : variable GITEA_TOKEN non definie." >&2
|
||||
echo "Cree un token dans Gitea (Parametres > Applications, scope repo) puis :" >&2
|
||||
echo " GITEA_TOKEN=xxxx ./scripts/release.sh ${VERSION}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
echo "==> Build Maven"
|
||||
mvn -q clean package
|
||||
|
||||
echo "==> Preparation du zip de distribution"
|
||||
rm -rf dist
|
||||
mkdir -p dist
|
||||
cp velocity/target/VoteNetwork-Velocity.jar dist/
|
||||
cp spigot/target/VoteNetwork-Spigot.jar dist/
|
||||
|
||||
if command -v zip >/dev/null 2>&1; then
|
||||
(cd dist && zip -q VoteNetwork.zip VoteNetwork-Velocity.jar VoteNetwork-Spigot.jar)
|
||||
else
|
||||
powershell -Command "Compress-Archive -Path dist/VoteNetwork-Velocity.jar,dist/VoteNetwork-Spigot.jar -DestinationPath dist/VoteNetwork.zip -Force"
|
||||
fi
|
||||
|
||||
echo "==> Creation de la release Gitea ${TAG}"
|
||||
RELEASE_JSON=$(curl -sf -X POST "${GITEA_HOST}/api/v1/repos/${OWNER}/${REPO}/releases" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"VoteNetwork ${VERSION}\",\"body\":$(printf '%s' "$NOTES" | python3 -c 'import json,sys;print(json.dumps(sys.stdin.read()))' 2>/dev/null || printf '"%s"' "$NOTES"),\"draft\":false,\"prerelease\":false}")
|
||||
|
||||
RELEASE_ID=$(printf '%s' "$RELEASE_JSON" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
|
||||
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "Erreur : creation de la release echouee." >&2
|
||||
echo "$RELEASE_JSON" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "==> Upload du zip (release id ${RELEASE_ID})"
|
||||
curl -sf -X POST "${GITEA_HOST}/api/v1/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}/assets?name=VoteNetwork.zip" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-F "attachment=@dist/VoteNetwork.zip" > /dev/null
|
||||
|
||||
echo "==> Fait : ${GITEA_HOST}/${OWNER}/${REPO}/releases/tag/${TAG}"
|
||||
Reference in New Issue
Block a user