mirror of
https://github.com/meshtastic/protobufs.git
synced 2026-04-20 22:13:55 +00:00
Merge pull request #790 from danditomaso/ci/jsr-publish-pipeline
ci: fix publish github action workflow for publishing to JSR, Cargo, …
This commit is contained in:
commit
cd5c83a728
12 changed files with 350 additions and 27 deletions
124
.github/workflows/publish.yml
vendored
124
.github/workflows/publish.yml
vendored
|
|
@ -1,30 +1,132 @@
|
|||
name: Push new version to schema registry
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
name: Publish to Cargo, JSR, & NPM
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "**"
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "Version to publish (e.g. v1.2.3). Used when manually dispatching."
|
||||
required: false
|
||||
type: string
|
||||
|
||||
permissions: write-all
|
||||
|
||||
jobs:
|
||||
push_to_registry:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
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
|
||||
ls -la packages/rust || true
|
||||
cat packages/ts/deno.json
|
||||
cat packages/ts/package.json
|
||||
cat packages/rust/Cargo.toml
|
||||
|
||||
- name: Determine VERSION
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ "${{ github.ref_type }}" = "tag" ]; then
|
||||
VERSION="${{ github.ref_name }}"
|
||||
elif [ -n "${{ inputs.version || '' }}" ]; then
|
||||
VERSION="${{ inputs.version }}"
|
||||
else
|
||||
echo "No tag ref and no 'version' input. Provide a tag (push a tag) or pass inputs.version." >&2
|
||||
exit 1
|
||||
fi
|
||||
# If you don't want the leading 'v' inside files, strip it:
|
||||
STRIPPED="${VERSION#v}"
|
||||
echo "VERSION=$STRIPPED" >> "$GITHUB_ENV"
|
||||
echo "Resolved VERSION=$STRIPPED"
|
||||
|
||||
- name: Set Package Versions to current tag
|
||||
run: |
|
||||
set -euxo pipefail
|
||||
for f in \
|
||||
packages/ts/deno.json \
|
||||
packages/ts/package.json \
|
||||
packages/rust/Cargo.toml
|
||||
do
|
||||
test -f "$f" || { echo "Missing $f" >&2; exit 1; }
|
||||
# replace __PACKAGE_VERSION__ with env VERSION
|
||||
sed -i "s/__PACKAGE_VERSION__/${VERSION//\//-}/g" "$f"
|
||||
done
|
||||
|
||||
- name: Setup Buf
|
||||
uses: bufbuild/buf-action@v1.2.0
|
||||
uses: bufbuild/buf-setup-action@main
|
||||
with:
|
||||
github_token: ${{ github.token }}
|
||||
token: ${{ secrets.BUF_TOKEN }}
|
||||
setup_only: true
|
||||
|
||||
- name: Generate code
|
||||
run: buf generate
|
||||
|
||||
- name: Copy license & README
|
||||
run: |
|
||||
cp LICENSE packages/ts
|
||||
cp LICENSE packages/rust
|
||||
cp README.md packages/ts
|
||||
cp README.md packages/rust
|
||||
|
||||
- name: Upload Rust code
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: rust_code
|
||||
path: packages/rust
|
||||
|
||||
- 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
|
||||
steps:
|
||||
- name: Download TypeScript code
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ts_code
|
||||
- name: Remove package.json (JSR doesn’t need it)
|
||||
run: rm -f package.json
|
||||
- name: Set up Deno
|
||||
uses: denoland/setup-deno@main
|
||||
with:
|
||||
deno-version: rc
|
||||
- name: Publish to JSR
|
||||
run: deno publish --unstable-sloppy-imports
|
||||
|
||||
publish-cargo:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: codegen
|
||||
steps:
|
||||
- name: Download Rust code
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: rust_code
|
||||
- name: Set up Rust
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
- name: Check Library
|
||||
run: cargo check
|
||||
- name: Publish to crates.io
|
||||
uses: katyo/publish-crates@v2
|
||||
with:
|
||||
registry-token: ${{ secrets.CARGO_TOKEN }}
|
||||
ignore-unpublished-changes: true
|
||||
10
buf.gen.yaml
Normal file
10
buf.gen.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
version: v2
|
||||
plugins:
|
||||
- remote: buf.build/bufbuild/es:v2.1.0
|
||||
out: packages/ts/lib
|
||||
opt: target=ts
|
||||
- remote: buf.build/community/neoeinstein-prost:v0.4.0
|
||||
out: packages/rust/src/generated
|
||||
- remote: buf.build/community/neoeinstein-prost-crate:v0.4.1
|
||||
out: packages/rust/src/generated
|
||||
opt: no_features
|
||||
35
buf.yaml
35
buf.yaml
|
|
@ -1,16 +1,19 @@
|
|||
version: v1
|
||||
name: buf.build/meshtastic/protobufs
|
||||
deps: []
|
||||
build:
|
||||
excludes: []
|
||||
breaking:
|
||||
use:
|
||||
- FILE
|
||||
ignore:
|
||||
- FILE_OPTION_CHANGED
|
||||
lint:
|
||||
ignore_only:
|
||||
PACKAGE_DEFINED:
|
||||
- nanopb.proto
|
||||
use:
|
||||
- MINIMAL
|
||||
version: v2
|
||||
modules:
|
||||
- path: meshtastic
|
||||
name: buf.build/meshtastic/protobufs
|
||||
excludes:
|
||||
- meshtastic/device_only/
|
||||
lint:
|
||||
use:
|
||||
- MINIMAL
|
||||
except:
|
||||
- PACKAGE_NO_IMPORT_CYCLE
|
||||
disallow_comment_ignores: true
|
||||
breaking:
|
||||
use:
|
||||
- FILE
|
||||
except:
|
||||
- EXTENSION_NO_DELETE
|
||||
- FIELD_SAME_DEFAULT
|
||||
|
||||
|
|
|
|||
105
packages/rust/Cargo.lock
generated
Normal file
105
packages/rust/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "meshtastic_protobufs"
|
||||
version = "2.5.5"
|
||||
dependencies = [
|
||||
"prost",
|
||||
"prost-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"prost-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-derive"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-types"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670"
|
||||
dependencies = [
|
||||
"prost",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||
15
packages/rust/Cargo.toml
Normal file
15
packages/rust/Cargo.toml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[package]
|
||||
name = "meshtastic_protobufs"
|
||||
edition = "2021"
|
||||
version = "__PACKAGE_VERSION__"
|
||||
description = "Meshtastic Protobuf definitions"
|
||||
repository = "https://github.com/meshtastic/protobufs"
|
||||
license-file = "LICENSE"
|
||||
include = [
|
||||
"**/*.rs",
|
||||
"Cargo.toml",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
prost = "0.13.3"
|
||||
prost-types = "0.13.3"
|
||||
0
packages/rust/src/generated/.gitkeep
Normal file
0
packages/rust/src/generated/.gitkeep
Normal file
5
packages/rust/src/lib.rs
Normal file
5
packages/rust/src/lib.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
extern crate prost;
|
||||
extern crate core;
|
||||
extern crate prost_types;
|
||||
|
||||
include!("generated/mod.rs");
|
||||
15
packages/ts/deno.json
Normal file
15
packages/ts/deno.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "@meshtastic/protobufs",
|
||||
"version": "__PACKAGE_VERSION__",
|
||||
"exports": {
|
||||
".": "./mod.ts"
|
||||
},
|
||||
"imports": {
|
||||
"@bufbuild/protobuf": "npm:@bufbuild/protobuf@^2.2.3"
|
||||
},
|
||||
"publish": {
|
||||
"exclude": [
|
||||
"!lib"
|
||||
]
|
||||
}
|
||||
}
|
||||
16
packages/ts/deno.lock
generated
Normal file
16
packages/ts/deno.lock
generated
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"npm:@bufbuild/protobuf@^2.2.3": "2.2.3"
|
||||
},
|
||||
"npm": {
|
||||
"@bufbuild/protobuf@2.2.3": {
|
||||
"integrity": "sha512-tFQoXHJdkEOSwj5tRIZSPNUuXK3RaR7T1nUrPgbYX1pUbvqqaaZAsfo+NXBPsz5rZMSKVFrgK1WL8Q/MSLvprg=="
|
||||
}
|
||||
},
|
||||
"workspace": {
|
||||
"dependencies": [
|
||||
"npm:@bufbuild/protobuf@^2.2.3"
|
||||
]
|
||||
}
|
||||
}
|
||||
0
packages/ts/lib/.gitkeep
Normal file
0
packages/ts/lib/.gitkeep
Normal file
20
packages/ts/mod.ts
Normal file
20
packages/ts/mod.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
export * as Admin from "./lib/admin_pb.ts";
|
||||
export * as AppOnly from "./lib/apponly_pb.ts";
|
||||
export * as ATAK from "./lib/atak_pb.ts";
|
||||
export * as CannedMessages from "./lib/cannedmessages_pb.ts";
|
||||
export * as Channel from "./lib/channel_pb.ts";
|
||||
export * as ClientOnly from "./lib/clientonly_pb.ts";
|
||||
export * as Config from "./lib/config_pb.ts";
|
||||
export * as ConnectionStatus from "./lib/connection_status_pb.ts";
|
||||
export * as LocalOnly from "./lib/localonly_pb.ts";
|
||||
export * as Mesh from "./lib/mesh_pb.ts";
|
||||
export * as ModuleConfig from "./lib/module_config_pb.ts";
|
||||
export * as Mqtt from "./lib/mqtt_pb.ts";
|
||||
export * as PaxCount from "./lib/paxcount_pb.ts";
|
||||
export * as Portnums from "./lib/portnums_pb.ts";
|
||||
export * as PowerMon from "./lib/powermon_pb.ts";
|
||||
export * as RemoteHardware from "./lib/remote_hardware_pb.ts";
|
||||
export * as Rtttl from "./lib/rtttl_pb.ts";
|
||||
export * as StoreForward from "./lib/storeforward_pb.ts";
|
||||
export * as Telemetry from "./lib/telemetry_pb.ts";
|
||||
export * as Xmodem from "./lib/xmodem_pb.ts";
|
||||
32
packages/ts/package.json
Executable file
32
packages/ts/package.json
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "@meshtastic/protobufs",
|
||||
"description": "Protobuf definitions for the Meshtastic project",
|
||||
"version": "__PACKAGE_VERSION__",
|
||||
"homepage": "https://github.com/meshtastic/protobufs",
|
||||
"license": "GPLV3",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "./dist/mod.js",
|
||||
"module": "./dist/mod.js",
|
||||
"types": "./dist/mod.d.ts",
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsdown": "^0.13.4",
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsdown"
|
||||
},
|
||||
"tsdown": {
|
||||
"entry": "mod.ts",
|
||||
"dts": true,
|
||||
"format": [
|
||||
"esm"
|
||||
],
|
||||
"splitting": false
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue