Skip to content

Commit 5fbf56a

Browse files
committed
feat: fix timestamps
1 parent 7c881f5 commit 5fbf56a

4 files changed

Lines changed: 59 additions & 4 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish Package to PyPI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.9'
17+
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install setuptools wheel twine build
22+
23+
- name: Check if version changed
24+
id: check_version
25+
run: |
26+
git fetch origin main
27+
PREV_VERSION=$(git show origin/main:logdash/__init__.py | grep -oP "__version__\s*=\s*['\"](\K[^'\"]+)")
28+
CURRENT_VERSION=$(grep -oP "__version__\s*=\s*['\"](\K[^'\"]+)" logdash/__init__.py)
29+
echo "Previous version: $PREV_VERSION"
30+
echo "Current version: $CURRENT_VERSION"
31+
if [ "$PREV_VERSION" != "$CURRENT_VERSION" ]; then
32+
echo "version_changed=true" >> $GITHUB_OUTPUT
33+
else
34+
echo "version_changed=false" >> $GITHUB_OUTPUT
35+
fi
36+
37+
- name: Build package
38+
if: steps.check_version.outputs.version_changed == 'true'
39+
run: python -m build
40+
41+
- name: Publish package
42+
if: steps.check_version.outputs.version_changed == 'true'
43+
uses: pypa/gh-action-pypi-publish@release/v1
44+
with:
45+
password: ${{ secrets.PYPI_API_TOKEN }}

logdash/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
from logdash.metrics import MetricOperation
44

55
__all__ = ["create_logdash", "Logger", "MetricOperation"]
6-
__version__ = "0.2.0"
6+
__version__ = "1.0.0"

logdash/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime
1+
from datetime import datetime, timezone
22
from typing import Dict, Optional, Any
33

44
from logdash.logger import Logger
@@ -21,7 +21,8 @@ def __init__(self, api_key: Optional[str] = None, host: str = "https://api.logda
2121

2222
# Initialize logger
2323
def on_log(level: LogLevel, message: str) -> None:
24-
self._log_sync.send(message, level, datetime.now().isoformat())
24+
self._log_sync.send(message, level, datetime.now(timezone.utc).isoformat().replace('+00:00', 'Z')
25+
)
2526

2627
self._logger_instance = Logger(log_method=print, on_log=on_log)
2728

setup.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
"""
44

55
from setuptools import setup, find_packages
6+
import re
7+
8+
# Read version from __init__.py
9+
with open('logdash/__init__.py', 'r') as f:
10+
version_match = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE)
11+
if version_match:
12+
version = version_match.group(1)
13+
else:
14+
raise RuntimeError('Cannot find version information')
615

716
setup(
817
name="logdash",
9-
version="0.2.2",
18+
version=version,
1019
packages=find_packages(),
1120
install_requires=[
1221
"requests>=2.25.0",

0 commit comments

Comments
 (0)