@@ -194,11 +194,74 @@ jobs:
194194 docs/public/versions.json > /tmp/versions_new.json
195195 mv /tmp/versions_new.json docs/public/versions.json
196196
197- - name : Commit versions.json to main
198- uses : stefanzweifel/git-auto-commit-action@v5.0.1
197+ - name : Generate blog post stub for new major version
198+ run : |
199+ set -euo pipefail
200+ # Convert vX.0.0 → v<maj>-0-0 for the file name (e.g. v3.0.0 → v3-0-0)
201+ TAG="$GITHUB_REF_NAME"
202+ SLUG="${TAG//./-}" # v3.0.0 → v3-0-0
203+ BLOG_FILE="docs/blog/release-${SLUG}.md"
204+ RELEASE_DATE="$(date -u +%Y-%m-%d)"
205+ # Idempotent — skip creation if the file already exists (manually authored).
206+ if [ -f "$BLOG_FILE" ]; then
207+ echo "Blog post $BLOG_FILE already exists — skipping stub generation."
208+ else
209+ # Fix: use Python to write the file so heredoc indentation never
210+ # leaks into the generated Markdown (which would break frontmatter).
211+ python3 - <<PY
212+ import pathlib
213+ tag = "$TAG"
214+ release_date = "$RELEASE_DATE"
215+ blog_file = "$BLOG_FILE"
216+ content = (
217+ f'---\ntitle: "What\'s new in {tag}"\n'
218+ f'description: "Highlights of github-code-search {tag}"\n'
219+ f'date: {release_date}\n---\n\n'
220+ f'# What\'s new in github-code-search {tag}\n\n'
221+ f'> Full release notes: <https://github.com/fulll/github-code-search/releases/tag/{tag}>\n\n'
222+ '<!-- TODO: fill in feature highlights, usage examples and screenshots. -->\n'
223+ )
224+ pathlib.Path(blog_file).write_text(content, encoding="utf-8")
225+ print(f"Created blog stub: {blog_file}")
226+ PY
227+ fi
228+
229+ - name : Update blog/index.md table with new major version
230+ run : |
231+ set -euo pipefail
232+ TAG="$GITHUB_REF_NAME"
233+ SLUG="${TAG//./-}"
234+ # Add a row to the blog index table only if the version isn't already listed.
235+ if grep -qF "release-${SLUG}" docs/blog/index.md; then
236+ echo "Blog index already contains ${TAG} — skipping."
237+ else
238+ python3 - <<PY
239+ import re, pathlib
240+
241+ path = pathlib.Path("docs/blog/index.md")
242+ content = path.read_text()
243+ tag = "$TAG"
244+ slug = "$SLUG"
245+ new_row = f"| [{tag}](./release-{slug}) | <!-- TODO: add summary --> |"
246+ # Insert the new row after the last markdown table row (line ending with |).
247+ updated = re.sub(
248+ r"(\|[^\n]+\|)(\s*\Z)",
249+ lambda m: m.group(1) + "\n" + new_row + m.group(2),
250+ content,
251+ count=1,
252+ flags=re.DOTALL,
253+ )
254+ path.write_text(updated)
255+ print(f"Inserted row for {tag} into blog/index.md")
256+ PY
257+ fi
258+
259+ - name : Commit blog stub and versions.json to main
260+ # Pin to exact commit SHA to prevent supply-chain attacks.
261+ uses : stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
199262 with :
200263 # No [skip ci] — the push to main matches paths: docs/** and re-triggers
201264 # the deploy job, which merges the new snapshot into the Pages artifact.
202- commit_message : " docs: add ${{ steps.ver.outputs.major }} to versions.json"
203- file_pattern : docs/public/versions.json
265+ commit_message : " docs: add ${{ steps.ver.outputs.major }} to versions.json and blog "
266+ file_pattern : docs/public/versions.json docs/blog/
204267 branch : main
0 commit comments