Files
web/.github/workflows/release-protobufs.yml
dependabot[bot] 77cc20635b chore(deps): bump actions/checkout from 6 to 7 (#1169)
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-19 22:57:52 -04:00

142 lines
3.7 KiB
YAML

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
env:
PROTOBUF_DIR: ./packages/protobufs
jobs:
codegen:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v7
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
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: Setup pnpm
uses: pnpm/action-setup@v6
- name: Install workspace dependencies
run: pnpm install --frozen-lockfile
- name: Generate code
run: pnpm --filter @meshtastic/protobufs-ws 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
# 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 $PROTOBUF_DIR/packages/ts
cp README.md $PROTOBUF_DIR/packages/ts
- name: Upload TypeScript code
uses: actions/upload-artifact@v7
with:
name: ts_code
path: ${{ env.PROTOBUF_DIR }}/packages/ts
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@v8
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