Add protobufs repo as git submodule (#882)
* feat: add protobufs git submodule * fixes * fixed publishing issue * fixed lockfile
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
name: Create Protobuf Release for JSR
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "Version to publish (e.g. v1.2.3). Used when manually dispatching."
|
||||
required: true
|
||||
type: string
|
||||
dry_run:
|
||||
description: "Don't actually publish to JSR (passes --dry-run)."
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions: write-all
|
||||
|
||||
jobs:
|
||||
codegen:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Show files exist
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
ls -la packages/ts || true
|
||||
cat packages/ts/deno.json
|
||||
|
||||
- name: Determine VERSION
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -n "${{ inputs.version }}" ]; then
|
||||
VERSION="${{ inputs.version }}"
|
||||
else
|
||||
echo "No 'version' input. Provide inputs.version." >&2
|
||||
exit 1
|
||||
fi
|
||||
STRIPPED="${VERSION#v}"
|
||||
echo "VERSION=$STRIPPED" >> "$GITHUB_ENV"
|
||||
echo "Resolved VERSION=$STRIPPED"
|
||||
|
||||
- name: Set Package Versions to current tag
|
||||
working-directory: packages/ts
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
for f in deno.json; do
|
||||
test -f "$f"
|
||||
jq --arg version "${VERSION//\//-}" '
|
||||
walk(
|
||||
if type == "string" and test("__PACKAGE_VERSION__")
|
||||
then sub("__PACKAGE_VERSION__"; $version)
|
||||
else .
|
||||
end
|
||||
)
|
||||
' "$f" > "$f.tmp"
|
||||
mv "$f.tmp" "$f"
|
||||
done
|
||||
|
||||
- name: Setup Buf
|
||||
uses: bufbuild/buf-setup-action@main
|
||||
with:
|
||||
github_token: ${{ github.token }}
|
||||
|
||||
- name: Generate code
|
||||
run: pnpm --filter @meshtastic/protobufs build
|
||||
|
||||
|
||||
- name: Move generated .ts files and clean up
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
SRC_DIR="packages/protobufs/packages/ts/dist/meshtastic"
|
||||
DEST_DIR="packages/protobufs/packages/ts/dist"
|
||||
|
||||
if [ -d "$SRC_DIR" ]; then
|
||||
shopt -s nullglob
|
||||
ts_files=("$SRC_DIR"/*.ts)
|
||||
if [ ${#ts_files[@]} -gt 0 ]; then
|
||||
mv "$SRC_DIR"/*.ts "$DEST_DIR"/
|
||||
fi
|
||||
rm -rf "$SRC_DIR"
|
||||
else
|
||||
echo "Source directory not found: $SRC_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remove nanopb_pb.ts if present
|
||||
if [ -f "$DEST_DIR/nanopb_pb.ts" ]; then
|
||||
rm "$DEST_DIR/nanopb_pb.ts"
|
||||
fi
|
||||
|
||||
- name: Copy license & README
|
||||
run: |
|
||||
cp LICENSE packages/ts
|
||||
cp README.md packages/ts
|
||||
|
||||
- name: Upload TypeScript code
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ts_code
|
||||
path: packages/ts
|
||||
|
||||
- name: Push to schema registry
|
||||
env:
|
||||
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
|
||||
run: buf push --tag ${{ github.ref_name }}
|
||||
|
||||
publish-jsr:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: codegen
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env:
|
||||
DRY_RUN: ${{ inputs.dry_run }}
|
||||
steps:
|
||||
- name: Download TypeScript code
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ts_code
|
||||
|
||||
- name: Set up Deno
|
||||
uses: denoland/setup-deno@main
|
||||
with:
|
||||
deno-version: rc
|
||||
|
||||
- name: Publish to JSR
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
FLAGS="--unstable-sloppy-imports"
|
||||
if [ "${DRY_RUN}" = "true" ]; then
|
||||
FLAGS="$FLAGS --dry-run"
|
||||
echo "Running publish in dry-run mode..."
|
||||
fi
|
||||
deno publish $FLAGS
|
||||
Reference in New Issue
Block a user