Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 50 additions & 4 deletions .github/workflows/update_protobufs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
name: "Update protobufs"
on: workflow_dispatch

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
Expand All @@ -14,6 +24,7 @@ jobs:
with:
fetch-depth: 0
submodules: true
persist-credentials: false

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -25,11 +36,44 @@ jobs:
python -m pip install --upgrade pip
python -m pip install poetry

- name: Update protobuf submodule
- 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
git submodule update --remote --recursive
cd protobufs
git checkout "${TARGET_VERSION}"
cd ..

- name: Download nanopb
run: |
Expand All @@ -46,14 +90,16 @@ jobs:
./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 "Update protobufs"
git commit -m "protobufs: ${TARGET_VERSION}"
git push
else
echo "No changes to commit"
Expand Down
Loading