Skip to content

Commit 73e738b

Browse files
committed
fix packaging
1 parent a3dbbf7 commit 73e738b

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

.github/workflows/release.yml

+12-10
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ on:
88
jobs:
99
goreleaser:
1010
runs-on: ubuntu-latest
11+
environment:
12+
name: release
1113
permissions:
1214
contents: write
1315
steps:
1416
- uses: actions/checkout@v4
1517
with:
1618
persist-credentials: false
1719
fetch-depth: 0
18-
- name: Set up Go
19-
uses: actions/setup-go@v5
20+
- uses: actions/setup-go@v5
2021
with:
2122
go-version: stable
2223
cache: false
23-
- name: Run GoReleaser
24-
uses: goreleaser/goreleaser-action@v6
24+
- uses: goreleaser/goreleaser-action@v6
2525
with:
2626
distribution: goreleaser
2727
version: "~> v2"
@@ -30,6 +30,8 @@ jobs:
3030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3131
pypi:
3232
runs-on: ubuntu-latest
33+
environment:
34+
name: release
3335
steps:
3436
- uses: actions/checkout@v4
3537
with:
@@ -39,9 +41,9 @@ jobs:
3941
with:
4042
go-version: stable
4143
cache: false
42-
- name: Install the latest version of uv
43-
uses: astral-sh/setup-uv@v5
44-
- name: Build
45-
run: uv build --wheel
46-
- name: Upload
47-
run: uv publish
44+
- 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 }}

pyproject.toml

+14
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,18 @@
22
requires = ["setuptools>=64", "setuptools_scm>=8"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "work-bin"
7+
description = "A stupid simple time tracker"
8+
license = {file = "LICENSE"}
9+
readme = "README.md"
10+
requires-python = ">=3.6"
11+
classifiers = [
12+
"Programming Language :: Go",
13+
"License :: OSI Approved :: MIT License",
14+
"Operating System :: OS Independent",
15+
]
16+
dynamic = ["version"]
17+
518
[tool.setuptools_scm]
19+

setup.py

+8-18
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,33 @@
77
from setuptools.command.build import build
88
from setuptools.command.install import install
99

10+
PACKAGE_NAME = "work"
11+
1012
class BuildGoBinary(build):
1113
def run(self):
12-
if not os.path.exists("work"):
14+
if not os.path.exists(PACKAGE_NAME):
1315
print("Building Go binary...")
14-
tag = os.environ["GITHUB_REF_NAME"]
15-
commit = os.environ["GITHUB_SHA"]
16+
tag = os.getenv("GITHUB_REF_NAME", "dev")
17+
commit = os.getenv("GITHUB_SHA", "none")
1618
subprocess.check_call(
17-
["go", "build", f"-ldflags=-X main.version={tag} -X main.commit={commit} -s -w", "-o", "work", "main.go"],
19+
["go", "build", f"-ldflags=-X main.version={tag} -X main.commit={commit} -s -w", "-o", PACKAGE_NAME, "main.go"],
1820
env={"GOOS": "linux", "GOARCH": "amd64", **os.environ},
1921
)
2022
build.run(self)
2123

2224
class PostInstallCommand(install):
2325
def run(self):
24-
binary_source = os.path.join(os.path.dirname(__file__), "work")
25-
binary_dest = os.path.join(self.install_scripts, "work")
26+
binary_source = os.path.join(os.path.dirname(__file__), PACKAGE_NAME)
27+
binary_dest = os.path.join(self.install_scripts, PACKAGE_NAME)
2628

2729
os.makedirs(self.install_scripts, exist_ok=True)
2830
shutil.move(binary_source, binary_dest)
2931

3032
install.run(self)
3133

3234
setup(
33-
name="work-bin",
34-
packages=[],
35-
include_package_data=True,
3635
cmdclass={
3736
"build": BuildGoBinary,
3837
"install": PostInstallCommand,
3938
},
40-
description="A stupid simple time tracker",
41-
long_description=open("README.md").read(),
42-
long_description_content_type="text/markdown",
43-
classifiers=[
44-
"Programming Language :: Go",
45-
"License :: OSI Approved :: MIT License",
46-
"Operating System :: OS Independent",
47-
],
48-
python_requires=">=3.6",
4939
)

0 commit comments

Comments
 (0)