[Protocol] Inline package assembly, fix cmake-format, add workflow_dispatch

- Replace the custom Node packaging script with a flat inline step
  (cp the .proto glob, cp the static files, npm version) so the
  workflow speaks the same shell idiom as the other workflows.
- Promote package.json and README.md to static files under
  libcockatrice_protocol/npm/ so contributors edit them in-place.
- Re-format libcockatrice_protocol/CMakeLists.txt per .cmake-format.json.
- Add workflow_dispatch (manual run; optional version input) and
  timeout-minutes: 10.
- Drop --provenance from npm publish: GitHub Packages doesn't
  attest Sigstore provenance.
This commit is contained in:
ZeldaZach 2026-05-23 13:12:21 -04:00
parent cc4a53b850
commit b870ce0a4a
No known key found for this signature in database
5 changed files with 111 additions and 138 deletions

View file

@ -11,11 +11,14 @@ if(NOT CMAKE_MATCH_1)
message(FATAL_ERROR "Failed to extract protocolVersion from ${PROTOCOL_VERSION_JSON_PATH}")
endif()
set(COCKATRICE_PROTOCOL_VERSION "${CMAKE_MATCH_1}")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${PROTOCOL_VERSION_JSON_PATH}")
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS "${PROTOCOL_VERSION_JSON_PATH}"
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/protocol_version.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/libcockatrice/protocol/protocol_version.h"
@ONLY
"${CMAKE_CURRENT_BINARY_DIR}/libcockatrice/protocol/protocol_version.h" @ONLY
)
add_subdirectory(libcockatrice/protocol/pb)

View file

@ -0,0 +1,30 @@
# @cockatrice/protocol
Network protocol artifacts for [Cockatrice](https://github.com/Cockatrice/Cockatrice): the `.proto`
definitions used by the desktop client, Servatrice, and the webclient, plus the
authoritative protocol version constant they all share.
## Install
```sh
npm install @cockatrice/protocol
```
The package is published to GitHub Packages under the `@cockatrice` scope; consumers
need an `.npmrc` entry pointing the scope at `https://npm.pkg.github.com` and a
`GITHUB_TOKEN` with `read:packages`.
## Contents
- `pb/*.proto` — every protobuf schema file from `libcockatrice_protocol`.
- `protocol_version.json``{ "protocolVersion": <int> }`. Identical to the file
the C++ build reads via `configure_file()`.
## Usage (TypeScript)
```ts
import protocolVersionInfo from "@cockatrice/protocol/protocol_version.json" with { type: "json" };
export const PROTOCOL_VERSION = protocolVersionInfo.protocolVersion;
```
Point your protobuf code-generator (e.g. buf) at `node_modules/@cockatrice/protocol/pb`.

View file

@ -0,0 +1,25 @@
{
"name": "@cockatrice/protocol",
"version": "0.0.0",
"description": "Cockatrice network protocol: .proto definitions and protocol version constant.",
"license": "GPL-2.0-or-later",
"repository": {
"type": "git",
"url": "git+https://github.com/Cockatrice/Cockatrice.git"
},
"homepage": "https://github.com/Cockatrice/Cockatrice",
"files": [
"pb/",
"protocol_version.json",
"LICENSE",
"README.md"
],
"publishConfig": {
"registry": "https://npm.pkg.github.com",
"access": "restricted"
},
"exports": {
"./protocol_version.json": "./protocol_version.json",
"./pb/*.proto": "./pb/*.proto"
}
}