Skip to content

Commit 83a7e25

Browse files
committed
Build custom build action yaml and improve packaging script.
1 parent b479de7 commit 83a7e25

File tree

10 files changed

+32
-19
lines changed

10 files changed

+32
-19
lines changed
Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
8-
91
name: Upload Python Package
102

113
on:
@@ -22,18 +14,20 @@ jobs:
2214

2315
steps:
2416
- uses: actions/checkout@v3
17+
- name: Set up .NET 8
18+
uses: actions/setup-dotnet@v3
19+
with:
20+
dotnet-version: '8.0.x'
2521
- name: Set up Python
2622
uses: actions/setup-python@v3
2723
with:
2824
python-version: '3.x'
2925
- name: Install dependencies
3026
run: |
3127
python -m pip install --upgrade pip
32-
pip install build
28+
pip install hatch
3329
- name: Build package
34-
run: python -m build
30+
run: hatch build
3531
- name: Publish package
36-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37-
with:
38-
user: __token__
39-
password: ${{ secrets.PYPI_API_TOKEN }}
32+
run: |
33+
hatch publish -u "__token__" -a ${{ secrets.PYPI_API_TOKEN }}

build_differ.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def main():
4444
version = get_version()
4545
print(f"Version: {version}")
4646

47+
dist_dir = "./src/python_redlines/dist/"
48+
4749
# Build for Linux
4850
print("Building for Linux...")
4951
run_command('dotnet publish ./csproj -c Release -r linux-x64 --self-contained')
@@ -58,15 +60,15 @@ def main():
5860

5961
# Compress the Linux build
6062
linux_build_dir = './csproj/bin/Release/net8.0/linux-x64'
61-
compress_files(linux_build_dir, f"./dist/linux-x64-{version}.tar.gz")
63+
compress_files(linux_build_dir, f"{dist_dir}/linux-x64-{version}.tar.gz")
6264

6365
# Compress the Windows build
6466
windows_build_dir = './csproj/bin/Release/net8.0/win-x64'
65-
compress_files(windows_build_dir, f"./dist/win-x64-{version}.zip")
67+
compress_files(windows_build_dir, f"{dist_dir}/win-x64-{version}.zip")
6668

6769
# Compress the macOS build
6870
macos_build_dir = './csproj/bin/Release/net8.0/osx-x64'
69-
compress_files(macos_build_dir, f"./dist/osx-x64-{version}.tar.gz")
71+
compress_files(macos_build_dir, f"{dist_dir}/osx-x64-{version}.tar.gz")
7072

7173
print("Build and compression complete.")
7274

dist/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

dist/osx-x64-0.0.1.tar.gz

-64.7 MB
Binary file not shown.

dist/win-x64-0.0.1.zip

-67.5 MB
Binary file not shown.

hatch_run_build_hook.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import subprocess
2+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
3+
4+
class HatchRunBuildHook(BuildHookInterface):
5+
PLUGIN_NAME = 'hatch-run-build'
6+
7+
def initialize(self, version, build_data):
8+
# Run the 'hatch run build' command
9+
subprocess.run(['hatch', 'run', 'build'], check=True)

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ artifacts = [
1111
"*.tar.gz",
1212
]
1313

14+
# Build hook to build the binaries for distribution...
15+
[tool.hatch.build.hooks.custom]
16+
path = "hatch_run_build_hook.py"
17+
1418
[project]
1519
name = "python-redlines"
1620
dynamic = ["version"]

src/python_redlines/bin/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*
1+
*
2+
!.gitignore
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
!*
1+
*
2+
!.gitignore
65.4 MB
Binary file not shown.

0 commit comments

Comments
 (0)