Skip to content

Commit 3521ed4

Browse files
committed
add release workflow, unify version to pyproject.toml
1 parent 5a11b0e commit 3521ed4

4 files changed

Lines changed: 160 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Build and release Wu forensics toolkit
2+
# Triggers on version tags (v1.2.3) - builds .exe and publishes to PyPI/GitHub Releases
3+
4+
name: Release
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
build-exe:
16+
name: Build Windows Executable
17+
runs-on: windows-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.12'
26+
cache: 'pip'
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -e ".[all,dev]"
32+
pip install pyinstaller
33+
34+
- name: Build executable
35+
run: python build_cli.py
36+
37+
- name: Get version from tag
38+
id: version
39+
shell: bash
40+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
41+
42+
- name: Upload executable artifact
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: wu-windows-exe
46+
path: dist/wu.exe
47+
retention-days: 5
48+
49+
build-package:
50+
name: Build Python Package
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Set up Python
57+
uses: actions/setup-python@v5
58+
with:
59+
python-version: '3.12'
60+
61+
- name: Install build tools
62+
run: |
63+
python -m pip install --upgrade pip
64+
pip install build twine
65+
66+
- name: Build package
67+
run: python -m build
68+
69+
- name: Upload package artifact
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: wu-python-package
73+
path: dist/*.whl
74+
retention-days: 5
75+
76+
release:
77+
name: Create GitHub Release
78+
needs: [build-exe, build-package]
79+
runs-on: ubuntu-latest
80+
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- name: Download Windows executable
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: wu-windows-exe
88+
path: release-assets
89+
90+
- name: Download Python package
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: wu-python-package
94+
path: release-assets
95+
96+
- name: Get version from tag
97+
id: version
98+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
99+
100+
- name: Create Release
101+
uses: softprops/action-gh-release@v1
102+
with:
103+
name: Wu v${{ steps.version.outputs.VERSION }}
104+
body: |
105+
## Wu Forensics Toolkit v${{ steps.version.outputs.VERSION }}
106+
107+
### Installation
108+
109+
**Python package:**
110+
```bash
111+
pip install wu-forensics==${{ steps.version.outputs.VERSION }}
112+
```
113+
114+
**Standalone executable (Windows):**
115+
Download `wu.exe` below - no Python required.
116+
117+
### Changes
118+
See commit history for details.
119+
files: |
120+
release-assets/wu.exe
121+
release-assets/*.whl
122+
draft: false
123+
prerelease: false
124+
125+
publish-pypi:
126+
name: Publish to PyPI
127+
needs: [build-package]
128+
runs-on: ubuntu-latest
129+
environment: pypi
130+
131+
steps:
132+
- name: Download package
133+
uses: actions/download-artifact@v4
134+
with:
135+
name: wu-python-package
136+
path: dist
137+
138+
- name: Publish to PyPI
139+
uses: pypa/gh-action-pypi-publish@release/v1
140+
with:
141+
password: ${{ secrets.PYPI_API_TOKEN }}
142+
skip-existing: true

src/wu/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
in Beta Decay. Physical Review, 105(4), 1413-1415.
1313
"""
1414

15+
from importlib.metadata import version as _get_version, PackageNotFoundError
16+
17+
try:
18+
__version__ = _get_version("wu-forensics")
19+
except PackageNotFoundError:
20+
# Package not installed (running from source)
21+
__version__ = "0.0.0-dev"
22+
1523
from .state import (
1624
DimensionState,
1725
DimensionResult,
@@ -42,8 +50,8 @@
4250
LightVector,
4351
)
4452

45-
__version__ = "1.2.0"
4653
__all__ = [
54+
"__version__",
4755
# Main interface
4856
"WuAnalyzer",
4957
"EpistemicAggregator",
@@ -56,7 +64,7 @@
5664
"OverallAssessment",
5765
"Confidence",
5866
"Evidence",
59-
# Dimension analyzers
67+
# Dimension analysers
6068
"MetadataAnalyzer",
6169
"C2PAAnalyzer",
6270
"GPSAnalyzer",

src/wu/analyzer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@
4747
from .video.analyzer import VideoAnalyzer
4848
from .dimensions.lipsync import LipSyncAnalyzer
4949

50-
__version__ = "1.1.0"
50+
from importlib.metadata import version as _get_version, PackageNotFoundError
51+
52+
try:
53+
__version__ = _get_version("wu-forensics")
54+
except PackageNotFoundError:
55+
__version__ = "0.0.0-dev"
5156

5257
# Default number of workers for parallel execution
5358
DEFAULT_MAX_WORKERS = min(8, (os.cpu_count() or 4))

src/wu/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
except ImportError:
2323
HAS_CLICK = False
2424

25-
from .analyzer import WuAnalyzer
25+
from .analyzer import WuAnalyzer, __version__
2626
from .state import OverallAssessment
2727

2828

@@ -111,7 +111,7 @@ def print_analysis(analysis, verbose: bool = False):
111111

112112
if HAS_CLICK:
113113
@click.group()
114-
@click.version_option(version="1.2.0", prog_name="wu")
114+
@click.version_option(version=__version__, prog_name="wu")
115115
def cli():
116116
"""
117117
Wu - Epistemic Media Forensics Toolkit

0 commit comments

Comments
 (0)