Skip to content

Commit 15f6e77

Browse files
workflow added
1 parent c44e24f commit 15f6e77

File tree

3 files changed

+143
-17
lines changed

3 files changed

+143
-17
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Create PR from dev to main
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
8+
jobs:
9+
create-pull-request:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
ref: dev
21+
22+
- name: Set Git Identity
23+
run: |
24+
git config --global user.name 'GitHub Actions'
25+
git config --global user.email 'github-actions@github.com'
26+
27+
- name: Create Pull Request with gh cli
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: |
31+
# We're already on dev, just need to fetch main
32+
git fetch origin main:refs/remotes/origin/main
33+
34+
# Check if there are differences between main and dev
35+
DIFF_COUNT=$(git rev-list --count origin/main..HEAD)
36+
37+
if [ "$DIFF_COUNT" -gt 0 ]; then
38+
echo "Differences found between main and dev. Creating PR..."
39+
40+
# Use GitHub CLI to create the PR
41+
gh pr create \
42+
--base main \
43+
--head dev \
44+
--title "Merge dev into main" \
45+
--body "This is an automated PR to merge changes from dev into main branch." || true
46+
47+
echo "Pull request created or already exists."
48+
else
49+
echo "No differences found between main and dev. Skipping PR creation."
50+
fi
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release and Publish Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
id-token: write
15+
pull-requests: write
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v3
25+
with:
26+
python-version: "3.x"
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install build twine python-semantic-release==10.0.2 setuptools-scm
32+
33+
- name: Create release branch
34+
run: |
35+
git config --global user.name "github-actions"
36+
git config --global user.email "github-actions@github.com"
37+
git checkout -b release-main
38+
git push --set-upstream origin release-main
39+
40+
- name: Run semantic-release version on release-main branch
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
semantic-release --verbose version
45+
46+
# For semantic-release 9.x, the publish command needs to be run separately
47+
- name: Run semantic-release publish
48+
env:
49+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
#PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
51+
run: |
52+
semantic-release --verbose publish
53+
54+
- name: Push release branch
55+
run: git push origin release-main
56+
57+
- name: Create PR to main
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
run: |
61+
gh pr create \
62+
--base main \
63+
--head release-main \
64+
--title "Automated Release Updates" \
65+
--body "This pull request contains updates from the semantic-release process." || true
66+
67+
# This is only needed if semantic-release publish didn't handle the PyPI upload
68+
# - name: Build and publish package to PyPI if needed
69+
# env:
70+
# TWINE_USERNAME: __token__
71+
# TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
72+
# run: |
73+
# if [ ! -f "dist/*" ]; then
74+
# python -m build
75+
# twine upload dist/*
76+
# fi
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
"""ML and AWS configuration settings."""
2-
32
import os
43
import boto3
54
from dotenv import load_dotenv
65
from langchain_aws import ChatBedrockConverse
76

87
load_dotenv()
98

10-
119
class MLConfig:
1210
"""Base configuration class."""
1311

1412
def get_llm_model(self):
1513
"""Method to get LLM model instance."""
16-
raise NotImplementedError('This method should be overridden by subclasses.')
17-
14+
raise NotImplementedError("This method should be overridden by subclasses.")
15+
1816
def get_client(self):
1917
"""Method to get client instance."""
2018
pass
2119

22-
2320
class AWSMLConfig(MLConfig):
2421
"""Configuration class for ML and AWS settings."""
25-
26-
def __init__(self, aws_token: str = None, aws_region: str = None, model_name: str = None):
22+
23+
def __init__(
24+
self,
25+
aws_token: str = None,
26+
aws_region: str = None,
27+
model_name: str = None
28+
):
2729
self.AWS_BEARER_TOKEN_BEDROCK = aws_token or os.getenv('AWS_BEARER_TOKEN_BEDROCK')
2830
self.AWS_DEFAULT_REGION = aws_region or os.getenv('AWS_DEFAULT_REGION', 'us-west-2')
29-
self.MODEL_NAME = model_name or os.getenv(
30-
'MODEL_NAME', 'us.anthropic.claude-sonnet-4-20250514-v1:0'
31-
)
32-
31+
self.MODEL_NAME = model_name or os.getenv("MODEL_NAME","us.anthropic.claude-sonnet-4-20250514-v1:0")
32+
3333
if not self.AWS_BEARER_TOKEN_BEDROCK:
34-
raise ValueError('AWS_BEARER_TOKEN_BEDROCK not found in .env file.')
35-
34+
raise ValueError("AWS_BEARER_TOKEN_BEDROCK not found in .env file.")
35+
3636
self._client = None
3737
self._llm = None
38-
38+
3939
def get_client(self):
4040
"""Get AWS Bedrock client (singleton pattern)."""
4141
if self._client is None:
4242
self._client = boto3.client(
43-
'bedrock-runtime',
43+
"bedrock-runtime",
4444
region_name=self.AWS_DEFAULT_REGION,
4545
aws_access_key_id=None,
4646
aws_secret_access_key=None,
4747
aws_session_token=self.AWS_BEARER_TOKEN_BEDROCK,
4848
)
4949
return self._client
50-
50+
5151
def get_llm_model(self):
5252
"""Get LLM model instance (singleton pattern)."""
5353
if self._llm is None:
@@ -57,4 +57,4 @@ def get_llm_model(self):
5757
temperature=0,
5858
max_tokens=4000,
5959
)
60-
return self._llm
60+
return self._llm

0 commit comments

Comments
 (0)