Skip to content

Commit

Permalink
Release restatectl with other binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkleeman committed Feb 3, 2025
1 parent 3b7fd88 commit cf406e0
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 12 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,12 @@ jobs:
run: |
cat > Dockerfile << 'EOF'
FROM --platform=${BUILDPLATFORM} alpine as builder
ADD restate-cli-aarch64-unknown-linux-musl.tar.xz /restate-arm64
ADD restate-cli-x86_64-unknown-linux-musl.tar.xz /restate-amd64
# keep output image small by removing the server binary
RUN rm /restate-*/restate-server
ADD restate-cli-aarch64-unknown-linux-musl.tar.xz /restate-cli-arm64
ADD restate-cli-x86_64-unknown-linux-musl.tar.xz /restate-cli-amd64
FROM alpine
ARG TARGETARCH
COPY --from=builder /restate-${TARGETARCH} /
COPY --from=builder /restate-cli-${TARGETARCH} /
ENTRYPOINT [ "/restate" ]
EOF
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
matrix:
app_name:
- restate-cli
- restatectl
- restate-server
build:
- target: aarch64-apple-darwin
Expand Down Expand Up @@ -96,6 +97,7 @@ jobs:
matrix:
app_name:
- restate-cli
- restatectl
- restate-server
steps:
- name: Checkout
Expand Down
20 changes: 17 additions & 3 deletions npm/restate-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
#!/usr/bin/env node

/*
* Copyright (c) 2023 - 2025 Restate Software, Inc., Restate GmbH.
* All rights reserved.
*
* Use of this software is governed by the Business Source License
* included in the LICENSE file.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0.
*/

import { spawnSync } from "child_process";
import os from 'node:os';
import os from "node:os";

function getExePath() {
const arch = os.arch();
const op = os.platform();

try {
return require.resolve(`@restatedev/restate-server-${op}-${arch}/bin/restate-server`);
return require.resolve(
`@restatedev/restate-server-${op}-${arch}/bin/restate-server`,
);
} catch (e) {
throw new Error(
`Couldn't find application binary inside node_modules for ${op}-${arch}`
`Couldn't find application binary inside node_modules for ${op}-${arch}`,
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions npm/restate/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

/*
* Copyright (c) 2023 - 2025 Restate Software, Inc., Restate GmbH.
* All rights reserved.
Expand All @@ -10,10 +12,8 @@
* by the Apache License, Version 2.0.
*/

#!/usr/bin/env node

import { spawnSync } from "child_process";
import os from 'node:os';
import os from "node:os";

function getExePath() {
const arch = os.arch();
Expand All @@ -23,7 +23,7 @@ function getExePath() {
return require.resolve(`@restatedev/restate-${op}-${arch}/bin/restate`);
} catch (e) {
throw new Error(
`Couldn't find application binary inside node_modules for ${op}-${arch}`
`Couldn't find application binary inside node_modules for ${op}-${arch}`,
);
}
}
Expand Down
37 changes: 37 additions & 0 deletions npm/restatectl/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@restatedev/restatectl",
"description": "Restate administration tools",
"version": "0.5.1",
"bin": "lib/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/restatedev/restate.git"
},
"publishConfig": {
"@restatedev:registry": "https://registry.npmjs.org"
},
"author": "Restate Developers",
"license": "BSL",
"email": "[email protected]",
"homepage": "https://github.com/restatedev/restate#readme",
"scripts": {
"typecheck": "tsc --noEmit",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"build": "tsc",
"dev": "npm run build && node lib/index.js"
},
"devDependencies": {
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"eslint": "^8.31.0",
"typescript": "^4.9.4"
},
"optionalDependencies": {
"@restatedev/restatectl-linux-x64": "0.5.1",
"@restatedev/restatectl-linux-arm64": "0.5.1",
"@restatedev/restatectl-darwin-x64": "0.5.1",
"@restatedev/restatectl-darwin-arm64": "0.5.1"
}
}
39 changes: 39 additions & 0 deletions npm/restatectl/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env node

/*
* Copyright (c) 2023 - 2025 Restate Software, Inc., Restate GmbH.
* All rights reserved.
*
* Use of this software is governed by the Business Source License
* included in the LICENSE file.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0.
*/

import { spawnSync } from "child_process";
import os from "node:os";

function getExePath() {
const arch = os.arch();
const op = os.platform();

try {
return require.resolve(
`@restatedev/restatectl-${op}-${arch}/bin/restatectl`,
);
} catch (e) {
throw new Error(
`Couldn't find application binary inside node_modules for ${op}-${arch}`,
);
}
}

function run() {
const args = process.argv.slice(2);
const processResult = spawnSync(getExePath(), args, { stdio: "inherit" });
process.exit(processResult.status ?? 0);
}

run();
12 changes: 12 additions & 0 deletions npm/restatectl/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"baseUrl": "./",
"outDir": "lib",
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
7 changes: 7 additions & 0 deletions tools/restatectl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
name = "restatectl"
version.workspace = true
authors.workspace = true
description = "Restate administration tools"
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
publish = false

[package.metadata.dist]
dist = true
formula = "restatectl"

[features]
default = ["replicated-loglet", "memory-loglet", "no-trace-logging"]
replicated-loglet = [
Expand Down

0 comments on commit cf406e0

Please sign in to comment.