Skip to content

Commit 579fd3f

Browse files
committed
WIP: buf build
1 parent bf48a48 commit 579fd3f

File tree

5 files changed

+94
-121
lines changed

5 files changed

+94
-121
lines changed

.github/workflows/build-golang-macos.yaml

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
name: Ubuntu build - buf edition
3+
on: [push]
4+
jobs:
5+
6+
build:
7+
runs-on: ubuntu-22.04
8+
permissions:
9+
contents: write
10+
11+
strategy:
12+
fail-fast: true
13+
matrix:
14+
go-version: [1.24.x]
15+
python3_version: [ "3.11", "3.12" ]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: ${{ matrix.go-version }}
24+
cache-dependency-path: go.sum
25+
26+
# - name: Set up Python
27+
# uses: actions/setup-python@v4
28+
# with:
29+
# python-version: ${{ matrix.python3_version }}
30+
31+
- name: Install the latest version of uv
32+
uses: astral-sh/setup-uv@v6
33+
with:
34+
version: "latest"
35+
python-version: ${{ matrix.python3_version }}
36+
37+
# Download a release like https://github.com/bufbuild/buf/releases/download/v1.53.0/buf-Linux-x86_64
38+
- name: Install buf
39+
run: |
40+
BUF_VERSION="1.53.0"
41+
BUF_URL="https://github.com/bufbuild/buf/releases/download/v1.53.0/buf-Linux-x86_64"
42+
curl -sSL "$BUF_URL" -o /usr/local/bin/buf
43+
chmod +x /usr/local/bin/buf
44+
45+
- name: Add buf to PATH
46+
run: echo "/usr/local/bin" >> $GITHUB_PATH
47+
48+
- name: Check buf version
49+
run: buf --version
50+
51+
- name: Build using 'uv_buf_build_script.sh'
52+
run: |
53+
cd build-scripts/
54+
chmod +x ./uv_buf_build_script.sh
55+
./uv_buf_build_script.sh

.github/workflows/build-golang-ubuntu.yaml

Lines changed: 0 additions & 65 deletions
This file was deleted.

build-scripts/setup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from setuptools import setup, find_packages
2+
3+
setup(
4+
name="otdf_python",
5+
version="0.2.11",
6+
author="b-long",
7+
author_email="[email protected]",
8+
description="Buf generated SDK for OpenTDF",
9+
packages=find_packages("gen"),
10+
package_dir={"": "gen"},
11+
)

build-scripts/uv_buf_build_script.sh

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
# Based on the excellent work of the sift-stack team:
4+
# https://github.com/sift-stack/sift/blob/main/docs/python.md
35
set -x
46
set -eou pipefail
57

@@ -43,12 +45,29 @@ if ! command -v go &> /dev/null; then
4345
fi
4446

4547

48+
# Shallow clone the 'https://github.com/opentdf/platform.git' repo
49+
git clone --depth 1 https://github.com/opentdf/platform.git
50+
51+
cd platform || { echo "Unable to change to platform directory" ; exit 1; }
52+
buf export --output=$BUILD_ROOT/protos --config buf.yaml
53+
54+
cd $SCRIPT_DIR || { echo "Unable to change to script directory" ; exit 1; }
55+
cp buf.gen.python.yaml $BUILD_ROOT/buf.gen.yaml
56+
cp setup.py $BUILD_ROOT/setup.py
57+
58+
cd "${BUILD_ROOT}" || { echo "Unable to change to build root directory" ; exit 1; }
59+
buf generate protos || { echo "buf generate failed" ; exit 1; }
60+
61+
for dir in $(find gen -type d); do
62+
touch $dir/__init__.py
63+
done
64+
4665
# PY_TYPE="--python-preference=only-system"
4766
PY_TYPE="--python-preference=only-managed"
4867

4968
loud_print "Creating virtual environment"
5069
# Install python deps
51-
uv venv .venv --python 3.12 "$PY_TYPE"
70+
uv venv .venv "$PY_TYPE"
5271

5372
if ! [ -d "${BUILD_ROOT}/.venv" ]; then
5473
echo "Unable to locate virtual environment directory"
@@ -58,9 +77,12 @@ fi
5877
loud_print "Activating virtual environment"
5978
source "${BUILD_ROOT}/.venv/bin/activate"
6079

80+
uv pip install build protobuf grpcio
81+
python -m build --sdist || { echo "Failed to build source distribution" ; exit 1; }
82+
python -m build --wheel || { echo "Failed to build wheel distribution" ; exit 1; }
6183

62-
# Shallow clone the 'https://github.com/opentdf/platform.git' repo
63-
git clone --depth 1 https://github.com/opentdf/platform.git
64-
65-
cd platform || { echo "Unable to change to platform directory" ; exit 1; }
66-
buf export --output=$BUILD_ROOT/protos --config buf.yaml
84+
echo "Build completed successfully."
85+
echo "Directory contents:"
86+
ls -lart
87+
echo "Dist directory contents:"
88+
ls -lart dist/

0 commit comments

Comments
 (0)