mirror of
https://github.com/ziex-dev/ziex.git
synced 2026-07-20 02:29:36 -06:00
ci: add npm release automation
This commit is contained in:
parent
cbb63d14cf
commit
6281b2468d
42
.github/workflows/release.yml
vendored
42
.github/workflows/release.yml
vendored
@ -122,6 +122,48 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
publish-npm:
|
||||||
|
name: Publish CLI to NPM
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build-release
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
registry-url: https://registry.npmjs.org
|
||||||
|
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
|
||||||
|
- name: Place binaries in zig-out/bin/release
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir -p zig-out/bin/release
|
||||||
|
for dir in dist/*/; do
|
||||||
|
for file in "$dir"*; do
|
||||||
|
case "$file" in
|
||||||
|
*.tar.gz) tar -xzf "$file" -C zig-out/bin/release ;;
|
||||||
|
*.zip) unzip -o "$file" -d zig-out/bin/release ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Prepare and publish @ziex packages
|
||||||
|
run: |
|
||||||
|
cd pkg/@ziex
|
||||||
|
bash prepare.sh
|
||||||
|
npm publish --workspaces --access public --provenance
|
||||||
|
|
||||||
sync-templates:
|
sync-templates:
|
||||||
name: Sync & Release Templates
|
name: Sync & Release Templates
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
8
pkg/@ziex/.gitignore
vendored
8
pkg/@ziex/.gitignore
vendored
@ -1,10 +1,6 @@
|
|||||||
*/bin/zig
|
*/bin/zx
|
||||||
*/bin/zig.exe
|
*/bin/zx.exe
|
||||||
*/README.md
|
*/README.md
|
||||||
lib/
|
|
||||||
|
|
||||||
!lib/package.json
|
|
||||||
.zig-version
|
|
||||||
.cache/
|
|
||||||
.verdaccio-storage/
|
.verdaccio-storage/
|
||||||
.verdaccio-htpasswd
|
.verdaccio-htpasswd
|
||||||
@ -1,6 +1,6 @@
|
|||||||
# @ziex/cli
|
# @ziex/cli
|
||||||
|
|
||||||
Ziex CLI Node Package Manager (npm) distribution.
|
Ziex CLI distribution via NPM.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -25,6 +25,4 @@ The `@ziex/cli` package resolves the correct native binary for your platform via
|
|||||||
| `@ziex/cli-linux-x64` | Linux x64 |
|
| `@ziex/cli-linux-x64` | Linux x64 |
|
||||||
| `@ziex/cli-linux-arm64` | Linux ARM64 |
|
| `@ziex/cli-linux-arm64` | Linux ARM64 |
|
||||||
| `@ziex/cli-win32-x64` | Windows x64 |
|
| `@ziex/cli-win32-x64` | Windows x64 |
|
||||||
| `@ziex/cli-win32-arm64` | Windows ARM64 |
|
| `@ziex/cli-win32-arm64` | Windows ARM64 |
|
||||||
|
|
||||||
The standard library is shipped separately in `@ziex/lib` (shared across all platforms).
|
|
||||||
8
pkg/@ziex/check.sh
Normal file
8
pkg/@ziex/check.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
rm -rf tmp
|
||||||
|
mkdir tmp
|
||||||
|
cd tmp
|
||||||
|
|
||||||
|
echo "version:"
|
||||||
|
npx --registry http://localhost:4873 @ziex/cli@dev version
|
||||||
|
echo -e "\ninit:"
|
||||||
|
npx --registry http://localhost:4873 @ziex/cli@dev init
|
||||||
@ -1,61 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
// Stub that delegates to the native zx binary.
|
|
||||||
// The postinstall script copies it to bin/zx, but if that hasn't run
|
|
||||||
// (e.g. bunx), we resolve the platform package's binary directly.
|
|
||||||
|
|
||||||
import { execFileSync } from "child_process";
|
|
||||||
import { existsSync } from "fs";
|
|
||||||
import { createRequire } from "module";
|
|
||||||
import { dirname, join } from "path";
|
|
||||||
import { fileURLToPath } from "url";
|
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
const isWindows = process.platform === "win32";
|
|
||||||
const ext = isWindows ? ".exe" : "";
|
|
||||||
|
|
||||||
function findBinary() {
|
|
||||||
// 1. Check if postinstall already placed the binary
|
|
||||||
const localBin = join(__dirname, `zx${ext}`);
|
|
||||||
if (existsSync(localBin)) return localBin;
|
|
||||||
|
|
||||||
// 2. Resolve from the platform-specific optional dependency
|
|
||||||
const platformPkgs = {
|
|
||||||
"darwin-arm64": "@ziex/cli-darwin-arm64",
|
|
||||||
"darwin-x64": "@ziex/cli-darwin-x64",
|
|
||||||
"linux-x64": "@ziex/cli-linux-x64",
|
|
||||||
"linux-arm64": "@ziex/cli-linux-arm64",
|
|
||||||
"win32-x64": "@ziex/cli-win32-x64",
|
|
||||||
"win32-arm64": "@ziex/cli-win32-arm64",
|
|
||||||
};
|
|
||||||
|
|
||||||
const pkg = platformPkgs[`${process.platform}-${process.arch}`];
|
|
||||||
if (pkg) {
|
|
||||||
try {
|
|
||||||
const pkgDir = dirname(require.resolve(`${pkg}/package.json`));
|
|
||||||
const bin = join(pkgDir, "bin", `zx${ext}`);
|
|
||||||
if (existsSync(bin)) return bin;
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bin = findBinary();
|
|
||||||
if (!bin) {
|
|
||||||
console.error(
|
|
||||||
"Error: ziex native binary not found. The postinstall script may not have run.",
|
|
||||||
);
|
|
||||||
console.error("Try reinstalling: npm install -g ziex");
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
execFileSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
||||||
} catch (e) {
|
|
||||||
if (e.status !== undefined) {
|
|
||||||
process.exit(e.status);
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
@ -8,6 +8,7 @@
|
|||||||
"publish": "npm publish --workspaces --access public",
|
"publish": "npm publish --workspaces --access public",
|
||||||
"start:registry": "verdaccio --config verdaccio.yaml --listen 4873",
|
"start:registry": "verdaccio --config verdaccio.yaml --listen 4873",
|
||||||
"publish:local": "npm publish --workspaces --registry http://localhost:4873",
|
"publish:local": "npm publish --workspaces --registry http://localhost:4873",
|
||||||
|
"check": "bash check.sh",
|
||||||
"syncver": "npm version --ignore-scripts --workspace lib --workspace cli --workspace cli-darwin-arm64 --workspace cli-darwin-x64 --workspace cli-linux-x64 --workspace cli-linux-arm64 --workspace cli-win32-x64 --workspace cli-win32-arm64"
|
"syncver": "npm version --ignore-scripts --workspace lib --workspace cli --workspace cli-darwin-arm64 --workspace cli-darwin-x64 --workspace cli-linux-x64 --workspace cli-linux-arm64 --workspace cli-win32-x64 --workspace cli-win32-arm64"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Downloads Zig compiler binaries for all platforms.
|
# Prepares @ziex npm packages for publishing.
|
||||||
# Reads version from package.json.
|
# Reads version from the root build.zig.zon.
|
||||||
# Places lib/ in the shared @zigc/lib package (identical across platforms).
|
# Copies platform binaries and syncs package versions.
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
ZIEX_VER=$(node -p "require('$SCRIPT_DIR/package.json').version")
|
ROOT_DIR="$SCRIPT_DIR/../.."
|
||||||
LIB_COPIED=false
|
ZIEX_VER=$(sed -n 's/.*\.version *= *"\([^"]*\)".*/\1/p' "$ROOT_DIR/build.zig.zon")
|
||||||
|
|
||||||
# Update version in all workspace package.json files
|
# Update version in all workspace package.json files
|
||||||
echo "Updating package versions to $ZIEX_VER..."
|
echo "Updating package versions to $ZIEX_VER..."
|
||||||
@ -35,6 +35,38 @@ if [[ "${1:-}" == "--version" ]]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Copy binaries from zig-out/bin/release to respective platform packages
|
||||||
|
RELEASE_DIR="$SCRIPT_DIR/../../zig-out/bin/release"
|
||||||
|
|
||||||
|
declare -A BINARY_MAP=(
|
||||||
|
["cli-darwin-arm64"]="zx-macos-aarch64"
|
||||||
|
["cli-darwin-x64"]="zx-macos-x64"
|
||||||
|
["cli-linux-x64"]="zx-linux-x64"
|
||||||
|
["cli-linux-arm64"]="zx-linux-aarch64"
|
||||||
|
["cli-win32-x64"]="zx-windows-x64.exe"
|
||||||
|
["cli-win32-arm64"]="zx-windows-aarch64.exe"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Copying binaries from $RELEASE_DIR..."
|
||||||
|
for pkg in "${!BINARY_MAP[@]}"; do
|
||||||
|
src="$RELEASE_DIR/${BINARY_MAP[$pkg]}"
|
||||||
|
dest_dir="$SCRIPT_DIR/$pkg/bin"
|
||||||
|
if [[ "$pkg" == cli-win32-* ]]; then
|
||||||
|
dest="$dest_dir/zx.exe"
|
||||||
|
else
|
||||||
|
dest="$dest_dir/zx"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$src" ]; then
|
||||||
|
mkdir -p "$dest_dir"
|
||||||
|
cp "$src" "$dest"
|
||||||
|
chmod +x "$dest"
|
||||||
|
echo " Copied ${BINARY_MAP[$pkg]} -> $pkg/bin/"
|
||||||
|
else
|
||||||
|
echo " Warning: $src not found, skipping $pkg"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Copy README.md to all packages
|
# Copy README.md to all packages
|
||||||
echo "Copying README.md to all packages..."
|
echo "Copying README.md to all packages..."
|
||||||
for dir in cli cli-darwin-arm64 cli-darwin-x64 cli-linux-x64 cli-linux-arm64 cli-win32-x64 cli-win32-arm64; do
|
for dir in cli cli-darwin-arm64 cli-darwin-x64 cli-linux-x64 cli-linux-arm64 cli-win32-x64 cli-win32-arm64; do
|
||||||
|
|||||||
16
pkg/README.md
Normal file
16
pkg/README.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Ziex Packages
|
||||||
|
|
||||||
|
Subpackages that are published separately or consumed by the root Ziex project.
|
||||||
|
|
||||||
|
| Package | Platform/Lang | Description |
|
||||||
|
|---------|---------------|-------------|
|
||||||
|
| `ziex` | NPM/JavaScript | Ziex JavaScript bindings for browser, Cloudflare, Vercel, WASI, and more |
|
||||||
|
| `@ziex` | NPM/JavaScript | @ziex org on NPM for CLI-related packages |
|
||||||
|
| `adapters` | Zig | Adapters for Ziex (zx.db (SQLite), zx.kv (FS)) |
|
||||||
|
| `create-ziex` | NPM/JavaScript | `npm init ziex` or `bun create ziex` |
|
||||||
|
| `create-zig` | Zig | `npm init zig` or `bun create zig` |
|
||||||
|
| `playground` | Zig | Interactive Zig development environment |
|
||||||
|
| `plugin-bun` | NPM/JavaScript | Bun plugin for the Zig build system |
|
||||||
|
| `plugin-tailwind` | Zig | Tailwind CSS plugin for the Zig build system |
|
||||||
|
| `tree-sitter-zx` | Tree-Sitter (C) | Tree-Sitter parser for .zx files |
|
||||||
|
| `tree-sitter-mdx` | Tree-Sitter (C) | Tree-Sitter parser for .mdzx files |
|
||||||
Loading…
x
Reference in New Issue
Block a user