You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

98 lines
2.7 KiB

name: Release Protobuf to 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
env:
PROTOBUF_DIR: ./packages/protobufs # 👈 single source of truth
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 $PROTOBUF_DIR/packages/ts || true
cat $PROTOBUF_DIR/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: ${{ env.PROTOBUF_DIR }}/packages/ts
run: |
set -euxo pipefail
for f in deno.json; do
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="$PROTOBUF_DIR/packages/ts/dist/meshtastic"
DEST_DIR="$PROTOBUF_DIR/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
if [ -f "$DEST_DIR/nanopb_pb.ts" ]; then
rm "$DEST_DIR/nanopb_pb.ts"
fi
- name: Copy license & README
run: |
cp LICENSE $PROTOBUF_DIR/packages/ts
cp README.md $PROTOBUF_DIR/packages/ts