|
|
@ -13,9 +13,9 @@ jobs: |
|
|
models: read |
|
|
models: read |
|
|
|
|
|
|
|
|
steps: |
|
|
steps: |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Validate payload (safe) |
|
|
# Validate payload (safe & strict) |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Validate payload |
|
|
- name: Validate payload |
|
|
run: | |
|
|
run: | |
|
|
required_keys=(version name notes url target_branch) |
|
|
required_keys=(version name notes url target_branch) |
|
|
@ -27,9 +27,9 @@ jobs: |
|
|
fi |
|
|
fi |
|
|
done |
|
|
done |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Checkout target branch |
|
|
# Checkout target branch |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- uses: actions/checkout@v4 |
|
|
- uses: actions/checkout@v4 |
|
|
with: |
|
|
with: |
|
|
ref: ${{ github.event.client_payload.target_branch }} |
|
|
ref: ${{ github.event.client_payload.target_branch }} |
|
|
@ -40,9 +40,9 @@ jobs: |
|
|
git config user.name "docs-bot" |
|
|
git config user.name "docs-bot" |
|
|
git config user.email "docs-bot@users.noreply.github.com" |
|
|
git config user.email "docs-bot@users.noreply.github.com" |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Create working branch |
|
|
# Create working branch |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Create branch |
|
|
- name: Create branch |
|
|
run: | |
|
|
run: | |
|
|
VERSION="${{ github.event.client_payload.version }}" |
|
|
VERSION="${{ github.event.client_payload.version }}" |
|
|
@ -50,17 +50,17 @@ jobs: |
|
|
git checkout -B "$BRANCH" |
|
|
git checkout -B "$BRANCH" |
|
|
echo "BRANCH=$BRANCH" >> $GITHUB_ENV |
|
|
echo "BRANCH=$BRANCH" >> $GITHUB_ENV |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Prepare raw release notes |
|
|
# Save raw release notes |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Save raw release notes |
|
|
- name: Save raw release notes |
|
|
run: | |
|
|
run: | |
|
|
mkdir -p .tmp |
|
|
mkdir -p .tmp |
|
|
jq -r '.client_payload.notes' "$GITHUB_EVENT_PATH" > .tmp/raw-notes.txt |
|
|
jq -r '.client_payload.notes' "$GITHUB_EVENT_PATH" > .tmp/raw-notes.txt |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Try AI formatting (optional) |
|
|
# Try AI formatting (OPTIONAL) |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Generate release notes with AI (optional) |
|
|
- name: Generate release notes with AI (optional) |
|
|
id: ai |
|
|
id: ai |
|
|
continue-on-error: true |
|
|
continue-on-error: true |
|
|
@ -74,76 +74,147 @@ jobs: |
|
|
Rules: |
|
|
Rules: |
|
|
- Use "-" bullets |
|
|
- Use "-" bullets |
|
|
- Keep it short and clear |
|
|
- Keep it short and clear |
|
|
- Skip internal / irrelevant details |
|
|
- Skip internal or low-level changes |
|
|
|
|
|
|
|
|
Release notes: |
|
|
Release notes: |
|
|
${{ github.event.client_payload.notes }} |
|
|
${{ github.event.client_payload.notes }} |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Decide final notes (AI or fallback) |
|
|
# Decide final release notes (AI or fallback) |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Decide final release notes |
|
|
- name: Decide final release notes |
|
|
run: | |
|
|
run: | |
|
|
if [ -n "${{ steps.ai.outputs.response }}" ]; then |
|
|
if [ -n "${{ steps.ai.outputs.response }}" ]; then |
|
|
echo "Using AI-formatted release notes" |
|
|
echo "✅ Using AI formatted notes" |
|
|
echo "${{ steps.ai.outputs.response }}" > .tmp/final-notes.txt |
|
|
echo "${{ steps.ai.outputs.response }}" > .tmp/final-notes.txt |
|
|
else |
|
|
else |
|
|
echo "AI unavailable – using raw release notes" |
|
|
echo "⚠️ AI unavailable – using raw notes" |
|
|
sed 's/^/- /' .tmp/raw-notes.txt > .tmp/final-notes.txt |
|
|
sed 's/^/- /' .tmp/raw-notes.txt > .tmp/final-notes.txt |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Update release-notes.md |
|
|
# Update release-notes.md (UNDER Latest) |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Update release-notes.md |
|
|
- name: Update release-notes.md |
|
|
run: | |
|
|
run: | |
|
|
FILE="docs/en/studio/release-notes.md" |
|
|
FILE="docs/en/studio/release-notes.md" |
|
|
VERSION="${{ github.event.client_payload.version }}" |
|
|
VERSION="${{ github.event.client_payload.version }}" |
|
|
NAME="${{ github.event.client_payload.name }}" |
|
|
NAME="${{ github.event.client_payload.name }}" |
|
|
URL="${{ github.event.client_payload.url }}" |
|
|
URL="${{ github.event.client_payload.url }}" |
|
|
|
|
|
DATE="$(date +%Y-%m-%d)" |
|
|
|
|
|
|
|
|
mkdir -p docs/en/studio |
|
|
mkdir -p docs/en/studio |
|
|
touch "$FILE" |
|
|
touch "$FILE" |
|
|
|
|
|
|
|
|
if grep -q "## Version $VERSION" "$FILE"; then |
|
|
if grep -q "## $VERSION" "$FILE"; then |
|
|
echo "Release notes already contain $VERSION, skipping" |
|
|
echo "Release notes already contain $VERSION" |
|
|
exit 0 |
|
|
exit 0 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
{ |
|
|
ENTRY=$(cat <<EOF |
|
|
echo "## Version $VERSION - $NAME" |
|
|
|
|
|
echo "" |
|
|
## $VERSION ($DATE) |
|
|
cat .tmp/final-notes.txt |
|
|
|
|
|
echo "" |
|
|
$(cat .tmp/final-notes.txt) |
|
|
echo "[Release Link]($URL)" |
|
|
|
|
|
echo "" |
|
|
[Release Link]($URL) |
|
|
echo "---" |
|
|
|
|
|
echo "" |
|
|
EOF |
|
|
} | cat - "$FILE" > "$FILE.new" |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
awk -v entry="$ENTRY" ' |
|
|
|
|
|
/Latest/ && !inserted { |
|
|
|
|
|
print |
|
|
|
|
|
print entry |
|
|
|
|
|
inserted=1 |
|
|
|
|
|
next |
|
|
|
|
|
} |
|
|
|
|
|
{ print } |
|
|
|
|
|
END { |
|
|
|
|
|
if (!inserted) print entry |
|
|
|
|
|
}' "$FILE" > "$FILE.new" |
|
|
|
|
|
|
|
|
mv "$FILE.new" "$FILE" |
|
|
mv "$FILE.new" "$FILE" |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Update version-mapping.md |
|
|
# Update version-mapping.md (INSIDE table) |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Update version-mapping.md |
|
|
- name: Update version-mapping.md (smart) |
|
|
run: | |
|
|
run: | |
|
|
FILE="docs/en/studio/version-mapping.md" |
|
|
FILE="docs/en/studio/version-mapping.md" |
|
|
VERSION="${{ github.event.client_payload.version }}" |
|
|
STUDIO_VERSION="${{ github.event.client_payload.version }}" |
|
|
|
|
|
ABP_VERSION="dev" # gerekiyorsa payload’dan alabilirsin |
|
|
|
|
|
|
|
|
mkdir -p docs/en/studio |
|
|
mkdir -p docs/en/studio |
|
|
|
|
|
|
|
|
if [ ! -f "$FILE" ]; then |
|
|
if [ ! -f "$FILE" ]; then |
|
|
echo "| Studio Version | ABP Version |" > "$FILE" |
|
|
echo "| ABP Studio Version | ABP Version |" > "$FILE" |
|
|
echo "|---------------|-------------|" >> "$FILE" |
|
|
echo "|-------------------|-------------|" >> "$FILE" |
|
|
|
|
|
echo "| $STUDIO_VERSION | $ABP_VERSION |" >> "$FILE" |
|
|
|
|
|
exit 0 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
if ! grep -q "| $VERSION |" "$FILE"; then |
|
|
python3 <<'EOF' |
|
|
echo "| $VERSION | dev |" >> "$FILE" |
|
|
import re |
|
|
fi |
|
|
from packaging.version import Version |
|
|
|
|
|
|
|
|
|
|
|
file_path = "docs/en/studio/version-mapping.md" |
|
|
|
|
|
studio = Version("${STUDIO_VERSION}") |
|
|
|
|
|
abp = "${ABP_VERSION}" |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
with open(file_path) as f: |
|
|
|
|
|
lines = f.readlines() |
|
|
|
|
|
|
|
|
|
|
|
header = lines[:2] |
|
|
|
|
|
rows = lines[2:] |
|
|
|
|
|
|
|
|
|
|
|
new_rows = [] |
|
|
|
|
|
handled = False |
|
|
|
|
|
|
|
|
|
|
|
for row in rows: |
|
|
|
|
|
m = re.match(r"\|\s*(.+?)\s*\|\s*(.+?)\s*\|", row) |
|
|
|
|
|
if not m: |
|
|
|
|
|
new_rows.append(row) |
|
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
studio_range, abp_version = m.groups() |
|
|
|
|
|
|
|
|
|
|
|
if abp_version != abp: |
|
|
|
|
|
new_rows.append(row) |
|
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
# range cases |
|
|
|
|
|
if "-" in studio_range: |
|
|
|
|
|
start, end = [Version(v.strip()) for v in studio_range.split("-")] |
|
|
|
|
|
if start <= studio <= end: |
|
|
|
|
|
handled = True |
|
|
|
|
|
new_rows.append(row) # already covered |
|
|
|
|
|
elif studio == end.next_patch(): |
|
|
|
|
|
handled = True |
|
|
|
|
|
new_rows.append(f"| {start} - {studio} | {abp} |\n") |
|
|
|
|
|
else: |
|
|
|
|
|
new_rows.append(row) |
|
|
|
|
|
else: |
|
|
|
|
|
v = Version(studio_range) |
|
|
|
|
|
if studio == v: |
|
|
|
|
|
handled = True |
|
|
|
|
|
new_rows.append(row) |
|
|
|
|
|
elif studio == v.next_patch(): |
|
|
|
|
|
handled = True |
|
|
|
|
|
new_rows.append(f"| {v} - {studio} | {abp} |\n") |
|
|
|
|
|
else: |
|
|
|
|
|
new_rows.append(row) |
|
|
|
|
|
|
|
|
|
|
|
if not handled: |
|
|
|
|
|
new_rows.insert(0, f"| {studio} | {abp} |\n") |
|
|
|
|
|
|
|
|
|
|
|
with open(file_path, "w") as f: |
|
|
|
|
|
f.writelines(header + new_rows) |
|
|
|
|
|
EOF |
|
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------- |
|
|
# Check for changes |
|
|
# Check for changes |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Check for changes |
|
|
- name: Check for changes |
|
|
id: changes |
|
|
id: changes |
|
|
run: | |
|
|
run: | |
|
|
@ -154,35 +225,37 @@ jobs: |
|
|
echo "has_changes=true" >> $GITHUB_OUTPUT |
|
|
echo "has_changes=true" >> $GITHUB_OUTPUT |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Commit & push |
|
|
# Commit & push |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Commit & push |
|
|
- name: Commit & push |
|
|
if: steps.changes.outputs.has_changes == 'true' |
|
|
if: steps.changes.outputs.has_changes == 'true' |
|
|
run: | |
|
|
run: | |
|
|
git commit -m "docs(studio): update docs for ${{ github.event.client_payload.version }}" |
|
|
git commit -m "docs(studio): release ${{ github.event.client_payload.version }}" |
|
|
git push -u origin "$BRANCH" |
|
|
git push -u origin "$BRANCH" |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Create PR |
|
|
# Create PR |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Create PR |
|
|
- name: Create PR |
|
|
if: steps.changes.outputs.has_changes == 'true' |
|
|
if: steps.changes.outputs.has_changes == 'true' |
|
|
env: |
|
|
env: |
|
|
GH_TOKEN: ${{ secrets.BOT_SECRET }} |
|
|
GH_TOKEN: ${{ secrets.BOT_SECRET }} |
|
|
run: | |
|
|
run: | |
|
|
gh pr create \ |
|
|
PR_URL=$(gh pr create \ |
|
|
--title "docs(studio): release ${{ github.event.client_payload.version }}" \ |
|
|
--title "docs(studio): release ${{ github.event.client_payload.version }}" \ |
|
|
--body "Automated documentation update for ABP Studio." \ |
|
|
--body "Automated documentation update for ABP Studio." \ |
|
|
--base "${{ github.event.client_payload.target_branch }}" \ |
|
|
--base "${{ github.event.client_payload.target_branch }}" \ |
|
|
--head "$BRANCH" |
|
|
--head "$BRANCH") |
|
|
|
|
|
|
|
|
|
|
|
echo "PR_URL=$PR_URL" >> $GITHUB_ENV |
|
|
|
|
|
|
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
# Enable auto-merge (branch protection safe) |
|
|
# Enable auto-merge (branch protection safe) |
|
|
# ----------------------------- |
|
|
# ------------------------------------------------- |
|
|
- name: Enable auto-merge |
|
|
- name: Enable auto-merge |
|
|
if: steps.changes.outputs.has_changes == 'true' |
|
|
if: steps.changes.outputs.has_changes == 'true' |
|
|
env: |
|
|
env: |
|
|
GH_TOKEN: ${{ secrets.BOT_SECRET }} |
|
|
GH_TOKEN: ${{ secrets.BOT_SECRET }} |
|
|
run: | |
|
|
run: | |
|
|
gh pr merge "$BRANCH" --squash --auto --admin |
|
|
gh pr merge "$PR_URL" --squash --auto |
|
|
|