Why release notes still stall
Every team agrees release notes matter, and almost every team writes them by hand at the last possible moment. The job that generates them is always the one nobody got around to building. The blocker is rarely the model itself. It is the plumbing: another SDK, another key format, another vendor account that has to clear procurement before the pipeline can go green.
An OpenAI-compatible endpoint removes most of that friction. You keep the official openai package, keep chat.completions.create, and change two strings. Below is a complete CI job that turns git history into a changelog entry, plus the guardrails that stop it from inventing ticket numbers nobody filed.
What an OpenAI-compatible endpoint actually buys you in CI
Compatibility means the request and response shapes match what the OpenAI SDK already sends: the same messages array, the same streaming chunks, the same tool-calling envelope. For a pipeline job, that has concrete consequences:
You reuse the SDK your services already depend on, so there is no second client library to audit, pin, or patch.
Swapping providers becomes an environment variable change in the workflow file instead of a code change plus a review.
Staging and production pipelines can point at different keys without touching the script.
The same script runs locally: export the key, run it against your working copy, and read the output before CI ever commits it.
Design the job around commits, not diffs
Raw git log output is a poor prompt. Merge commits, chore noise, and paragraph-length bodies inflate the input and push the model toward inventing structure that is not there. Filter first, then let the model organise. Subject lines plus short bodies are enough for the vast majority of releases; send diffs only when a change is genuinely ambiguous, because diffs are expensive and mostly noise at this level.
Treat this as a summarisation task, not a reasoning task. Low temperature, a hard cap on commits, and an idempotent write step matter more than model choice. The job should be safe to re-run on every push without stacking duplicate sections in your changelog.
A runnable script for scripts/release_notes.py
This reads commits since the last tag, drops noise, calls deepseek-v4-flash, and rewrites a single Unreleased block at the top of CHANGELOG.md. Requires pip install openai and AICREDITS_API_KEY in the environment.
import os
import re
import subprocess
import sys
from openai import OpenAI
client = OpenAI(
api_key=os.environ['AICREDITS_API_KEY'],
base_url='https://api.aicreditsapi.com/v1',
)
MAX_COMMITS = 120
MAX_CHARS = 24000
SKIP = re.compile(r'^(chore\(release\)|Merge)')
def git(*args):
res = subprocess.run(['git', *args], capture_output=True, text=True)
if res.returncode != 0:
raise RuntimeError(res.stderr.strip())
return res.stdout
def last_tag():
try:
return git('describe', '--tags', '--abbrev=0').strip()
except RuntimeError:
return ''
def collect(since):
rng = '{}..HEAD'.format(since) if since else 'HEAD'
out = git('log', rng, '--no-merges', '--pretty=format:%h%x09%s')
rows = [line for line in out.splitlines() if line.strip()]
rows = [row for row in rows if not SKIP.match(row.split('\t')[-1])]
return rows[:MAX_COMMITS]
def write_notes(commits, since):
body = '\n'.join(commits)
if len(body) > MAX_CHARS:
body = body[:MAX_CHARS] + '\n...[truncated]'
prompt = (
'Write developer-facing release notes from the commit list below.\n'
'Rules:\n'
'1. Use ONLY the lines provided. Never invent issue numbers, PR links or authors.\n'
'2. Group under these headings in order: Features, Fixes, Performance, Docs, Internal.\n'
'3. Omit headings whose section would be empty.\n'
'4. One bullet per user-visible change, imperative mood, no marketing adjectives.\n'
'5. Skip pure noise such as version bumps and formatting.\n\n'
'Commits:\n' + body
)
resp = client.chat.completions.create(
model='deepseek-v4-flash',
messages=[{'role': 'user', 'content': prompt}],
temperature=0.2,
max_tokens=900,
)
notes = resp.choices[0].message.content.strip()
if not notes:
raise RuntimeError('model returned an empty completion')
header = '## Unreleased (since ' + (since or 'initial commit') + ')'
return header + '\n\n' + notes + '\n'
def main():
since = last_tag()
commits = collect(since)
if not commits:
print('No new commits since', since or 'the start of history')
return 0
block = write_notes(commits, since)
path = 'CHANGELOG.md'
existing = open(path).read() if os.path.exists(path) else '# Changelog\n'
existing = re.sub(r'\n?## Unreleased.*?(?=\n## |\Z)', '', existing, flags=re.S)
if existing.startswith('# '):
title, _, rest = existing.partition('\n')
updated = title + '\n\n' + block + '\n' + rest.lstrip() + '\n'
else:
updated = block + '\n' + existing
with open(path, 'w') as handle:
handle.write(updated)
print('Wrote {} commits into {}'.format(len(commits), path))
return 0
if __name__ == '__main__':
sys.exit(main())
Wire it into GitHub Actions
Add AICREDITS_API_KEY as a repository secret, drop the script in scripts/, and commit the workflow. fetch-depth 0 and fetch-tags are both load-bearing: without tags, last_tag() returns nothing and every run regenerates the entire history.
name: release-notes
on:
push:
branches: [main]
permissions:
contents: write
jobs:
changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install --upgrade openai
- run: python scripts/release_notes.py
env:
AICREDITS_API_KEY: ${{ secrets.AICREDITS_API_KEY }}
- name: Commit changelog
run: |
git config user.name 'release-bot'
git config user.email '[email protected]'
git add CHANGELOG.md
git diff --cached --quiet || git commit -m 'docs: refresh unreleased changelog'
git push
Guardrails that keep generated notes honest
Constrain the input, not just the prompt. Anything you do not send cannot be hallucinated, which is why the script strips merge and release-bot commits before the call.
Post-filter for invented references. Reject any bullet containing #123 or a URL that does not appear verbatim in the commit text you supplied.
Fail loudly on empty output instead of committing a blank section, as the script does above.
Pin the model name in the script so a change in note style is a deliberate commit rather than a silent vendor-side update.
Cap the range. A 120-commit ceiling keeps latency and token spend predictable; for larger gaps, summarise per tag instead of all at once.
For major releases, open a PR from the bot rather than pushing to main. A human reading the bullet list is still the cheapest quality check you have.
Flash versus pro: choosing per repo
deepseek-v4-flash is the sensible default. It is fast, it costs less, and turning a clean list of commit subjects into five grouped headings is not a hard task. Most repos should stop here.
deepseek-v4-pro earns its higher price when the input is genuinely messy: squashed commits with multi-paragraph bodies, monorepo releases that mix several packages, or a request to also flag breaking changes. A cheap hybrid is to run flash on every push and escalate to pro only when the commit count or churn crosses a threshold you choose.
Both models bill per token. Cache hits and off-peak requests cost less than the standard rate, and pro costs more than flash for the same input. Current numbers live at aicreditsapi.com/pricing — read them there rather than hardcoding figures into a budget alert, since rates move.
How the options compare for this job
| Route | Where it shines | What to plan for |
|---|---|---|
| OpenAI API, direct | Mature tooling, a broad model family, and the reference implementation of function calling | A separate account and quota to manage per pipeline; prompt code is tied to one vendor's roadmap |
| OpenRouter | One key across many vendors, useful when you genuinely want to A/B the same prompt on several models | An extra routing layer between your job and the model, with its own policy and failure modes to debug |
| AiCredits + deepseek-v4-flash | OpenAI-compatible base URL and credits payable by card or PayPal, no Chinese phone number or bank account needed | Narrower catalogue than an aggregator; keep deepseek-v4-pro in reserve for the messy releases |
If your organisation already runs on OpenAI, staying there is defensible — the surrounding tooling is the most polished, and every other provider copies its request shape. OpenRouter is a good answer when cross-vendor routing is the actual requirement. AiCredits is deliberately narrower: DeepSeek credits you can buy internationally, behind a base URL that drops straight into the script above with no other change.
Frequently asked questions
Yes. Construct the client with base_url set to https://api.aicreditsapi.com/v1 and your AiCredits key, then call chat.completions.create exactly as before. Streaming and message shapes are unchanged, so retry helpers and wrappers keep working.
It is a plain Python script plus an environment variable, so GitLab CI, Jenkins, Buildkite, and a local pre-release checklist all work the same way. Only the YAML around it changes.
No. Subject lines and commit bodies handle most releases. Diffs add cost and usually bury the signal; if you must include them, use a stat summary rather than full patches.
Scope the log per package, for example git log -- packages/api, and generate one section per package before concatenating. Sending the whole monorepo history to one prompt produces vague bullets that mention no specific area.
Everything that defines the output lives in the script: model name, temperature, heading order, and the prompt. Keep a golden test of three sample commit lists and assert the shape of the output in CI so drift surfaces as a failing test, not as a surprise in a release.
Run it once in dry-run mode against your own history and read the output before you let it commit. If the bullets look generic, the fix is almost always upstream — better commit subjects or a tighter filter — rather than a bigger model.