Skip to content

Commit 5438b75

Browse files
add workflows to bump version
1 parent 675fd86 commit 5438b75

File tree

10 files changed

+399
-9
lines changed

10 files changed

+399
-9
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
push:
99
branches:
1010
- main
11+
- dev
12+
paths:
13+
- 'app/core/version.py'
14+
- 'pyproject.toml'
1115

1216
concurrency:
1317
group: ${{ github.head_ref || github.run_id }}
@@ -30,14 +34,38 @@ jobs:
3034
username: ${{ github.actor }}
3135
password: ${{ secrets.CR_TOKEN }}
3236

37+
- name: Set up Python
38+
uses: actions/setup-python@v6
39+
with:
40+
python-version: '3.11'
41+
42+
- name: Read version from version.py
43+
id: get-version
44+
run: |
45+
# Try Python import first
46+
VERSION=$(python -c "import sys; sys.path.insert(0, '.'); from app.core.version import __version__; print(__version__)" 2>/dev/null || echo "")
47+
# Fallback to regex if import fails
48+
if [ -z "${VERSION}" ]; then
49+
VERSION=$(grep -oP '__version__\s*=\s*"\K[^"]*' app/core/version.py || echo "0.0.0")
50+
fi
51+
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
52+
echo "Read version: ${VERSION}"
53+
3354
- name: Set Docker image tag
3455
id: set-tag
3556
run: |
36-
echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
57+
VERSION="${{ steps.get-version.outputs.VERSION }}"
58+
echo "IMAGE_TAG=${VERSION}" >> $GITHUB_OUTPUT
59+
echo "Building Docker image with version: ${VERSION}"
3760
3861
- name: Build and Push Docker image
3962
working-directory: "./"
4063
run: |
4164
REPO_NAME="${GITHUB_REPOSITORY,,}"
42-
docker build -t ghcr.io/${REPO_NAME}:${{ steps.set-tag.outputs.IMAGE_TAG }} .
43-
docker push ghcr.io/${REPO_NAME}:${{ steps.set-tag.outputs.IMAGE_TAG }}
65+
IMAGE_TAG="${{ steps.set-tag.outputs.IMAGE_TAG }}"
66+
# Build and tag with version
67+
docker build -t ghcr.io/${REPO_NAME}:${IMAGE_TAG} .
68+
docker push ghcr.io/${REPO_NAME}:${IMAGE_TAG}
69+
# Also tag as latest
70+
docker tag ghcr.io/${REPO_NAME}:${IMAGE_TAG} ghcr.io/${REPO_NAME}:latest
71+
docker push ghcr.io/${REPO_NAME}:latest

.github/workflows/release.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Create GitHub Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
paths:
9+
- 'app/core/version.py'
10+
- 'pyproject.toml'
11+
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
packages: write
19+
contents: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v5
24+
with:
25+
fetch-depth: 0 # Fetch all history for all tags and branches
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v6
29+
with:
30+
python-version: '3.11'
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install openai pydantic
36+
37+
- name: Run Python script to generate release notes
38+
id: generate_release_notes
39+
env:
40+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: |
43+
echo "Running generate_release_notes.py"
44+
python scripts/generate_release_notes.py
45+
echo "Script completed"
46+
47+
- name: Debug Outputs
48+
run: |
49+
echo "Version: ${{ steps.generate_release_notes.outputs.version }}"
50+
echo "Release Notes: ${{ steps.generate_release_notes.outputs.release_notes }}"
51+
52+
- name: Create Release Tag
53+
run: |
54+
VERSION=$(cat $GITHUB_OUTPUT | grep "^version=" | cut -f2- -d=)
55+
echo "Creating tag: $VERSION"
56+
git tag $VERSION
57+
git push origin $VERSION
58+
59+
- name: Create GitHub Release
60+
uses: actions/create-release@v1
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
with:
64+
tag_name: ${{ steps.generate_release_notes.outputs.version }}
65+
release_name: Release ${{ steps.generate_release_notes.outputs.version }} - ${{ steps.generate_release_notes.outputs.version_name }}
66+
body: ${{ steps.generate_release_notes.outputs.release_notes }}
67+
draft: false
68+
prerelease: ${{ github.ref == 'refs/heads/dev' }}

app/api/endpoints/manifest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from app.core.config import settings
66
from app.core.settings import UserSettings, decode_settings
7+
from app.core.version import __version__
78
from app.services.catalog import DynamicCatalogService
89
from app.services.stremio_service import StremioService
910
from app.utils import resolve_user_credentials
@@ -41,7 +42,7 @@ def get_base_manifest(user_settings: UserSettings | None = None):
4142

4243
return {
4344
"id": settings.ADDON_ID,
44-
"version": settings.APP_VERSION,
45+
"version": __version__,
4546
"name": settings.ADDON_NAME,
4647
"description": "Movie and series recommendations based on your Stremio library",
4748
"logo": "https://raw.githubusercontent.com/TimilsinaBimal/Watchly/refs/heads/main/static/logo.png",

app/core/app.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from app.services.catalog_updater import BackgroundCatalogUpdater
1313

1414
from .config import settings
15+
from .version import __version__
1516

1617
# class InterceptHandler(logging.Handler):
1718
# def emit(self, record):
@@ -57,7 +58,7 @@ async def lifespan(app: FastAPI):
5758
app = FastAPI(
5859
title="Watchly",
5960
description="Stremio catalog addon for movie and series recommendations",
60-
version=settings.APP_VERSION,
61+
version=__version__,
6162
lifespan=lifespan,
6263
)
6364

@@ -93,10 +94,10 @@ async def configure_page(token: str | None = None):
9394
announcement_html = (dynamic_announcement or "").strip()
9495
snippet = ""
9596
if announcement_html:
96-
snippet = '\n <div class="announcement">' f"{announcement_html}" "</div>"
97+
snippet = f'\n <div class="announcement">{announcement_html}</div>'
9798
html_content = html_content.replace("<!-- ANNOUNCEMENT_HTML -->", snippet, 1)
9899
# Inject version
99-
html_content = html_content.replace("<!-- APP_VERSION -->", settings.APP_VERSION, 1)
100+
html_content = html_content.replace("<!-- APP_VERSION -->", __version__, 1)
100101
# Inject host
101102
html_content = html_content.replace("<!-- APP_HOST -->", settings.HOST_NAME, 1)
102103
return HTMLResponse(content=html_content, media_type="text/html")

app/core/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from pydantic_settings import BaseSettings, SettingsConfigDict
44

5+
from app.core.version import __version__
6+
57

68
class Settings(BaseSettings):
79
"""Application settings loaded from environment variables."""
@@ -17,7 +19,6 @@ class Settings(BaseSettings):
1719
PORT: int = 8000
1820
ADDON_ID: str = "com.bimal.watchly"
1921
ADDON_NAME: str = "Watchly"
20-
APP_VERSION: str = "1.0.0"
2122
REDIS_URL: str = "redis://redis:6379/0"
2223
TOKEN_SALT: str = "change-me"
2324
TOKEN_TTL_SECONDS: int = 0 # 0 = never expire
@@ -36,3 +37,6 @@ class Settings(BaseSettings):
3637

3738

3839
settings = Settings()
40+
41+
# Get version from version.py (single source of truth)
42+
APP_VERSION = __version__

app/core/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.0.0.beta.1"

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
2+
dynamic = ["version"]
23
name = "watchly"
3-
version = "0.1.0"
44
description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.10"
@@ -15,9 +15,13 @@ dependencies = [
1515
"pydantic>=2.5.0",
1616
"pydantic-settings>=2.1.0",
1717
"redis>=5.0.1",
18+
"tomli>=2.3.0",
1819
"uvicorn[standard]>=0.24.0",
1920
]
2021

22+
[tool.setuptools.dynamic]
23+
version = { attr = "app.core.version.__version__" }
24+
2125
[dependency-groups]
2226
dev = [
2327
"black>=25.11.0",

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ redis>=5.0.1
99
cryptography>=41.0.0
1010
async-lru>=2.0.5
1111
apscheduler>=3.11.1
12+
tomli>=2.3.0

0 commit comments

Comments
 (0)