Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | ||
on: | ||
push: | ||
branches: | ||
- dev | ||
- main | ||
jobs: | ||
generate-release-notes: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8.6.6 | ||
- name: Install dependencies | ||
run: pnpm install | ||
# For generating release notes when merging to 'dev' | ||
- name: Generate Release Notes for dev | ||
if: github.ref == 'refs/heads/dev' | ||
run: | | ||
# Get the diff between the previous commit and the current merge commit | ||
PREV_COMMIT=$(git rev-parse HEAD^1) | ||
git diff $PREV_COMMIT HEAD > changes.diff | ||
# Use GPT to generate release notes based on the diff | ||
echo "Generating release notes with GPT..." | ||
RELEASE_NOTES=$(python3 <<EOF | ||
import openai | ||
openai.api_key = "${{ secrets.OPENAI_API_KEY }}" | ||
with open('changes.diff', 'r') as f: | ||
diff_content = f.read() | ||
response = openai.Completion.create( | ||
model="gpt-4", | ||
prompt=f"Generate detailed release notes based on this git diff: {diff_content}", | ||
max_tokens=500 | ||
) | ||
print(response['choices'][0]['text'].strip()) | ||
EOF | ||
) | ||
echo "Release Notes: $RELEASE_NOTES" | ||
# Save release notes to a file | ||
echo "$RELEASE_NOTES" > RELEASE_NOTES.md | ||
# Commit release notes to the dev branch | ||
git add RELEASE_NOTES.md | ||
git commit -m "Generated release notes for dev" | ||
git push | ||
summarize-release-notes: | ||
runs-on: ubuntu-latest | ||
needs: generate-release-notes | ||
if: github.ref == 'refs/heads/main' | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8.6.6 | ||
- name: Install dependencies | ||
run: pnpm install | ||
# Aggregate and summarize release notes when merging to 'main' | ||
- name: Summarize Release Notes for main | ||
run: | | ||
# Aggregate all the release notes from the dev branch | ||
RELEASE_NOTES=$(git log --oneline --grep="Generated release notes for dev" --pretty=format:"%s%n%b") | ||
echo "Summarizing release notes with GPT..." | ||
SUMMARY_NOTES=$(python3 <<EOF | ||
import openai | ||
openai.api_key = "${{ secrets.OPENAI_API_KEY }}" | ||
response = openai.Completion.create( | ||
model="gpt-4", | ||
prompt=f"Summarize these release notes: {RELEASE_NOTES}", | ||
max_tokens=500 | ||
) | ||
print(response['choices'][0]['text'].strip()) | ||
EOF | ||
) | ||
echo "Release Summary: $SUMMARY_NOTES" | ||
# Save summarized release notes to a file | ||
echo "$SUMMARY_NOTES" > SUMMARY_RELEASE_NOTES.md | ||
# Commit summarized release notes to the main branch | ||
git add SUMMARY_RELEASE_NOTES.md | ||
git commit -m "Summarized release notes for main" | ||
git push |