Skip to content

Commit 7b5aa31

Browse files
committed
improved with love 💖🥰
1 parent 9a44a84 commit 7b5aa31

6 files changed

Lines changed: 69 additions & 55 deletions

File tree

.github/workflows/auto-bump-version.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/publish-to-pypi.yml

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,72 @@
1-
# workflow automates the Python package publishing process
1+
# workflow automates the Python package publishing process
22
# to PyPI upon pushes to the main branch or manual triggers,
3-
# incrementing version if needed.
3+
# auto-bumps version before publishing.
44

55
name: Publish to PyPI
66
on:
77
push:
88
branches:
99
- main
1010
paths-ignore:
11-
- '**.md' # Ignore changes to Markdown files to prevent infinite loop
11+
- '**.md'
1212
workflow_dispatch:
1313
jobs:
1414
deploy:
1515
runs-on: ubuntu-latest
16-
if: github.actor != 'github-actions[bot]' # This line prevents the loop
16+
if: github.actor != 'github-actions[bot]'
1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
19+
with:
20+
token: ${{ secrets.GH_TOKEN }}
21+
fetch-depth: 0
22+
23+
- name: Get current version
24+
run: |
25+
current_version=$(grep 'version =' pyproject.toml | cut -d'"' -f2)
26+
echo "CURRENT_VERSION=$current_version" >> $GITHUB_ENV
27+
28+
- name: Bump version
29+
run: |
30+
IFS=. read -r major minor patch <<< "${CURRENT_VERSION}"
31+
patch=$((patch + 1))
32+
new_version="${major}.${minor}.${patch}"
33+
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
34+
35+
- name: Update version in setup.py
36+
run: |
37+
sed -i "s/version='.*'/version='$NEW_VERSION'/" setup.py
38+
39+
- name: Update version in pyproject.toml
40+
run: |
41+
sed -i "s/version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml
42+
43+
- name: Commit version bump
44+
run: |
45+
git config --global user.name "github-actions[bot]"
46+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
47+
git add .
48+
git commit -m "Auto bump version to $NEW_VERSION"
49+
git push origin main
50+
1951
- name: Set up Python
20-
uses: actions/setup-python@v2
52+
uses: actions/setup-python@v5
2153
with:
22-
python-version: '3.x'
54+
python-version: '3.12'
55+
2356
- name: Install dependencies
2457
run: |
2558
python -m pip install --upgrade pip
2659
pip install poetry
27-
- name: re run poetry lockfile
28-
run: poetry lock --no-update
60+
61+
- name: Re-run poetry lockfile
62+
run: poetry lock
63+
2964
- name: Install project dependencies
3065
run: poetry install
66+
3167
- name: Build package
3268
run: poetry build
69+
3370
- name: Publish to PyPI
3471
uses: pypa/gh-action-pypi-publish@release/v1
3572
with:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["Tharaka Umayanga <tharakau@gmail.com>"]
66
readme = "README.md"
77
packages = [{include = "vedastro"}]
88
[tool.poetry.dependencies]
9-
python = ">=3.9,<3.13"
9+
python = ">=3.9,<4.0"
1010
colorama = "*"
1111
packaging = "*"
1212
requests = "*"

vedastro/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# VedAstro Python Library - REST API Mode
22
# https://vedastro.org
33

4-
print("VedAstro - Made & Funded by Users - https://vedastro.org/Donate\n")
4+
from colorama import Fore, Style
5+
6+
print(Fore.CYAN + "══════════════════════════════════════════════════════" + Style.RESET_ALL)
7+
print(Fore.CYAN + " 🪐 VedAstro" + Style.RESET_ALL + " - Vedic Astrology Library")
8+
print(" Open-source & powerful astronomical calculations")
9+
print()
10+
print(" 🌐 " + Fore.BLUE + "https://vedastro.org" + Style.RESET_ALL)
11+
print(" 📖 " + Fore.BLUE + "https://vedastro.org/API" + Style.RESET_ALL)
12+
print(" 💖 " + Fore.BLUE + "https://vedastro.org/Donate" + Style.RESET_ALL)
13+
print(Fore.CYAN + "══════════════════════════════════════════════════════" + Style.RESET_ALL)
14+
print()
515

616
from .update_check import check_for_update
717
check_for_update("vedastro")

vedastro/calculate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class Calculate:
1515
@classmethod
1616
def SetAPIKey(cls, api_key):
1717
cls.api_key = api_key
18+
if api_key and api_key != "FreeAPIUser":
19+
from colorama import Fore, Style
20+
print(Fore.GREEN + "⭐ Thank you for subscribing! Your support keeps VedAstro free & open-source." + Style.RESET_ALL)
1821

1922
@classmethod
2023
def SetAyanamsa(cls, ayanamsa):

vedastro/update_check.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from colorama import Fore, Style
22
from packaging import version
33
import requests
4+
import subprocess
5+
import sys
46

57

68
def check_for_update(package_name):
@@ -12,8 +14,12 @@ def check_for_update(package_name):
1214
latest_version = response.json()['info']['version']
1315

1416
if version.parse(installed_version) < version.parse(latest_version):
15-
print(Fore.YELLOW + f"VedAstro Package Outdated! {installed_version} --> {latest_version}" + Style.RESET_ALL)
16-
print(Fore.YELLOW + f"Run: pip install --upgrade {package_name}" + Style.RESET_ALL)
17+
print(Fore.YELLOW + f"VedAstro Update Available: {installed_version} --> {latest_version}" + Style.RESET_ALL)
18+
print(Fore.YELLOW + "Auto-updating..." + Style.RESET_ALL)
19+
subprocess.check_call(
20+
[sys.executable, "-m", "pip", "install", "--upgrade", package_name, "--quiet"],
21+
)
22+
print(Fore.GREEN + f"VedAstro updated to {latest_version}. Please restart your script for changes to take effect." + Style.RESET_ALL)
1723

1824
except Exception:
1925
return

0 commit comments

Comments
 (0)