Skip to content

feat(inspect+dogfood): broader inspect --json + canonical bundle lock… #34

feat(inspect+dogfood): broader inspect --json + canonical bundle lock…

feat(inspect+dogfood): broader inspect --json + canonical bundle lock… #34

name: Update Unreleased Changelog
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- CHANGELOG.md
concurrency:
group: update-unreleased-changelog-${{ github.ref }}
cancel-in-progress: true
permissions:
actions: write
contents: write
issues: read
pull-requests: write
jobs:
update-unreleased-changelog:
runs-on: ubuntu-latest
timeout-minutes: 20
env:
BASE_BRANCH: main
CHANGELOG_BRANCH: automation/update-unreleased-changelog
steps:
- name: Check out main
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: main
fetch-depth: 0
persist-credentials: false
- name: Set up mise
uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3.6.3
with:
install_args: --locked
- name: Prepare changelog branch
run: git switch -c "$CHANGELOG_BRANCH"
- name: Generate unreleased changelog
env:
GITHUB_TOKEN: ${{ github.token }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
COMMUNIQUE_MODEL: ${{ vars.COMMUNIQUE_MODEL }}
run: |
set -euo pipefail
if [[ -z "${ANTHROPIC_API_KEY:-}" && -z "${OPENAI_API_KEY:-}" ]]; then
echo 'ANTHROPIC_API_KEY or OPENAI_API_KEY is required to generate changelog entries with Communique.' >&2
exit 1
fi
if [[ -z "${ANTHROPIC_API_KEY:-}" && -z "${COMMUNIQUE_MODEL:-}" ]]; then
echo 'Set COMMUNIQUE_MODEL when using OPENAI_API_KEY so Communique can select an OpenAI-compatible model.' >&2
exit 1
fi
communique_args=()
if [[ -n "${COMMUNIQUE_MODEL:-}" ]]; then
communique_args+=(--model "$COMMUNIQUE_MODEL")
fi
communique generate HEAD \
--changelog \
--repo "$GITHUB_REPOSITORY" \
"${communique_args[@]}"
- name: Open or update changelog PR
id: changelog_pr
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if git diff --quiet -- CHANGELOG.md; then
echo 'CHANGELOG.md is already up to date.'
echo 'pushed=false' >> "$GITHUB_OUTPUT"
exit 0
fi
changed_files="$(git diff --name-only)"
if [[ "$changed_files" != 'CHANGELOG.md' ]]; then
printf 'Communique changed unexpected files:\n%s\n' "$changed_files" >&2
exit 1
fi
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add CHANGELOG.md
git commit -m 'docs: update unreleased changelog'
auth_header="$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 | tr -d '\n')"
git -c "http.https://github.com/.extraheader=AUTHORIZATION: basic ${auth_header}" \
fetch --no-tags origin \
"+refs/heads/${CHANGELOG_BRANCH}:refs/remotes/origin/${CHANGELOG_BRANCH}" || true
git -c "http.https://github.com/.extraheader=AUTHORIZATION: basic ${auth_header}" \
push --force-with-lease origin "HEAD:${CHANGELOG_BRANCH}"
body_file="$(mktemp)"
cat > "$body_file" <<'EOF'
## Summary
Updates the `[Unreleased]` section of `CHANGELOG.md` after changes merged to `main`.
Generated by:
```sh
communique generate HEAD --changelog
```
EOF
pr_number="$(gh pr list --head "$CHANGELOG_BRANCH" --state open --json number --jq '.[0].number // empty')"
if [[ -n "$pr_number" ]]; then
gh pr edit "$pr_number" \
--title 'docs(CHANGELOG.md): update unreleased section' \
--body-file "$body_file"
echo "Updated existing changelog PR #${pr_number}."
else
gh pr create \
--head "$CHANGELOG_BRANCH" \
--base "$BASE_BRANCH" \
--title 'docs(CHANGELOG.md): update unreleased section' \
--body-file "$body_file"
fi
echo 'pushed=true' >> "$GITHUB_OUTPUT"
- name: Dispatch follow-up checks
if: steps.changelog_pr.outputs.pushed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
gh workflow run ci.yml --ref "$CHANGELOG_BRANCH"
gh workflow run validate-skills.yml --ref "$CHANGELOG_BRANCH"