Skip to content

Commit dc19e98

Browse files
committed
docs(release): add no-clone distribution and publish workflow
1 parent d0592cc commit dc19e98

6 files changed

Lines changed: 252 additions & 1 deletion

File tree

.github/workflows/publish-sdk.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish SDK
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "Git tag to publish from (example: sdk-v0.1.1)"
8+
required: true
9+
type: string
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: typescript
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
ref: ${{ github.event.inputs.tag }}
23+
24+
- name: Setup pnpm
25+
uses: pnpm/action-setup@v4
26+
with:
27+
version: 9
28+
29+
- name: Setup Node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
registry-url: https://registry.npmjs.org
34+
cache: pnpm
35+
cache-dependency-path: typescript/pnpm-lock.yaml
36+
37+
- name: Install
38+
run: pnpm install --frozen-lockfile
39+
40+
- name: Build SDK
41+
run: pnpm --filter @spatiad/sdk build
42+
43+
- name: Test SDK
44+
run: pnpm --filter @spatiad/sdk test
45+
46+
- name: Publish SDK
47+
run: pnpm --filter @spatiad/sdk publish --no-git-checks --access public
48+
env:
49+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ See full matrix in docs/CONFIG.md.
8282

8383
Detailed deployment steps are in docs/DEPLOYMENT.md.
8484

85+
## Distribution without clone
86+
87+
- TypeScript SDK from npm: `npm i @spatiad/sdk` or `pnpm add @spatiad/sdk`
88+
- Container runtime from published image (Docker/OCI registry)
89+
- Binary install via one command installer script: `dist/install-spatiad.sh`
90+
91+
Release and publishing flow is documented in docs/PUBLISHING.md.
92+
8593
## Documentation
8694

8795
Primary references:
@@ -92,6 +100,7 @@ Primary references:
92100
- docs/SECURITY.md
93101
- docs/CONFIG.md
94102
- docs/DEPLOYMENT.md
103+
- docs/PUBLISHING.md
95104
- docs/OPERATIONS_RUNBOOK.md
96105
- docs/TROUBLESHOOTING.md
97106
- ARCHITECTURE.md

dist/install-spatiad.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env sh
2+
set -eu
3+
4+
VERSION="${1:-v0.1.0}"
5+
INSTALL_DIR="${2:-/usr/local/bin}"
6+
OWNER="${SPATIAD_GITHUB_OWNER:-zubeyralmaho}"
7+
REPO="${SPATIAD_GITHUB_REPO:-spatiad}"
8+
9+
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
10+
ARCH_RAW="$(uname -m)"
11+
12+
case "$ARCH_RAW" in
13+
x86_64|amd64) ARCH="x86_64" ;;
14+
arm64|aarch64) ARCH="aarch64" ;;
15+
*)
16+
echo "Unsupported architecture: $ARCH_RAW" >&2
17+
exit 1
18+
;;
19+
esac
20+
21+
case "$OS" in
22+
linux|darwin) ;;
23+
*)
24+
echo "Unsupported OS: $OS" >&2
25+
exit 1
26+
;;
27+
esac
28+
29+
ASSET="spatiad-${VERSION}-${OS}-${ARCH}.tar.gz"
30+
URL="https://github.com/${OWNER}/${REPO}/releases/download/${VERSION}/${ASSET}"
31+
TMP_DIR="$(mktemp -d)"
32+
trap 'rm -rf "$TMP_DIR"' EXIT
33+
34+
echo "Downloading ${URL}"
35+
36+
if command -v curl >/dev/null 2>&1; then
37+
curl -fsSL "$URL" -o "$TMP_DIR/spatiad.tar.gz"
38+
elif command -v wget >/dev/null 2>&1; then
39+
wget -qO "$TMP_DIR/spatiad.tar.gz" "$URL"
40+
else
41+
echo "Neither curl nor wget is available" >&2
42+
exit 1
43+
fi
44+
45+
tar -xzf "$TMP_DIR/spatiad.tar.gz" -C "$TMP_DIR"
46+
47+
if [ ! -f "$TMP_DIR/spatiad-bin" ]; then
48+
echo "Archive does not contain spatiad-bin" >&2
49+
exit 1
50+
fi
51+
52+
mkdir -p "$INSTALL_DIR"
53+
install -m 0755 "$TMP_DIR/spatiad-bin" "$INSTALL_DIR/spatiad-bin"
54+
55+
echo "Installed spatiad-bin to ${INSTALL_DIR}/spatiad-bin"
56+
echo "Run: ${INSTALL_DIR}/spatiad-bin"

docs/PUBLISHING.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Publishing and No-Clone Distribution
2+
3+
This guide explains how users can install Spatiad artifacts without cloning this repository.
4+
5+
## 1) Publish TypeScript SDK to npm
6+
7+
Users can then install with npm, pnpm, or yarn.
8+
9+
### One-time setup
10+
11+
```bash
12+
npm login
13+
```
14+
15+
### Release flow
16+
17+
```bash
18+
cd typescript
19+
pnpm install --frozen-lockfile
20+
pnpm --filter @spatiad/sdk build
21+
pnpm --filter @spatiad/sdk test
22+
pnpm --filter @spatiad/sdk publish --no-git-checks --access public
23+
```
24+
25+
### GitHub Actions option
26+
27+
Use `.github/workflows/publish-sdk.yml` with `workflow_dispatch` and a release tag.
28+
29+
Required secret:
30+
31+
- `NPM_TOKEN`: npm automation token with publish permission for `@spatiad/sdk`
32+
33+
After publish, end users install with:
34+
35+
```bash
36+
npm i @spatiad/sdk
37+
# or
38+
pnpm add @spatiad/sdk
39+
```
40+
41+
## 2) Publish container image
42+
43+
Container users do not need source code.
44+
45+
Example (GHCR):
46+
47+
```bash
48+
docker build -t ghcr.io/<owner>/spatiad:latest -f Dockerfile .
49+
docker push ghcr.io/<owner>/spatiad:latest
50+
```
51+
52+
Consumers run with:
53+
54+
```bash
55+
docker run -p 3000:3000 ghcr.io/<owner>/spatiad:latest
56+
```
57+
58+
## 3) Publish binary assets and support one-command install
59+
60+
Build and upload release archives to GitHub Releases with this naming pattern:
61+
62+
- spatiad-vX.Y.Z-linux-x86_64.tar.gz
63+
- spatiad-vX.Y.Z-linux-aarch64.tar.gz
64+
- spatiad-vX.Y.Z-darwin-x86_64.tar.gz
65+
- spatiad-vX.Y.Z-darwin-aarch64.tar.gz
66+
67+
Each archive should contain:
68+
69+
- spatiad-bin
70+
71+
Users can install via:
72+
73+
```bash
74+
curl -fsSL https://raw.githubusercontent.com/<owner>/spatiad/main/dist/install-spatiad.sh | sh -s -- v0.1.0
75+
```
76+
77+
Or with explicit install dir:
78+
79+
```bash
80+
curl -fsSL https://raw.githubusercontent.com/<owner>/spatiad/main/dist/install-spatiad.sh | sh -s -- v0.1.0 /usr/local/bin
81+
```
82+
83+
## npm vs pnpm
84+
85+
- Publishing target is npm registry.
86+
- End users may use npm, pnpm, or yarn.
87+
- pnpm is a package manager choice, not a separate distribution channel.

typescript/packages/sdk/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# @spatiad/sdk
2+
3+
TypeScript SDK for Spatiad dispatch APIs.
4+
5+
## Install
6+
7+
```bash
8+
npm i @spatiad/sdk
9+
# or
10+
pnpm add @spatiad/sdk
11+
```
12+
13+
## Usage
14+
15+
```ts
16+
import { SpatiadClient } from "@spatiad/sdk";
17+
18+
const client = new SpatiadClient("http://localhost:3000", {
19+
dispatcherToken: process.env.SPATIAD_DISPATCHER_TOKEN,
20+
dispatcherAuthMode: "bearer"
21+
});
22+
23+
const status = await client.getJobStatus({
24+
jobId: "22222222-2222-2222-2222-222222222222"
25+
});
26+
27+
console.log(status.state);
28+
```
29+
30+
See full examples in ../../docs/GETTING_STARTED.md.
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
{
22
"name": "@spatiad/sdk",
33
"version": "0.1.0",
4+
"description": "TypeScript SDK for Spatiad dispatch APIs",
45
"type": "module",
56
"main": "dist/index.js",
67
"types": "dist/index.d.ts",
8+
"files": [
9+
"dist",
10+
"README.md"
11+
],
12+
"publishConfig": {
13+
"access": "public"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/zubeyralmaho/spatiad.git",
18+
"directory": "typescript/packages/sdk"
19+
},
20+
"keywords": [
21+
"dispatch",
22+
"fleet",
23+
"spatiad",
24+
"sdk"
25+
],
726
"scripts": {
827
"build": "tsc -p tsconfig.json",
928
"test": "node --test",
10-
"lint": "echo 'no lint configured yet'"
29+
"lint": "echo 'no lint configured yet'",
30+
"prepublishOnly": "pnpm run build && pnpm run test"
1131
}
1232
}

0 commit comments

Comments
 (0)