Skip to content

Commit 4f3eefd

Browse files
docs: add pre/post-flight checks and document v0.2.0 release failure
1 parent e5c7727 commit 4f3eefd

2 files changed

Lines changed: 350 additions & 0 deletions

File tree

scripts/post-flight-check.sh

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#!/bin/bash
2+
# Post-flight checks after CI completes
3+
# This script MUST pass before updating Homebrew formula
4+
5+
set -e
6+
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
YELLOW='\033[1;33m'
10+
NC='\033[0m'
11+
12+
fail() {
13+
echo -e "${RED}[FAIL]${NC} $1"
14+
exit 1
15+
}
16+
17+
pass() {
18+
echo -e "${GREEN}[PASS]${NC} $1"
19+
}
20+
21+
warn() {
22+
echo -e "${YELLOW}[WARN]${NC} $1"
23+
}
24+
25+
echo "=========================================="
26+
echo " LAIN Post-Flight Release Checks"
27+
echo "=========================================="
28+
echo ""
29+
30+
# Get version from arguments
31+
VERSION="${1:-}"
32+
if [ -z "$VERSION" ]; then
33+
fail "Usage: $0 <version> (e.g., $0 0.2.0)"
34+
fi
35+
36+
# Check 1: Release exists
37+
echo "Check 1: Checking if release exists..."
38+
if gh release view "v$VERSION" >/dev/null 2>&1; then
39+
pass "Release v$VERSION exists"
40+
else
41+
fail "Release v$VERSION does not exist. Wait for CI to complete."
42+
fi
43+
44+
# Check 2: All expected binaries are present
45+
echo "Check 2: Checking expected binaries..."
46+
EXPECTED_BINARIES=(
47+
"lain-${VERSION}-x86_64-unknown-linux-gnu.tar.gz"
48+
"lain-${VERSION}-aarch64-apple-darwin.tar.gz"
49+
"lain-${VERSION}-x86_64-pc-windows-msvc.tar.gz"
50+
)
51+
52+
RELEASE_ASSETS=$(gh release view "v$VERSION" --json assets --jq '.assets[] | .name')
53+
54+
ALL_BINARIES_PRESENT=true
55+
for binary in "${EXPECTED_BINARIES[@]}"; do
56+
if echo "$RELEASE_ASSETS" | grep -q "$binary"; then
57+
pass "Binary found: $binary"
58+
else
59+
fail "Binary missing: $binary"
60+
ALL_BINARIES_PRESENT=false
61+
fi
62+
done
63+
64+
if [ "$ALL_BINARIES_PRESENT" = false ]; then
65+
fail "Not all expected binaries are present in the release"
66+
fi
67+
68+
# Check 3: Download and verify each binary
69+
echo ""
70+
echo "Check 3: Downloading and verifying binaries..."
71+
TEMP_DIR=$(mktemp -d)
72+
trap "rm -rf $TEMP_DIR" EXIT
73+
74+
declare -A SHA256_HASHES
75+
76+
for binary in "${EXPECTED_BINARIES[@]}"; do
77+
echo " Downloading $binary..."
78+
if curl -fsSL "https://github.com/spuentesp/lain/releases/download/v${VERSION}/${binary}" -o "$TEMP_DIR/$binary"; then
79+
echo " Calculating SHA256 for $binary..."
80+
SHA256=$(shasum -a 256 "$TEMP_DIR/$binary" | cut -d' ' -f1)
81+
SHA256_HASHES["$binary"]="$SHA256"
82+
echo " SHA256: $SHA256"
83+
pass "Downloaded and verified: $binary"
84+
else
85+
fail "Failed to download: $binary"
86+
fi
87+
done
88+
89+
# Check 4: Extract and verify binaries work
90+
echo ""
91+
echo "Check 4: Extracting and verifying binaries..."
92+
93+
# Check macOS ARM binary
94+
if [ "$(uname -s)" = "Darwin" ] && [ "$(uname -m)" = "arm64" ]; then
95+
MACOS_BINARY="lain-${VERSION}-aarch64-apple-darwin.tar.gz"
96+
echo " Extracting $MACOS_BINARY..."
97+
cd "$TEMP_DIR"
98+
tar xzf "$MACOS_BINARY"
99+
100+
if [ -f "lain" ]; then
101+
chmod +x lain
102+
if ./lain --version >/dev/null 2>&1; then
103+
pass "macOS ARM binary is executable"
104+
else
105+
fail "macOS ARM binary is not executable"
106+
fi
107+
else
108+
fail "macOS ARM binary not found in archive"
109+
fi
110+
cd - >/dev/null
111+
else
112+
warn "Skipping binary verification (not on macOS ARM)"
113+
fi
114+
115+
# Check 5: Generate Homebrew formula update instructions
116+
echo ""
117+
echo "Check 5: Generating Homebrew formula update..."
118+
cat <<EOF
119+
==========================================
120+
Homebrew Formula Update Instructions
121+
==========================================
122+
123+
Update Formula/lain.rb with the following SHA256 hashes:
124+
125+
EOF
126+
127+
for binary in "${EXPECTED_BINARIES[@]}"; do
128+
SHA256="${SHA256_HASHES[$binary]}"
129+
case "$binary" in
130+
*aarch64-apple-darwin*)
131+
echo " macOS ARM (aarch64-apple-darwin):"
132+
echo " sha256 \"$SHA256\" => :aarch64_darwin"
133+
;;
134+
*x86_64-unknown-linux-gnu*)
135+
echo " Linux x86_64 (x86_64-unknown-linux-gnu):"
136+
echo " sha256 \"$SHA256\" => :x86_64_linux"
137+
;;
138+
*x86_64-pc-windows-msvc*)
139+
echo " Windows x86_64 (x86_64-pc-windows-msvc):"
140+
echo " sha256 \"$SHA256\" => :x86_64_windows"
141+
;;
142+
esac
143+
done
144+
145+
echo ""
146+
echo "=========================================="
147+
echo -e "${GREEN}✅ All post-flight checks passed!${NC}"
148+
echo "=========================================="
149+
echo ""
150+
echo "Next steps:"
151+
echo " 1. Update Formula/lain.rb with the SHA256 hashes above"
152+
echo " 2. Test the formula locally:"
153+
echo " brew install --build-from-source ./Formula/lain.rb"
154+
echo " 3. Commit and push the formula:"
155+
echo " git add Formula/lain.rb"
156+
echo " git commit -m \"chore: update formula for v$VERSION\""
157+
echo " git push origin main"
158+
echo " 4. Test the release:"
159+
echo " curl -fsSL https://raw.githubusercontent.com/spuentesp/lain/main/install.sh | bash"
160+
echo ""

scripts/pre-flight-check.sh

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
#!/bin/bash
2+
# Pre-flight checks before creating a release
3+
# This script MUST pass before creating a tag
4+
5+
set -e
6+
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
YELLOW='\033[1;33m'
10+
NC='\033[0m'
11+
12+
fail() {
13+
echo -e "${RED}[FAIL]${NC} $1"
14+
exit 1
15+
}
16+
17+
pass() {
18+
echo -e "${GREEN}[PASS]${NC} $1"
19+
}
20+
21+
warn() {
22+
echo -e "${YELLOW}[WARN]${NC} $1"
23+
}
24+
25+
echo "=========================================="
26+
echo " LAIN Pre-Flight Release Checks"
27+
echo "=========================================="
28+
echo ""
29+
30+
# Check 1: All tests pass
31+
echo "Check 1: Running all tests..."
32+
if cargo test 2>&1 | grep -q "test result: ok"; then
33+
pass "All tests pass"
34+
else
35+
fail "Tests failed"
36+
fi
37+
38+
# Check 2: No compilation warnings
39+
echo "Check 2: Checking for compilation warnings..."
40+
if cargo build --release 2>&1 | grep -i warning > /dev/null 2>&1; then
41+
fail "Compilation warnings found. Run: cargo build --release 2>&1 | grep -i warning"
42+
else
43+
pass "No compilation warnings"
44+
fi
45+
46+
# Check 3: Version consistency
47+
echo "Check 3: Checking version consistency..."
48+
VERSION=$(grep '^version = "' Cargo.toml | head -1 | sed 's/version = "\([^"]*\)"/\1/')
49+
if [ -z "$VERSION" ]; then
50+
fail "Could not extract version from Cargo.toml"
51+
fi
52+
53+
# Check Cargo.toml
54+
if grep -q "version = \"$VERSION\"" Cargo.toml; then
55+
pass "Cargo.toml version: $VERSION"
56+
else
57+
fail "Cargo.toml version mismatch"
58+
fi
59+
60+
# Check README.md
61+
if grep -q "v$VERSION" README.md || ! grep -q "v[0-9]" README.md; then
62+
pass "README.md version: $VERSION"
63+
else
64+
fail "README.md version mismatch"
65+
fi
66+
67+
# Check server.json
68+
if grep -q "\"version\": \"$VERSION\"" server.json; then
69+
pass "server.json version: $VERSION"
70+
else
71+
fail "server.json version mismatch"
72+
fi
73+
74+
# Check 4: Binary builds locally
75+
echo "Check 4: Building binary locally..."
76+
if cargo build --release 2>&1 | grep -q "Finished \`release\`"; then
77+
pass "Binary builds successfully"
78+
else
79+
fail "Binary build failed"
80+
fi
81+
82+
# Check 5: Binary is executable
83+
echo "Check 5: Checking binary is executable..."
84+
if [ -f "target/release/lain" ]; then
85+
if target/release/lain --version >/dev/null 2>&1; then
86+
pass "Binary is executable"
87+
else
88+
fail "Binary exists but is not executable"
89+
fi
90+
else
91+
fail "Binary not found at target/release/lain"
92+
fi
93+
94+
# Check 6: Git status is clean
95+
echo "Check 6: Checking git status..."
96+
if [ -n "$(git status --porcelain)" ]; then
97+
fail "Git working directory is not clean. Commit or stash changes."
98+
else
99+
pass "Git working directory is clean"
100+
fi
101+
102+
# Check 7: No uncommitted changes
103+
echo "Check 7: Checking for uncommitted changes..."
104+
if [ -z "$(git diff --name-only)" ] && [ -z "$(git diff --cached --name-only)" ]; then
105+
pass "No uncommitted changes"
106+
else
107+
fail "There are uncommitted changes"
108+
fi
109+
110+
# Check 8: No existing tag for this version
111+
echo "Check 8: Checking for existing tag..."
112+
if git tag -l "v$VERSION" | grep -q "v$VERSION"; then
113+
fail "Tag v$VERSION already exists. Delete it first: git tag -d v$VERSION && git push origin :refs/tags/v$VERSION"
114+
else
115+
pass "No existing tag for v$VERSION"
116+
fi
117+
118+
# Check 9: Release workflow exists and is valid
119+
echo "Check 9: Checking release workflow..."
120+
if [ -f ".github/workflows/release.yml" ]; then
121+
if yamllint .github/workflows/release.yml >/dev/null 2>&1 || grep -q "name:" .github/workflows/release.yml; then
122+
pass "Release workflow exists and is valid"
123+
else
124+
fail "Release workflow is invalid"
125+
fi
126+
else
127+
fail "Release workflow not found"
128+
fi
129+
130+
# Check 10: Awareness docs exist
131+
echo "Check 10: Checking awareness docs..."
132+
AWARENESS_DOCS=(
133+
"hooks/claude/lain-awareness.md"
134+
"hooks/cursor/lain-awareness.md"
135+
"hooks/windsurf/lain-rules.md"
136+
"hooks/cline/lain-rules.md"
137+
)
138+
139+
ALL_DOCS_EXIST=true
140+
for doc in "${AWARENESS_DOCS[@]}"; do
141+
if [ ! -f "$doc" ]; then
142+
warn "Missing awareness doc: $doc"
143+
ALL_DOCS_EXIST=false
144+
fi
145+
done
146+
147+
if [ "$ALL_DOCS_EXIST" = true ]; then
148+
pass "All awareness docs exist"
149+
else
150+
fail "Some awareness docs are missing"
151+
fi
152+
153+
# Check 11: Install script exists and is bash-compatible
154+
echo "Check 11: Checking install script..."
155+
if [ -f "install.sh" ]; then
156+
if bash -n install.sh >/dev/null 2>&1; then
157+
pass "Install script exists and is bash-compatible"
158+
else
159+
fail "Install script has syntax errors"
160+
fi
161+
else
162+
fail "Install script not found"
163+
fi
164+
165+
# Check 12: Formula exists and is valid
166+
echo "Check 12: Checking Homebrew formula..."
167+
if [ -f "Formula/lain.rb" ]; then
168+
if grep -q "class Lain" Formula/lain.rb; then
169+
pass "Homebrew formula exists and is valid"
170+
else
171+
fail "Homebrew formula is invalid"
172+
fi
173+
else
174+
fail "Homebrew formula not found"
175+
fi
176+
177+
echo ""
178+
echo "=========================================="
179+
echo -e "${GREEN}✅ All pre-flight checks passed!${NC}"
180+
echo "=========================================="
181+
echo ""
182+
echo "You can now create the release:"
183+
echo " git tag -a v$VERSION -m \"Release v$VERSION\""
184+
echo " git push origin v$VERSION"
185+
echo ""
186+
echo "After the CI completes, verify:"
187+
echo " gh release view v$VERSION --json assets"
188+
echo " # Download and verify all 3 binaries"
189+
echo ""
190+
echo "Then update the Homebrew formula with SHA256 hashes."

0 commit comments

Comments
 (0)