Skip to content

Commit

Permalink
Merge pull request #12 from omnisat/test
Browse files Browse the repository at this point in the history
testing
  • Loading branch information
hathbanger authored Oct 12, 2024
2 parents f8ddbeb + 9327f7e commit 42b831d
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 24 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- main
- dev

jobs:
setup:
Expand Down
173 changes: 152 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,185 @@ name: Release
on:
push:
branches:
- main
- dev
- main

jobs:
release:
generate-release-notes:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev' && github.event_name != 'pull_request'
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

- name: Generate git diff
run: |
PREV_COMMIT=$(git rev-parse HEAD^1)
git diff $PREV_COMMIT HEAD > changes.diff
# Generate release notes using the external Python script
- name: Generate Release Notes with GPT
run: |
python3 scripts/generate_release_notes.py > releases/dev_release_notes_$(date +'%Y-%m-%d').md # Store in releases directory
# Commit the release notes to the releases directory
- name: Commit Release Notes
run: |
git add releases/
git commit -m "Added release notes for dev $(date +'%Y-%m-%d')"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

changeset-rc-version:
runs-on: ubuntu-latest
needs: generate-release-notes
if: github.ref == 'refs/heads/dev'
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
# Run Changesets version for RC
- name: Run Changesets pre-release mode for RC
run: |
if [ "${{ github.ref }}" == "refs/heads/dev" ]; then
pnpx changeset pre enter rc
fi
pnpx changeset version
pnpx changeset pre enter rc # Enter RC mode
pnpx changeset version # Bump RC version
- name: Push Changeset version update
# Commit the version bump and changelog
- name: Commit version bumps and changelog
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 commit -m "RC version bump"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
uses: changesets/action@v1
publish-rc-release:
runs-on: ubuntu-latest
needs: changeset-rc-version
if: github.ref == 'refs/heads/dev'
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:
publish: false
version: false
changelog: true
version: 8.6.6

- name: Install dependencies
run: pnpm install

# Publish the RC version to npm (or another registry)
- name: Publish RC to npm
run: pnpm publish --tag rc --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

changeset-stable-version:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: publish-rc-release
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

# Exit pre-release mode
- name: Exit RC mode
run: pnpx changeset pre exit

# Run Changesets version to bump versions and generate changelogs for stable release
- name: Run Changesets version
run: pnpx changeset version

# Commit the version bump and changelog
- name: Commit version bumps and changelog
run: |
git add .
git commit -m "Stable version bump"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Echo publish action
run: echo "This is where the package would be published to npm."
publish-stable-release:
runs-on: ubuntu-latest
needs: changeset-stable-version
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

# Publish the stable version to npm
- name: Publish stable release to npm
run: pnpm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# Create a GitHub Release with the summarized release notes
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: ${{ github.sha }}
release_name: "Stable Release ${{ github.sha }}"
body_path: releases/main_summary_notes_$(date +'%Y-%m-%d').md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 0 additions & 3 deletions .husky/pre-commit

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

# lasereyes



A common wallet interface for building React applications on Bitcoin.

![Version](https://img.shields.io/npm/v/@omnisat/lasereyes)
Expand Down
19 changes: 19 additions & 0 deletions scripts/generate_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import openai
import os

# Get the OpenAI API key from environment variables
openai.api_key = os.getenv("OPENAI_API_KEY")

# Read the git diff content from a file (generated in the GitHub Action)
with open('changes.diff', 'r') as f:
diff_content = f.read()

# Use OpenAI's GPT to generate detailed release notes based on the git diff
response = openai.Completion.create(
model="gpt-4",
prompt=f"Generate detailed release notes based on this git diff: {diff_content}",
max_tokens=500
)

# Print the generated release notes to stdout
print(response['choices'][0]['text'].strip())
19 changes: 19 additions & 0 deletions scripts/summarize_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import openai
import os

# Get the OpenAI API key from environment variables
openai.api_key = os.getenv("OPENAI_API_KEY")

# Read the aggregated release notes from a file
with open('release_notes_aggregated.txt', 'r') as f:
release_notes = f.read()

# Use OpenAI's GPT to summarize the release notes
response = openai.Completion.create(
model="gpt-4",
prompt=f"Summarize these release notes: {release_notes}",
max_tokens=500
)

# Print the summarized release notes to stdout
print(response['choices'][0]['text'].strip())

0 comments on commit 42b831d

Please sign in to comment.