Skip to content

Commit 6f82a50

Browse files
committed
ci: use calver for version
1 parent be5a666 commit 6f82a50

2 files changed

Lines changed: 15 additions & 23 deletions

File tree

.github/workflows/publish-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
pip install -e .
4242
4343
- name: Build Python package
44-
run: proton-build --hash ${{ github.sha }}
44+
run: proton-build
4545

4646
- name: Build wheel
4747
run: proton-publish

python/scripts/build.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,15 @@ def publish():
2828

2929
# Check if build package is installed
3030
check_build = subprocess.run(
31-
[sys.executable, "-m", "build", "--version"],
32-
capture_output=True
31+
[sys.executable, "-m", "build", "--version"], capture_output=True
3332
)
3433
if check_build.returncode != 0:
3534
print("Error: 'build' package not installed. Install it with:")
3635
print(" pip install build")
3736
sys.exit(1)
3837

3938
print("Building wheel...")
40-
result = subprocess.run(
41-
[sys.executable, "-m", "build", "--wheel"],
42-
cwd=DIST_DIR
43-
)
39+
result = subprocess.run([sys.executable, "-m", "build", "--wheel"], cwd=DIST_DIR)
4440

4541
if result.returncode != 0:
4642
print("Wheel build failed!", file=sys.stderr)
@@ -50,7 +46,7 @@ def publish():
5046
print(f"Output: {DIST_DIR}/dist/")
5147

5248

53-
def build(version_hash=None):
49+
def build():
5450
"""Generate Python code from proto files."""
5551
clean()
5652

@@ -87,12 +83,13 @@ def build(version_hash=None):
8783
print("Copying pyproject.toml to dist...")
8884
content = template_file.read_text()
8985

90-
# Update version if hash is provided
91-
if version_hash:
92-
version_str = f"0.1.0+{version_hash}"
93-
content = content.replace('version = "0.1.0"', f'version = "{version_str}"')
94-
print(f"Set version to: {version_str}")
86+
# Generate CalVer format: YYYY.MM.DD.HHMMSS
87+
from datetime import datetime
9588

89+
now = datetime.utcnow()
90+
version_str = now.strftime("%Y.%m.%d.%H%M%S")
91+
content = content.replace('version = "0.1.0"', f'version = "{version_str}"')
92+
print(f"Set version to: {version_str}")
9693
(DIST_DIR / "pyproject.toml").write_text(content)
9794

9895
# Copy README to dist
@@ -112,28 +109,23 @@ def build(version_hash=None):
112109

113110
def build_cli():
114111
"""CLI entry point for build command."""
115-
import argparse
116-
117-
parser = argparse.ArgumentParser(description="Build Python protobuf package")
118-
parser.add_argument("--hash", help="Version hash to append (e.g., git commit hash)")
119-
120-
args = parser.parse_args()
121-
build(version_hash=args.hash)
112+
build()
122113

123114

124115
def main():
125116
import argparse
126117

127118
parser = argparse.ArgumentParser(description="Build Python protobuf package")
128-
parser.add_argument("command", choices=["clean", "build", "publish"], help="Command to run")
129-
parser.add_argument("--hash", help="Version hash to append (e.g., git commit hash)")
119+
parser.add_argument(
120+
"command", choices=["clean", "build", "publish"], help="Command to run"
121+
)
130122

131123
args = parser.parse_args()
132124

133125
if args.command == "clean":
134126
clean()
135127
elif args.command == "build":
136-
build(version_hash=args.hash)
128+
build()
137129
elif args.command == "publish":
138130
publish()
139131

0 commit comments

Comments
 (0)