Skip to content

Update protobufs

Update protobufs #31

name: "Update protobufs"
on:
workflow_dispatch:
inputs:
version:
description: "Protobufs version tag to sync to (e.g., v2.7.26). Defaults to the latest protobufs release."
required: false
default: ""
type: string
repository_dispatch:
types: [protobufs-release]
permissions:
contents: write
jobs:
update-protobufs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry
- name: Determine target protobufs version
id: version
env:
INPUT_VERSION: ${{ github.event.inputs.version }}
PAYLOAD_VERSION: ${{ github.event.client_payload.version }}
run: |
cd protobufs
git fetch --tags
if [ -n "${INPUT_VERSION}" ]; then
target="${INPUT_VERSION}"
elif [ -n "${PAYLOAD_VERSION}" ]; then
target="${PAYLOAD_VERSION}"
else
target=$(git tag --list 'v*' --sort=-version:refname | head -n1)
if [ -z "${target}" ]; then
echo "Error: no release tags found in meshtastic/protobufs"
exit 1
fi
fi
if ! git show-ref --verify --quiet "refs/tags/${target}"; then
echo "Error: '${target}' is not a valid tag in meshtastic/protobufs"
exit 1
fi
printf 'version=%s\n' "${target}" >> "$GITHUB_OUTPUT"
echo "Target protobufs version: ${target}"
- name: Update protobuf submodule to release
env:
TARGET_VERSION: ${{ steps.version.outputs.version }}
run: |
git submodule sync --recursive
git submodule update --init --recursive
cd protobufs
git checkout "${TARGET_VERSION}"
cd ..
- name: Download nanopb
run: |
curl -L -o nanopb-0.4.8-linux-x86.tar.gz https://jpa.kapsi.fi/nanopb/download/nanopb-0.4.8-linux-x86.tar.gz
tar xvzf nanopb-0.4.8-linux-x86.tar.gz
mv nanopb-0.4.8-linux-x86 nanopb-0.4.8
- name: Install Python dependencies
run: |
poetry install --with dev
- name: Re-generate protocol buffers
run: |
./bin/regen-protobufs.sh
- name: Commit update
env:
TARGET_VERSION: ${{ steps.version.outputs.version }}
run: |
git config --global user.name 'github-actions'
git config --global user.email 'bot@noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add protobufs
git add meshtastic/protobuf
if [[ -n "$(git status --porcelain)" ]]; then
git commit -m "protobufs: ${TARGET_VERSION}"
git push
else
echo "No changes to commit"
fi