Skip to content

Commit c06e5c9

Browse files
committed
release
1 parent 0a3c2d4 commit c06e5c9

19 files changed

Lines changed: 2305 additions & 8 deletions

File tree

.DS_Store

8 KB
Binary file not shown.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Full index with metadata, tags, and relationships: `flows/adr-index.md`
8989
| `sdd-https-vpn-ciphersuite-cn` | `flows/sdd-https-vpn-ciphersuite-cn/_status.md` | IMPLEMENTATION (SM9 deferred) |
9090
| `sdd-https-vpn-multi-cert` | `flows/sdd-https-vpn-multi-cert/_status.md` | REQUIREMENTS (drafting) |
9191
| `sdd-https-vpn-ciphersuite-ua` | `flows/sdd-https-vpn-ciphersuite-ua/_status.md` | IMPLEMENTATION (базова реалізація завершена) |
92+
| `sdd-h2-cli-release` | `flows/sdd-h2-cli-release/_status.md` | IMPLEMENTATION (script ready) |
9293

9394
### DDD Flows (Document-Driven)
9495

build/mobile.sh

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Build h2.core as iOS Framework and Android AAR using gomobile.
4+
#
5+
# Prerequisites:
6+
# - Go 1.21+
7+
# - Xcode (for iOS)
8+
# - Android SDK/NDK (for Android)
9+
# - gomobile: go install golang.org/x/mobile/cmd/gomobile@latest
10+
#
11+
# Usage:
12+
# ./build/mobile.sh # Build both iOS and Android
13+
# ./build/mobile.sh ios # Build iOS only
14+
# ./build/mobile.sh android # Build Android only
15+
#
16+
set -euo pipefail
17+
18+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
19+
cd "$ROOT_DIR"
20+
21+
OUT_DIR="${OUT_DIR:-dist/mobile}"
22+
VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo "0.1.0-dev")}"
23+
24+
mkdir -p "$OUT_DIR"
25+
26+
# Add Go bin to PATH
27+
export PATH="$PATH:$(go env GOPATH)/bin"
28+
29+
# Check gomobile
30+
check_gomobile() {
31+
if ! command -v gomobile &> /dev/null; then
32+
echo "gomobile not found. Installing..."
33+
go install golang.org/x/mobile/cmd/gomobile@latest
34+
echo "Initializing gomobile..."
35+
gomobile init
36+
fi
37+
}
38+
39+
# Build iOS Framework
40+
build_ios() {
41+
echo "=== Building iOS Framework ==="
42+
echo "Output: $OUT_DIR/H2Core.xcframework"
43+
echo ""
44+
45+
# Check for Xcode
46+
if ! command -v xcodebuild &> /dev/null; then
47+
echo "WARNING: Xcode not found. Skipping iOS build."
48+
return 1
49+
fi
50+
51+
gomobile bind \
52+
-target=ios \
53+
-ldflags="-s -w -X github.com/vpnclient/https-vpn/mobile.Version=$VERSION" \
54+
-o "$OUT_DIR/H2Core.xcframework" \
55+
./mobile
56+
57+
echo "iOS Framework built successfully!"
58+
echo ""
59+
}
60+
61+
# Build Android AAR
62+
build_android() {
63+
echo "=== Building Android AAR ==="
64+
echo "Output: $OUT_DIR/h2core.aar"
65+
echo ""
66+
67+
# Check for Android SDK
68+
if [[ -z "${ANDROID_HOME:-}" ]] && [[ -z "${ANDROID_SDK_ROOT:-}" ]]; then
69+
echo "WARNING: ANDROID_HOME/ANDROID_SDK_ROOT not set."
70+
echo "Attempting build anyway (may fail if SDK not in default location)..."
71+
fi
72+
73+
gomobile bind \
74+
-target=android \
75+
-androidapi=21 \
76+
-ldflags="-s -w -X github.com/vpnclient/https-vpn/mobile.Version=$VERSION" \
77+
-o "$OUT_DIR/h2core.aar" \
78+
./mobile
79+
80+
echo "Android AAR built successfully!"
81+
echo ""
82+
}
83+
84+
# Main
85+
check_gomobile
86+
87+
TARGET="${1:-all}"
88+
89+
case "$TARGET" in
90+
ios)
91+
build_ios
92+
;;
93+
android)
94+
build_android
95+
;;
96+
all)
97+
# Try both, continue if one fails
98+
build_ios || echo "iOS build skipped/failed"
99+
build_android || echo "Android build skipped/failed"
100+
;;
101+
*)
102+
echo "Usage: $0 [ios|android|all]"
103+
exit 1
104+
;;
105+
esac
106+
107+
echo "=== Build Complete ==="
108+
echo "Outputs in $OUT_DIR/:"
109+
ls -la "$OUT_DIR"/ 2>/dev/null || true

build/release.sh

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/bash
2+
# h2.core cross-platform release build script
3+
# Builds CLI binaries for all supported platforms
4+
5+
set -e
6+
7+
VERSION="${VERSION:-0.1.0}"
8+
OUTPUT_DIR="${OUTPUT_DIR:-dist}"
9+
CMD_PATH="./cmd/https-vpn"
10+
BINARY_NAME="https-vpn"
11+
12+
# Create output directory
13+
mkdir -p "$OUTPUT_DIR"
14+
15+
# Build targets: GOOS/GOARCH/ARM/Name
16+
TARGETS=(
17+
# Linux
18+
"linux/amd64//h2-linux-64"
19+
"linux/386//h2-linux-32"
20+
"linux/arm64//h2-linux-arm64-v8a"
21+
"linux/arm/7/h2-linux-arm32-v7a"
22+
"linux/arm/6/h2-linux-arm32-v6"
23+
"linux/arm/5/h2-linux-arm32-v5"
24+
"linux/mips//h2-linux-mips32"
25+
"linux/mipsle//h2-linux-mips32le"
26+
"linux/mips64//h2-linux-mips64"
27+
"linux/mips64le//h2-linux-mips64le"
28+
"linux/ppc64//h2-linux-ppc64"
29+
"linux/ppc64le//h2-linux-ppc64le"
30+
"linux/riscv64//h2-linux-riscv64"
31+
"linux/s390x//h2-linux-s390x"
32+
"linux/loong64//h2-linux-loong64"
33+
34+
# macOS
35+
"darwin/amd64//h2-macos-64"
36+
"darwin/arm64//h2-macos-arm64-v8a"
37+
38+
# FreeBSD
39+
"freebsd/amd64//h2-freebsd-64"
40+
"freebsd/386//h2-freebsd-32"
41+
"freebsd/arm64//h2-freebsd-arm64-v8a"
42+
"freebsd/arm/7/h2-freebsd-arm32-v7a"
43+
44+
# OpenBSD
45+
"openbsd/amd64//h2-openbsd-64"
46+
"openbsd/386//h2-openbsd-32"
47+
"openbsd/arm64//h2-openbsd-arm64-v8a"
48+
"openbsd/arm/7/h2-openbsd-arm32-v7a"
49+
50+
# Android (CLI)
51+
"android/amd64//h2-android-amd64"
52+
"android/arm64//h2-android-arm64-v8a"
53+
54+
# Windows
55+
"windows/amd64//h2-windows-64"
56+
"windows/386//h2-windows-32"
57+
"windows/arm64//h2-windows-arm64-v8a"
58+
)
59+
60+
echo "Building h2.core v${VERSION} for ${#TARGETS[@]} platforms..."
61+
62+
build_target() {
63+
local target="$1"
64+
IFS='/' read -r goos goarch goarm name <<< "$target"
65+
66+
local binary="$BINARY_NAME"
67+
[[ "$goos" == "windows" ]] && binary="${BINARY_NAME}.exe"
68+
69+
local build_dir="$OUTPUT_DIR/$name"
70+
mkdir -p "$build_dir"
71+
72+
echo "Building $name..."
73+
74+
local env="GOOS=$goos GOARCH=$goarch CGO_ENABLED=0"
75+
[[ -n "$goarm" ]] && env="$env GOARM=$goarm"
76+
77+
if eval $env go build -trimpath -ldflags="-s -w -X main.Version=${VERSION}" \
78+
-o "$build_dir/$binary" "$CMD_PATH" 2>/dev/null; then
79+
# Create zip
80+
(cd "$OUTPUT_DIR" && zip -q -r "$name.zip" "$name")
81+
rm -rf "$build_dir"
82+
echo " -> $OUTPUT_DIR/$name.zip"
83+
else
84+
echo " -> SKIPPED (build failed)"
85+
rm -rf "$build_dir"
86+
fi
87+
}
88+
89+
# Build all targets
90+
for target in "${TARGETS[@]}"; do
91+
build_target "$target"
92+
done
93+
94+
# Win7 builds (requires Go 1.20 - last version with Win7 support)
95+
# Skip if GO120 not set
96+
if [ -n "$GO120" ] && [ -x "$GO120" ]; then
97+
echo ""
98+
echo "Building Win7 targets with Go 1.20..."
99+
100+
for arch in "amd64/h2-win7-64" "386/h2-win7-32"; do
101+
IFS='/' read -r goarch name <<< "$arch"
102+
mkdir -p "$OUTPUT_DIR/$name"
103+
echo "Building $name..."
104+
GOOS=windows GOARCH=$goarch CGO_ENABLED=0 $GO120 build -trimpath \
105+
-ldflags="-s -w -X main.Version=${VERSION}" \
106+
-o "$OUTPUT_DIR/$name/${BINARY_NAME}.exe" "$CMD_PATH"
107+
(cd "$OUTPUT_DIR" && zip -q -r "$name.zip" "$name")
108+
rm -rf "$OUTPUT_DIR/$name"
109+
echo " -> $OUTPUT_DIR/$name.zip"
110+
done
111+
else
112+
echo ""
113+
echo "Skipping Win7 builds (set GO120=/path/to/go1.20/bin/go to enable)"
114+
fi
115+
116+
# Generate checksums
117+
echo ""
118+
echo "Generating checksums..."
119+
(cd "$OUTPUT_DIR" && sha256sum *.zip > checksums.txt 2>/dev/null || shasum -a 256 *.zip > checksums.txt)
120+
echo " -> $OUTPUT_DIR/checksums.txt"
121+
122+
echo ""
123+
echo "Build complete! Archives in $OUTPUT_DIR/"
124+
ls -lh "$OUTPUT_DIR"/*.zip 2>/dev/null | head -20
125+
echo "..."
126+
echo "Total: $(ls -1 "$OUTPUT_DIR"/*.zip 2>/dev/null | wc -l) archives"
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Requirements: h2-cli-release
2+
3+
> Version: 1.0
4+
> Status: APPROVED
5+
> Last Updated: 2026-05-16
6+
7+
## Problem Statement
8+
9+
h2.core needs cross-platform CLI binary releases for direct deployment on servers and clients. Users should be able to download a single zip for their platform and run the HTTPS VPN immediately.
10+
11+
## User Stories
12+
13+
### Primary
14+
15+
**As a** system administrator
16+
**I want** to download h2.core CLI for my platform
17+
**So that** I can run an HTTPS VPN server/client without building from source
18+
19+
**As a** developer
20+
**I want** automated release builds for all platforms
21+
**So that** releases are consistent and reproducible
22+
23+
## Acceptance Criteria
24+
25+
### Must Have
26+
27+
1. **Given** the build script `build/release.sh`
28+
**When** running without arguments
29+
**Then** all 30+ platform binaries are built and zipped
30+
31+
2. **Given** a platform target (e.g., linux/amd64)
32+
**When** the binary is built
33+
**Then** it should be statically linked (CGO_ENABLED=0) and stripped (-s -w)
34+
35+
3. **Given** the built archives
36+
**When** checking file names
37+
**Then** they match the naming convention: `h2-{os}-{arch}.zip`
38+
39+
## Target Platforms
40+
41+
| Archive Name | GOOS | GOARCH | GOARM |
42+
|-------------|------|--------|-------|
43+
| h2-linux-64.zip | linux | amd64 | - |
44+
| h2-linux-32.zip | linux | 386 | - |
45+
| h2-linux-arm64-v8a.zip | linux | arm64 | - |
46+
| h2-linux-arm32-v7a.zip | linux | arm | 7 |
47+
| h2-linux-arm32-v6.zip | linux | arm | 6 |
48+
| h2-linux-arm32-v5.zip | linux | arm | 5 |
49+
| h2-linux-mips32.zip | linux | mips | - |
50+
| h2-linux-mips32le.zip | linux | mipsle | - |
51+
| h2-linux-mips64.zip | linux | mips64 | - |
52+
| h2-linux-mips64le.zip | linux | mips64le | - |
53+
| h2-linux-ppc64.zip | linux | ppc64 | - |
54+
| h2-linux-ppc64le.zip | linux | ppc64le | - |
55+
| h2-linux-riscv64.zip | linux | riscv64 | - |
56+
| h2-linux-s390x.zip | linux | s390x | - |
57+
| h2-linux-loong64.zip | linux | loong64 | - |
58+
| h2-macos-64.zip | darwin | amd64 | - |
59+
| h2-macos-arm64-v8a.zip | darwin | arm64 | - |
60+
| h2-freebsd-64.zip | freebsd | amd64 | - |
61+
| h2-freebsd-32.zip | freebsd | 386 | - |
62+
| h2-freebsd-arm64-v8a.zip | freebsd | arm64 | - |
63+
| h2-freebsd-arm32-v7a.zip | freebsd | arm | 7 |
64+
| h2-openbsd-64.zip | openbsd | amd64 | - |
65+
| h2-openbsd-32.zip | openbsd | 386 | - |
66+
| h2-openbsd-arm64-v8a.zip | openbsd | arm64 | - |
67+
| h2-openbsd-arm32-v7a.zip | openbsd | arm | 7 |
68+
| h2-windows-64.zip | windows | amd64 | - |
69+
| h2-windows-32.zip | windows | 386 | - |
70+
| h2-windows-arm64-v8a.zip | windows | arm64 | - |
71+
| h2-win7-64.zip | windows | amd64 | - |
72+
| h2-win7-32.zip | windows | 386 | - |
73+
| h2-android-amd64.zip | android | amd64 | - |
74+
| h2-android-arm64-v8a.zip | android | arm64 | - |
75+
76+
## Constraints
77+
78+
- **No CGO**: All builds with `CGO_ENABLED=0` for static linking
79+
- **No .so/.dylib**: This flow is CLI only, no shared libraries
80+
- **No gomobile**: Mobile wrappers are in libh2, not h2.core
81+
82+
## Non-Goals
83+
84+
- iOS builds (CLI not applicable)
85+
- Shared library builds (.so, .dylib, .dll)
86+
- Gomobile frameworks (xcframework, aar)
87+
88+
## References
89+
90+
- Source: `cmd/https-vpn/main.go`
91+
- Build script: `build/release.sh`
92+
93+
---
94+
95+
## Approval
96+
97+
- [x] Reviewed by: User
98+
- [x] Approved on: 2026-05-16

0 commit comments

Comments
 (0)