105 lines
2.9 KiB
YAML
105 lines
2.9 KiB
YAML
name: Proto Sync
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- "src/noteflow/grpc/proto/**"
|
|
branches:
|
|
- main
|
|
- master
|
|
- develop
|
|
|
|
env:
|
|
PYTHON_VERSION: "3.12"
|
|
RUST_TOOLCHAIN: "stable"
|
|
|
|
jobs:
|
|
regenerate-stubs:
|
|
runs-on: ubuntu-22.04
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GIT_TOKEN }}
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Install Python gRPC tools
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install grpcio-tools
|
|
|
|
- name: Regenerate Python gRPC stubs
|
|
run: |
|
|
python -m grpc_tools.protoc \
|
|
-I src/noteflow/grpc/proto \
|
|
--python_out=src/noteflow/grpc/proto \
|
|
--grpc_python_out=src/noteflow/grpc/proto \
|
|
--pyi_out=src/noteflow/grpc/proto \
|
|
src/noteflow/grpc/proto/noteflow.proto
|
|
|
|
- name: Fix Python imports (relative imports)
|
|
run: |
|
|
sed -i 's/^import noteflow_pb2/from . import noteflow_pb2/' \
|
|
src/noteflow/grpc/proto/noteflow_pb2_grpc.py
|
|
|
|
- name: Install system dependencies (Tauri/Rust)
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
libgtk-3-dev \
|
|
libwebkit2gtk-4.1-dev \
|
|
libappindicator3-dev \
|
|
librsvg2-dev \
|
|
patchelf \
|
|
libasound2-dev \
|
|
protobuf-compiler
|
|
|
|
- name: Set up Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
|
|
|
- name: Cache Cargo
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/bin/
|
|
~/.cargo/registry/index/
|
|
~/.cargo/registry/cache/
|
|
~/.cargo/git/db/
|
|
client/src-tauri/target/
|
|
key: ${{ runner.os }}-cargo-proto-${{ hashFiles('client/src-tauri/Cargo.lock') }}
|
|
restore-keys: ${{ runner.os }}-cargo-
|
|
|
|
- name: Regenerate Rust types (via cargo build)
|
|
run: |
|
|
cd client/src-tauri
|
|
cargo build --lib 2>&1 || echo "Rust build completed (proto regeneration triggered)"
|
|
|
|
- name: Check for changes
|
|
id: check_changes
|
|
run: |
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
echo "changes=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "changes=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Commit and push regenerated stubs
|
|
if: steps.check_changes.outputs.changes == 'true'
|
|
run: |
|
|
git config --global user.name "vasceannie"
|
|
git config --global user.email "vasceannie@users.noreply.gitea.local"
|
|
git add -A
|
|
git commit -m "chore: auto-regenerate gRPC stubs [skip ci]"
|
|
git push
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
|