Skip to content

Commit c4f8f4a

Browse files
committed
migrate to uv and hatchling
1 parent 73e738b commit c4f8f4a

File tree

5 files changed

+52
-47
lines changed

5 files changed

+52
-47
lines changed

.github/workflows/release.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
runs-on: ubuntu-latest
3333
environment:
3434
name: release
35+
permissions:
36+
id-token: write
3537
steps:
3638
- uses: actions/checkout@v4
3739
with:
@@ -42,8 +44,7 @@ jobs:
4244
go-version: stable
4345
cache: false
4446
- uses: astral-sh/setup-uv@v5
45-
- run: uv build --wheel
46-
- run: uvx twine upload dist/*
47-
env:
48-
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
49-
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
47+
with:
48+
enable-cache: false
49+
- run: uv build
50+
- run: uv publish

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ go.work.sum
2323

2424
# env file
2525
.env
26+
27+
# python packaging
28+
dist/
29+
*.egg-info/
30+
*.dist-info/
31+
__pycache__
32+
work

hatch_build.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
import subprocess
3+
4+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
5+
6+
7+
class GoBinaryBuildHook(BuildHookInterface):
8+
def initialize(self, version, build_data):
9+
build_data["pure_python"] = False
10+
binary_name = self.config["binary_name"]
11+
tag = os.getenv("GITHUB_REF_NAME", "dev")
12+
commit = os.getenv("GITHUB_SHA", "none")
13+
14+
if not os.path.exists(binary_name):
15+
print(f"Building Go binary '{binary_name}'...")
16+
subprocess.check_call(
17+
["go", "build", f"-ldflags=-X main.version={tag} -X main.commit={commit} -s -w", "-o", binary_name],
18+
env={"GOOS": "linux", "GOARCH": "amd64", **os.environ},
19+
)
20+
21+
build_data["shared_scripts"] = {binary_name: binary_name}
22+

pyproject.toml

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
[build-system]
2-
requires = ["setuptools>=64", "setuptools_scm>=8"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "work-bin"
77
description = "A stupid simple time tracker"
88
license = {file = "LICENSE"}
9+
authors = [{ name = "Jamison Lahman", email = "[email protected]" }]
910
readme = "README.md"
1011
requires-python = ">=3.6"
12+
keywords = [
13+
"time-tracker", "time-management", "time",
14+
]
1115
classifiers = [
1216
"Programming Language :: Go",
1317
"License :: OSI Approved :: MIT License",
1418
"Operating System :: OS Independent",
1519
]
1620
dynamic = ["version"]
1721

18-
[tool.setuptools_scm]
1922

23+
[project.urls]
24+
Repository = "https://github.com/jmelahman/work"
25+
26+
[tool.hatch.build]
27+
include = ["go.mod", "go.sum", "**/*.go"]
28+
29+
[tool.hatch.version]
30+
source = "vcs"
31+
32+
[tool.hatch.build.hooks.custom]
33+
binary_name = "work"

setup.py

-39
This file was deleted.

0 commit comments

Comments
 (0)