2026-08-12 21:26:36 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
|
|
# Sürüm notlarını git tag'lerinden üretir:
|
2026-08-13 10:43:48 +00:00
|
|
|
|
# api/src/Sozsoft.Platform.HttpApi.Host/release-notes.json
|
2026-08-12 21:26:36 +00:00
|
|
|
|
#
|
2026-08-13 10:43:48 +00:00
|
|
|
|
# Dosya csproj'daki `Content Update="release-notes.json"` kuralıyla publish
|
|
|
|
|
|
# çıktısına kopyalanır, yani imaja gömülür ve konteynerde ContentRootPath
|
|
|
|
|
|
# altında (/srv/app) yer alır. ReleaseNoteStartupService açılışta tam bu yolu
|
|
|
|
|
|
# okuyup `Sas_H_ReleaseNote` tablosuyla eşitler; DbMigrator gerekmez.
|
2026-08-12 21:26:36 +00:00
|
|
|
|
#
|
2026-08-13 10:43:48 +00:00
|
|
|
|
# ÖNEMLİ: Çıktı yolu ReleaseNoteStartupService'in okuduğu yolla aynı olmak
|
|
|
|
|
|
# ZORUNDA. Daha önce script `api/release-notes/` altına yazıyordu; orası ne
|
|
|
|
|
|
# publish çıktısına kopyalanıyor ne de konteynere mount ediliyordu, dolayısıyla
|
|
|
|
|
|
# imajdaki eski (commit'lenmiş) dosya kullanılıyor ve yeni tag'ler hiç
|
|
|
|
|
|
# görünmüyordu.
|
2026-08-12 21:52:49 +00:00
|
|
|
|
#
|
2026-08-13 10:43:48 +00:00
|
|
|
|
# Çıktı .gitignore'dadır: takip edilseydi deploy'daki `git pull` her seferinde
|
|
|
|
|
|
# yerel değişiklikle çakışırdı.
|
|
|
|
|
|
#
|
|
|
|
|
|
# Deploy akışında configs/deployment/scripts/build/api.sh tarafından otomatik
|
|
|
|
|
|
# çağrılır; elle de çalıştırılabilir.
|
2026-08-12 21:26:36 +00:00
|
|
|
|
#
|
|
|
|
|
|
# Dış bağımlılığı yoktur (jq/node gerekmez): JSON kaçışları sed ile yapılır.
|
|
|
|
|
|
|
|
|
|
|
|
cd "$(dirname "$0")/.."
|
2026-08-13 10:43:48 +00:00
|
|
|
|
OUTPUT="src/Sozsoft.Platform.HttpApi.Host/release-notes.json"
|
2026-08-12 21:52:49 +00:00
|
|
|
|
mkdir -p "$(dirname "$OUTPUT")"
|
2026-08-12 21:26:36 +00:00
|
|
|
|
|
|
|
|
|
|
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
|
|
|
|
echo "> git deposu yok, ${OUTPUT} güncellenmedi." >&2
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo "> release-notes.json oluşturuluyor..."
|
|
|
|
|
|
|
|
|
|
|
|
# origin'de olmayan yerel tag'ler sürüm sırasını bozar; temizle. `--force` şart:
|
|
|
|
|
|
# yerel bir tag origin'dekinden farklı commit'e bakıyorsa git onu "would clobber
|
|
|
|
|
|
# existing tag" diyerek reddediyor ve YENİ tag'ler de alınmamış oluyor.
|
|
|
|
|
|
git fetch --prune --prune-tags --tags --force origin >/dev/null 2>&1 || true
|
|
|
|
|
|
|
|
|
|
|
|
# Sıra tag adına göre (creatordate değil): 1.1.10 > 1.1.09.
|
|
|
|
|
|
TAGS=$(git tag --list --sort=-v:refname)
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "$TAGS" ]; then
|
|
|
|
|
|
echo "> Tag bulunamadı, mevcut dosya korundu." >&2
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# JSON string kaçışı: önce ters bölü, sonra tırnak, sonra sekme/CR.
|
|
|
|
|
|
escape_json() {
|
|
|
|
|
|
printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/\t/\\t/g' -e 's/\r//g'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TMP=$(mktemp)
|
|
|
|
|
|
printf '{\n "ReleaseNotes": [\n' > "$TMP"
|
|
|
|
|
|
|
|
|
|
|
|
FIRST_TAG=true
|
|
|
|
|
|
for TAG in $TAGS; do
|
|
|
|
|
|
VERSION=${TAG#v}
|
|
|
|
|
|
RELEASE_DATE=$(git log -1 --format=%ad --date=short "$TAG")
|
|
|
|
|
|
COMMIT=$(git rev-list -n 1 "$TAG")
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$FIRST_TAG" = true ]; then FIRST_TAG=false; else printf ',\n' >> "$TMP"; fi
|
|
|
|
|
|
|
|
|
|
|
|
printf ' {\n' >> "$TMP"
|
|
|
|
|
|
printf ' "version": "%s",\n' "$(escape_json "$VERSION")" >> "$TMP"
|
|
|
|
|
|
printf ' "releaseDate": "%s",\n' "$RELEASE_DATE" >> "$TMP"
|
|
|
|
|
|
printf ' "commit": "%s",\n' "$COMMIT" >> "$TMP"
|
|
|
|
|
|
printf ' "notes": [' >> "$TMP"
|
|
|
|
|
|
|
|
|
|
|
|
# Annotated tag mesajı; her satır bir madde. Boş satırlar ve baştaki "-" / "*"
|
|
|
|
|
|
# işaretleri temizlenir. Lightweight tag'de mesaj boştur → notes: [].
|
|
|
|
|
|
FIRST_NOTE=true
|
|
|
|
|
|
while IFS= read -r LINE; do
|
|
|
|
|
|
[ -z "$LINE" ] && continue
|
|
|
|
|
|
if [ "$FIRST_NOTE" = true ]; then FIRST_NOTE=false; printf '\n' >> "$TMP"; else printf ',\n' >> "$TMP"; fi
|
|
|
|
|
|
printf ' "%s"' "$(escape_json "$LINE")" >> "$TMP"
|
|
|
|
|
|
done < <(git tag -l --format='%(contents)' "$TAG" \
|
|
|
|
|
|
| sed -e 's/\r//' -e 's/^[[:space:]]*[-*][[:space:]]*//' -e 's/[[:space:]]*$//' \
|
|
|
|
|
|
| grep -v '^$' || true)
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$FIRST_NOTE" = true ]; then
|
|
|
|
|
|
printf ']\n' >> "$TMP"
|
|
|
|
|
|
else
|
|
|
|
|
|
printf '\n ]\n' >> "$TMP"
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf ' }' >> "$TMP"
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
printf '\n ]\n}\n' >> "$TMP"
|
|
|
|
|
|
mv "$TMP" "$OUTPUT"
|
|
|
|
|
|
|
|
|
|
|
|
echo "> ${OUTPUT}: $(grep -c '"version":' "$OUTPUT") sürüm"
|