Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up versioning #22

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[bumpversion]
current_version = 0.1.0
commit = True
tag = True

[bumpversion:file:version.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[bumpversion:file:setup.py]
search = version="{current_version}"
replace = version="{new_version}"
90 changes: 90 additions & 0 deletions .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Version Management

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
push:
branches:
- main

jobs:
preview-bump:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: "Preview version bump"
steps:
- name: Check out
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install commitizen
run: pip install commitizen

- name: Preview version bump
id: preview
run: |
if git log -1 --pretty=%B | grep -qE '^(feat|fix|BREAKING CHANGE):|#(minor|major)'; then
NEW_VERSION=$(cz bump --dry-run)
else
NEW_VERSION=$(cz bump --increment PATCH --dry-run)
fi
echo "New version would be: $NEW_VERSION"
echo "::set-output name=new_version::$NEW_VERSION"

- name: Comment PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.name,
body: 'When merged, this PR will bump the version to: ${{ steps.preview.outputs.new_version }}'
})

bump-version:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
name: "Bump version and create changelog"
steps:
- name: Check out
uses: actions/checkout@v2
with:
fetch-depth: 0
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install commitizen
run: pip install commitizen

- name: Bump version
id: cz
run: |
if git log -1 --pretty=%B | grep -qE '^(feat|fix|BREAKING CHANGE):|#(minor|major)'; then
cz bump --yes
else
cz bump --increment PATCH --yes
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true

- name: Print Version
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ https://github.com/user-attachments/assets/8aa729ff-c431-4a61-a9ef-d17050a27d02

## Usage

To test the API connection, run:

```
python codeaide.py test
```
This will send a simple "Hi Claude, are we communicating?" prompt to the API. If your API key is set up properly and you have an internet connection, you'll see a response at the command line that looks something like this:
```
Connection successful!
Claude says: Yes, we are communicating! I'm Claude, an AI assistant. How can I help you today?
```

To start CodeAIde for actual code generation, run:

```
Expand All @@ -79,6 +68,18 @@ Follow the prompts to interact with the AI assistant. You can:
- Copy the code to your clipboard or save it as a standalone file
- Select and re-run any previous version of the code form the current conversation.


To test the API connection, run:

```
python codeaide.py test
```
This will send a simple "Hi Claude, are we communicating?" prompt to the API. If your API key is set up properly and you have an internet connection, you'll see a response at the command line that looks something like this:
```
Connection successful!
Claude says: Yes, we are communicating! I'm Claude, an AI assistant. How can I help you today?
```

## Future feature roadmap

The following features do not currently exist, but adding them in the future would make this project more useful:
Expand Down
28 changes: 1 addition & 27 deletions codeaide.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
import sys

from PyQt5.QtWidgets import QApplication

from codeaide.logic.chat_handler import ChatHandler
from codeaide.ui.chat_window import ChatWindow
from codeaide.utils import api_utils


def main():
chat_handler = ChatHandler()

if len(sys.argv) > 1 and sys.argv[1] == "test":
success, message = chat_handler.check_api_connection()
success, message = api_utils.test_api_connection()
if success:
print("Connection successful!")
print("Claude says:", message)
else:
print("Connection failed.")
print("Error:", message)
else:
app = QApplication(sys.argv)
chat_window = ChatWindow(chat_handler)
chat_window.show()
sys.exit(app.exec_())

from codeaide.__main__ import main

if __name__ == "__main__":
main()
30 changes: 30 additions & 0 deletions codeaide/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys

from PyQt5.QtWidgets import QApplication

from codeaide.logic.chat_handler import ChatHandler
from codeaide.ui.chat_window import ChatWindow
from codeaide.utils import api_utils


def main():
chat_handler = ChatHandler()

if len(sys.argv) > 1 and sys.argv[1] == "test":
success, message = chat_handler.check_api_connection()
success, message = api_utils.test_api_connection()
if success:
print("Connection successful!")
print("Claude says:", message)
else:
print("Connection failed.")
print("Error:", message)
else:
app = QApplication(sys.argv)
chat_window = ChatWindow(chat_handler)
chat_window.show()
sys.exit(app.exec_())


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ black
isort
pre-commit
pyqt5
bump2version
30 changes: 30 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from setuptools import setup, find_packages
from version import __version__

# Read requirements from requirements.txt
with open("requirements.txt") as f:
requirements = f.read().splitlines()

setup(
name="codeaide",
version=__version__,
packages=find_packages(),
install_requires=requirements,
entry_points={
"console_scripts": [
"codeaide=codeaide.__main__:main",
],
},
author="Doug Ollerenshaw",
author_email="[email protected]",
description="A chat application leveraging large language models (LLMs) for code generation and execution",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url="https://github.com/dougollerenshaw/CodeAIde",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.8",
)
2 changes: 2 additions & 0 deletions version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# version.py
__version__ = "0.1.0"
Loading