5454 contents : write
5555 outputs :
5656 version : ${{ steps.version.outputs.version }}
57+ env :
58+ USE_CODEX : ' false' # Set to 'true' to use OpenAI Codex instead of Claude
5759 steps :
5860 - name : Checkout repository
5961 uses : actions/checkout@v4
7678 script : |
7779 const latestRelease = await github.rest.repos.getLatestRelease({ owner: context.repo.owner, repo: context.repo.repo }).catch(()=>null);
7880 let nextVersion;
81+ let prevTagRaw = '';
7982 if (latestRelease) {
80- const prevTagRaw = latestRelease.data.tag_name || '';
83+ prevTagRaw = latestRelease.data.tag_name || '';
8184 const prev = prevTagRaw.replace(/^v/, '');
8285 const parts = prev.split('.');
8386 if (parts.length !== 3 || parts.some(p => isNaN(Number(p)))) {
@@ -91,21 +94,91 @@ jobs:
9194 }
9295 core.info(`Computed next version: ${nextVersion}`);
9396 core.setOutput('version', nextVersion);
97+ core.setOutput('previous_tag', prevTagRaw);
9498
95- - name : Create and push tag
99+ - name : Configure Git
100+ run : |
101+ git config user.name "github-actions[bot]"
102+ git config user.email "github-actions[bot]@users.noreply.github.com"
103+
104+ - name : Generate Context
105+ id : context
106+ run : |
107+ PREV_TAG="${{ steps.version.outputs.previous_tag }}"
108+ if [ -n "$PREV_TAG" ]; then
109+ RANGE="$PREV_TAG..HEAD"
110+ echo "Generating context for range: $RANGE"
111+ else
112+ RANGE=""
113+ echo "Generating context for initial release (all history)"
114+ fi
115+
116+ {
117+ echo 'commits<<EOF'
118+ git log --pretty=format:"- %s (%an) [%h]" $RANGE
119+ echo ''
120+ echo 'EOF'
121+ } >> $GITHUB_OUTPUT
122+
123+ {
124+ echo 'stats<<EOF'
125+ if [ -n "$RANGE" ]; then
126+ git diff --stat $RANGE
127+ else
128+ git show --stat
129+ fi
130+ echo 'EOF'
131+ } >> $GITHUB_OUTPUT
132+
133+ - name : Read Prompt
134+ id : prompt
135+ run : |
136+ PROMPT=$(cat .github/prompts/release-notes.md)
137+ echo "prompt<<EOF" >> $GITHUB_OUTPUT
138+ echo "$PROMPT" >> $GITHUB_OUTPUT
139+ echo "EOF" >> $GITHUB_OUTPUT
140+
141+ - name : Update docs, tag, and release with Claude
142+ if : env.USE_CODEX != 'true'
143+ uses : anthropics/claude-code-action@v1
96144 env :
97- VERSION : ${{ steps.version.outputs.version }}
145+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
146+ with :
147+ anthropic_api_key : ${{ secrets.ANTHROPIC_API_KEY }}
148+ prompt : ${{ steps.prompt.outputs.prompt }}
149+ claude_args : |
150+ --allowedTools "Read,Write,Edit,Bash(git:*)"
151+
152+ - name : Update docs, tag, and release with Codex
153+ if : env.USE_CODEX == 'true'
154+ uses : openai/codex-action@v1
155+ with :
156+ openai-api-key : ${{ secrets.OPENAI_API_KEY }}
157+ prompt : ${{ steps.prompt.outputs.prompt }}
158+ sandbox : workspace-write
159+ codex-args : ' ["--allowedTools", "Read,Write,Edit,Bash(git:*)"]'
160+
161+ - name : Commit and Push Changes
98162 run : |
99- if git rev-parse ${VERSION} >/dev/null 2>&1; then echo "Tag ${VERSION} already exists"; else git tag ${VERSION}; git push origin ${VERSION}; fi
163+ git add CHANGELOG.md README.md package.json
164+ if git diff --staged --quiet; then
165+ echo "No changes to commit"
166+ else
167+ git commit -m "docs: update for release ${{ steps.version.outputs.version }} [skip ci]"
168+ git push origin main
169+ fi
170+
171+ - name : Create Tag
172+ run : |
173+ git tag ${{ steps.version.outputs.version }}
174+ git push origin ${{ steps.version.outputs.version }}
100175
101- - name : Generate release notes & create release
102- uses : ./.github/actions/anthropic-release-notes
176+ - name : Create Release
177+ uses : softprops/action-gh-release@v1
103178 with :
104- anthropic-api-key : ${{ secrets.ANTHROPIC_API_KEY }}
105- language : en
106- model : claude-3-5-sonnet-latest
179+ tag_name : ${{ steps.version.outputs.version }}
180+ body_path : RELEASE_NOTES.md
107181 token : ${{ secrets.GITHUB_TOKEN }}
108- version : ${{ steps.version.outputs.version }}
109182
110183 package :
111184 name : Package Extension
0 commit comments