Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hathbanger committed Oct 12, 2024
1 parent 142079d commit 70483c9
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 33 deletions.
122 changes: 92 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,116 @@ name: Release
on:
push:
branches:
- main
- dev
- main

jobs:
release:
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: 18
cache: 'pnpm'
node-version: 20

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 6.32.9
version: 8.6.6

- name: Install dependencies
run: pnpm install

- name: Create Changesets version
# For generating release notes when merging to 'dev'
- name: Generate Release Notes for dev
if: github.ref == 'refs/heads/dev'
run: |
if [ "${{ github.ref }}" == "refs/heads/dev" ]; then
pnpx changeset pre enter rc
fi
pnpx changeset version
# 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 }}"

- name: Push Changeset version update
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Version Packages"
git push
- name: Create GitHub Release
uses: changesets/action@v1
with:
publish: false
version: false
changelog: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Echo publish action
run: echo "This is where the package would be published to npm."
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
3 changes: 0 additions & 3 deletions .husky/pre-commit

This file was deleted.

0 comments on commit 70483c9

Please sign in to comment.