Enable publishing to Cargo & JSR

This commit is contained in:
Sacha Weatherstone 2024-10-06 22:11:45 +10:00
parent 5df44cf804
commit 5ff4ed0248
22 changed files with 308 additions and 120 deletions

View file

@ -1,27 +0,0 @@
name: Push commit to schema registry
permissions:
contents: read
on:
push:
branches:
- master
jobs:
push_to_registry:
name: Push to schema registry
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Buf
uses: bufbuild/buf-setup-action@v1.30.0
with:
github_token: ${{ github.token }}
- name: Push to schema registry
uses: bufbuild/buf-push-action@v1.2.0
with:
buf_token: ${{ secrets.BUF_TOKEN }}

View file

@ -1,30 +1,72 @@
name: Push new version to schema registry
permissions:
contents: read
name: Publish to Cargo & JSR
on:
push:
tags:
- "**"
jobs:
push_to_registry:
runs-on: ubuntu-latest
permissions: write-all
jobs:
codegen:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set Package Versions to current tag
run: sed -i "s/__PACKAGE_VERSION__/$(echo $GITHUB_REF | cut -d '/' -f 3)/g" packages/ts/deno.json \
&& sed -i "s/__PACKAGE_VERSION__/$(echo $GITHUB_REF | cut -d '/' -f 3)/g" packages/rust/Cargo.toml
- name: Setup Buf
uses: bufbuild/buf-setup-action@v1.30.0
uses: bufbuild/buf-setup-action@main
with:
github_token: ${{ github.token }}
- name: Generate code
run: buf generate dewars
- name: Copy license
run: cp LICENSE packages/ts && cp LICENSE 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
# uses: bufbuild/buf-push-action@v1
# with:
# buf_token: ${{ secrets.BUF_TOKEN }}
run: |
export BUF_TOKEN=${{ secrets.BUF_TOKEN }}
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: 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

View file

@ -1,28 +0,0 @@
name: pull-request
permissions:
contents: read
on: pull_request
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Buf
uses: bufbuild/buf-setup-action@v1.30.0
with:
github_token: ${{ github.token }}
- name: Lint
uses: bufbuild/buf-lint-action@v1.1.1
- name: Push to schema registry
uses: bufbuild/buf-push-action@v1.2.0
if: ${{ github.event_name != 'pull_request_target' && github.event_name != 'pull_request' }}
with:
buf_token: ${{ secrets.BUF_TOKEN }}
draft: ${{ github.ref_name != 'master'}}

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
packages/ts/lib/*
packages/rust/src/generated/*
packages/rust/target
!.gitkeep

10
buf.gen.yaml Normal file
View 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

View file

@ -1,14 +1,18 @@
version: v1
name: buf.build/meshtastic/protobufs
deps: []
build:
excludes: []
breaking:
use:
- FILE
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

View file

@ -2,11 +2,11 @@ syntax = "proto3";
package meshtastic;
import "meshtastic/channel.proto";
import "meshtastic/config.proto";
import "meshtastic/connection_status.proto";
import "meshtastic/mesh.proto";
import "meshtastic/module_config.proto";
import "channel.proto";
import "config.proto";
import "connection_status.proto";
import "mesh.proto";
import "module_config.proto";
option csharp_namespace = "Meshtastic.Protobufs";
option go_package = "github.com/meshtastic/go/generated";

View file

@ -2,8 +2,8 @@ syntax = "proto3";
package meshtastic;
import "meshtastic/channel.proto";
import "meshtastic/config.proto";
import "channel.proto";
import "config.proto";
option csharp_namespace = "Meshtastic.Protobufs";
option go_package = "github.com/meshtastic/go/generated";

View file

@ -2,8 +2,8 @@ syntax = "proto3";
package meshtastic;
import "meshtastic/localonly.proto";
import "meshtastic/mesh.proto";
import "localonly.proto";
import "mesh.proto";
option csharp_namespace = "Meshtastic.Protobufs";
option go_package = "github.com/meshtastic/go/generated";

View file

@ -2,11 +2,11 @@ syntax = "proto3";
package meshtastic;
import "meshtastic/channel.proto";
import "meshtastic/localonly.proto";
import "meshtastic/mesh.proto";
import "meshtastic/telemetry.proto";
import "meshtastic/config.proto";
import "channel.proto";
import "localonly.proto";
import "mesh.proto";
import "telemetry.proto";
import "config.proto";
import "nanopb.proto";
option csharp_namespace = "Meshtastic.Protobufs";

View file

@ -2,8 +2,8 @@ syntax = "proto3";
package meshtastic;
import "meshtastic/config.proto";
import "meshtastic/module_config.proto";
import "config.proto";
import "module_config.proto";
option csharp_namespace = "Meshtastic.Protobufs";
option go_package = "github.com/meshtastic/go/generated";

View file

@ -2,12 +2,12 @@ syntax = "proto3";
package meshtastic;
import "meshtastic/channel.proto";
import "meshtastic/config.proto";
import "meshtastic/module_config.proto";
import "meshtastic/portnums.proto";
import "meshtastic/telemetry.proto";
import "meshtastic/xmodem.proto";
import "channel.proto";
import "config.proto";
import "module_config.proto";
import "portnums.proto";
import "telemetry.proto";
import "xmodem.proto";
option csharp_namespace = "Meshtastic.Protobufs";
option go_package = "github.com/meshtastic/go/generated";
@ -338,7 +338,7 @@ enum HardwareModel {
* Heltec HRU-3601: https://heltec.org/project/hru-3601/
*/
HELTEC_HRU_3601 = 23;
/*
* Heltec Wireless Bridge
*/
@ -541,7 +541,7 @@ enum HardwareModel {
CDEBYTE_EORA_S3 = 61;
/*
* TWC_MESH_V4
* TWC_MESH_V4
* Adafruit NRF52840 feather express with SX1262, SSD1306 OLED and NEO6M GPS
*/
TWC_MESH_V4 = 62;
@ -557,27 +557,27 @@ enum HardwareModel {
* ESP32-D0WDQ6 With SX1276/SKY66122, SSD1306 OLED and No GPS
*/
RADIOMASTER_900_BANDIT_NANO = 64;
/*
* Heltec Capsule Sensor V3 with ESP32-S3 CPU, Portable LoRa device that can replace GNSS modules or sensors
*/
HELTEC_CAPSULE_SENSOR_V3 = 65;
/*
* Heltec Vision Master T190 with ESP32-S3 CPU, and a 1.90 inch TFT display
*/
HELTEC_VISION_MASTER_T190 = 66;
/*
* Heltec Vision Master E213 with ESP32-S3 CPU, and a 2.13 inch E-Ink display
*/
HELTEC_VISION_MASTER_E213 = 67;
/*
* Heltec Vision Master E290 with ESP32-S3 CPU, and a 2.9 inch E-Ink display
*/
HELTEC_VISION_MASTER_E290 = 68;
/*
* Heltec Mesh Node T114 board with nRF52840 CPU, and a 1.14 inch TFT display, Ultimate low-power design,
* specifically adapted for the Meshtatic project
@ -593,7 +593,7 @@ enum HardwareModel {
* Seeed studio T1000-E tracker card. NRF52840 w/ LR1110 radio, GPS, button, buzzer, and sensors.
*/
TRACKER_T1000_E = 71;
/*
* RAK3172 STM32WLE5 Module (https://store.rakwireless.com/products/wisduo-lpwan-module-rak3172)
*/
@ -625,7 +625,7 @@ enum HardwareModel {
*
*/
RP2040_FEATHER_RFM95 = 76;
/* M5 esp32 based MCU modules with enclosure, TFT and LORA Shields. All Variants (Basic, Core, Fire, Core2, CoreS3, Paper) https://m5stack.com/ */
M5STACK_COREBASIC = 77;
M5STACK_CORE2 = 78;
@ -635,7 +635,7 @@ enum HardwareModel {
/* M5 esp32 based MCU modules with enclosure, TFT and LORA Shields. All Variants (Basic, Core, Fire, Core2, CoreS3, Paper) https://m5stack.com/ */
M5STACK_CORES3 = 80;
/* Seeed XIAO S3 DK*/
SEEED_XIAO_S3 = 81;
@ -1069,7 +1069,7 @@ message MeshPacket {
/*
* Higher priority for specific message types (portnums) to distinguish between other reliable packets.
*/
*/
HIGH = 100;
/*

View file

@ -2,8 +2,8 @@ syntax = "proto3";
package meshtastic;
import "meshtastic/config.proto";
import "meshtastic/mesh.proto";
import "config.proto";
import "mesh.proto";
option csharp_namespace = "Meshtastic.Protobufs";
option go_package = "github.com/meshtastic/go/generated";

105
packages/rust/Cargo.lock generated Normal file
View 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
View 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"

View file

5
packages/rust/src/lib.rs Normal file
View 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
View file

@ -0,0 +1,15 @@
{
"name": "@meshtastic/protobufs",
"version": "__PACKAGE_VERSION__",
"exports": {
".": "./mod.ts"
},
"imports": {
"@bufbuild/protobuf": "npm:@bufbuild/protobuf@^2.1.0"
},
"publish": {
"exclude": [
"!lib"
]
}
}

0
packages/ts/lib/.gitkeep Normal file
View file

43
packages/ts/mod.ts Normal file
View file

@ -0,0 +1,43 @@
import * as Admin from "./lib/admin_pb.ts";
import * as AppOnly from "./lib/apponly_pb.ts";
import * as ATAK from "./lib/atak_pb.ts";
import * as CannedMessages from "./lib/cannedmessages_pb.ts";
import * as Channel from "./lib/channel_pb.ts";
import * as ClientOnly from "./lib/clientonly_pb.ts";
import * as Config from "./lib/config_pb.ts";
import * as ConnectionStatus from "./lib/connection_status_pb.ts";
import * as LocalOnly from "./lib/localonly_pb.ts";
import * as Mesh from "./lib/mesh_pb.ts";
import * as ModuleConfig from "./lib/module_config_pb.ts";
import * as Mqtt from "./lib/mqtt_pb.ts";
import * as PaxCount from "./lib/paxcount_pb.ts";
import * as Portnums from "./lib/portnums_pb.ts";
import * as PowerMon from "./lib/powermon_pb.ts";
import * as RemoteHardware from "./lib/remote_hardware_pb.ts";
import * as Rtttl from "./lib/rtttl_pb.ts";
import * as StoreForward from "./lib/storeforward_pb.ts";
import * as Telemetry from "./lib/telemetry_pb.ts";
import * as Xmodem from "./lib/xmodem_pb.ts";
export const Protobuf = {
Admin,
AppOnly,
ATAK,
CannedMessages,
Channel,
ClientOnly,
Config,
ConnectionStatus,
LocalOnly,
Mesh,
ModuleConfig,
Mqtt,
PaxCount,
Portnums,
PowerMon,
RemoteHardware,
Rtttl,
StoreForward,
Telemetry,
Xmodem,
};