|
| 1 | +# AsyncReview Runtime Build System |
| 2 | +# |
| 3 | +# Usage: |
| 4 | +# make build - Build the runtime for current platform |
| 5 | +# make install - Install the built runtime locally |
| 6 | +# make test - Run the bundled runtime test |
| 7 | +# make publish - Publish to GitHub Releases |
| 8 | +# make all - Build, install, and test |
| 9 | +# make clean - Clean build artifacts |
| 10 | +# |
| 11 | +# Version Management: |
| 12 | +# make bump-patch - Bump patch version (0.5.0 -> 0.5.1) |
| 13 | +# make bump-minor - Bump minor version (0.5.0 -> 0.6.0) |
| 14 | +# make bump-major - Bump major version (0.5.0 -> 1.0.0) |
| 15 | + |
| 16 | +.PHONY: all build install test publish clean bump-patch bump-minor bump-major version |
| 17 | + |
| 18 | +# Version file - single source of truth |
| 19 | +VERSION_FILE := VERSION |
| 20 | +VERSION := $(shell cat $(VERSION_FILE) 2>/dev/null || echo "0.5.0") |
| 21 | + |
| 22 | +# Platform detection |
| 23 | +UNAME_S := $(shell uname -s | tr '[:upper:]' '[:lower:]') |
| 24 | +UNAME_M := $(shell uname -m) |
| 25 | +ifeq ($(UNAME_M),arm64) |
| 26 | + ARCH := arm64 |
| 27 | +else ifeq ($(UNAME_M),aarch64) |
| 28 | + ARCH := arm64 |
| 29 | +else |
| 30 | + ARCH := x64 |
| 31 | +endif |
| 32 | +PLATFORM := $(UNAME_S)-$(ARCH) |
| 33 | + |
| 34 | +# Paths |
| 35 | +DIST_DIR := dist |
| 36 | +RUNTIME_ARTIFACT := $(DIST_DIR)/asyncreview-runtime-v$(VERSION)-$(PLATFORM).tar.gz |
| 37 | + |
| 38 | +# Default target |
| 39 | +all: build install test |
| 40 | + |
| 41 | +# Ensure VERSION file exists |
| 42 | +$(VERSION_FILE): |
| 43 | + @echo "0.5.0" > $(VERSION_FILE) |
| 44 | + |
| 45 | +# Show current version |
| 46 | +version: $(VERSION_FILE) |
| 47 | + @echo "Current version: $(VERSION)" |
| 48 | + @echo "Platform: $(PLATFORM)" |
| 49 | + @echo "Artifact: $(RUNTIME_ARTIFACT)" |
| 50 | + |
| 51 | +# Build the runtime |
| 52 | +build: $(VERSION_FILE) |
| 53 | + @echo "==> Building AsyncReview v$(VERSION) for $(PLATFORM)" |
| 54 | + @./scripts/build_runtime_local.sh $(VERSION) |
| 55 | + |
| 56 | +# Install the built runtime locally |
| 57 | +install: $(RUNTIME_ARTIFACT) |
| 58 | + @echo "==> Installing v$(VERSION)" |
| 59 | + @./scripts/install_runtime_local.sh $(RUNTIME_ARTIFACT) $(VERSION) |
| 60 | + |
| 61 | +# Test the installed runtime |
| 62 | +test: |
| 63 | + @echo "==> Testing v$(VERSION)" |
| 64 | + @./scripts/run_cached.sh $(VERSION) review \ |
| 65 | + --url https://github.com/stanfordnlp/dspy/pull/9240 \ |
| 66 | + -q "Use SEARCH_CODE to find process_pair" |
| 67 | + |
| 68 | +# Quick build+install+test cycle |
| 69 | +quick: build install test |
| 70 | + |
| 71 | +# Clean build artifacts |
| 72 | +clean: |
| 73 | + @echo "==> Cleaning build artifacts" |
| 74 | + @rm -rf $(DIST_DIR)/*.tar.gz |
| 75 | + @rm -rf .runtime_stage |
| 76 | + @echo "Done." |
| 77 | + |
| 78 | +# ============================================================ |
| 79 | +# Version Management |
| 80 | +# ============================================================ |
| 81 | + |
| 82 | +bump-patch: $(VERSION_FILE) |
| 83 | + @echo "$(VERSION)" | awk -F. '{printf "%d.%d.%d\n", $$1, $$2, $$3+1}' > $(VERSION_FILE) |
| 84 | + @echo "Bumped to $$(cat $(VERSION_FILE))" |
| 85 | + |
| 86 | +bump-minor: $(VERSION_FILE) |
| 87 | + @echo "$(VERSION)" | awk -F. '{printf "%d.%d.0\n", $$1, $$2+1}' > $(VERSION_FILE) |
| 88 | + @echo "Bumped to $$(cat $(VERSION_FILE))" |
| 89 | + |
| 90 | +bump-major: $(VERSION_FILE) |
| 91 | + @echo "$(VERSION)" | awk -F. '{printf "%d.0.0\n", $$1+1}' > $(VERSION_FILE) |
| 92 | + @echo "Bumped to $$(cat $(VERSION_FILE))" |
| 93 | + |
| 94 | +# ============================================================ |
| 95 | +# Publishing to GitHub Releases |
| 96 | +# ============================================================ |
| 97 | + |
| 98 | +# Check if gh CLI is available and authenticated |
| 99 | +.PHONY: check-gh |
| 100 | +check-gh: |
| 101 | + @command -v gh >/dev/null 2>&1 || { echo "Error: gh CLI not installed"; exit 1; } |
| 102 | + @gh auth status >/dev/null 2>&1 || { echo "Error: gh not authenticated. Run: gh auth login"; exit 1; } |
| 103 | + |
| 104 | +# Create a GitHub release with the runtime artifact |
| 105 | +publish: check-gh $(RUNTIME_ARTIFACT) |
| 106 | + @echo "==> Publishing v$(VERSION) to GitHub Releases" |
| 107 | + @echo " Artifact: $(RUNTIME_ARTIFACT)" |
| 108 | + @gh release create v$(VERSION) \ |
| 109 | + --title "AsyncReview v$(VERSION)" \ |
| 110 | + --notes "Runtime release for $(PLATFORM)" \ |
| 111 | + $(RUNTIME_ARTIFACT) \ |
| 112 | + || { echo "Release v$(VERSION) may already exist. Use 'make publish-update' to add artifacts."; exit 1; } |
| 113 | + @echo "==> Published: https://github.com/AsyncFuncAI/AsyncReview/releases/tag/v$(VERSION)" |
| 114 | + |
| 115 | +# Add artifact to existing release (for multi-platform builds) |
| 116 | +publish-update: check-gh $(RUNTIME_ARTIFACT) |
| 117 | + @echo "==> Adding $(PLATFORM) artifact to v$(VERSION) release" |
| 118 | + @gh release upload v$(VERSION) $(RUNTIME_ARTIFACT) --clobber |
| 119 | + @echo "==> Updated: https://github.com/AsyncFuncAI/AsyncReview/releases/tag/v$(VERSION)" |
| 120 | + |
| 121 | +# ============================================================ |
| 122 | +# Development Helpers |
| 123 | +# ============================================================ |
| 124 | + |
| 125 | +# Build npx package only (for dev iteration) |
| 126 | +build-npx: |
| 127 | + @cd npx && npm install && npm run build |
| 128 | + |
| 129 | +# Run local dev mode (not bundled) |
| 130 | +dev: |
| 131 | + @cd npx && node dist/index.js review --url $(URL) -q "$(Q)" |
| 132 | + |
| 133 | +# ============================================================ |
| 134 | +# Release Workflow |
| 135 | +# ============================================================ |
| 136 | + |
| 137 | +# Full release: bump, commit, tag, push (triggers CI/CD for runtime builds) |
| 138 | +release-patch: bump-patch release-commit |
| 139 | +release-minor: bump-minor release-commit |
| 140 | +release-major: bump-major release-commit |
| 141 | + |
| 142 | +release-commit: $(VERSION_FILE) |
| 143 | + @echo "==> Creating release v$$(cat $(VERSION_FILE))" |
| 144 | + @git add VERSION npx/package.json |
| 145 | + @git commit -m "Release v$$(cat $(VERSION_FILE))" |
| 146 | + @git tag v$$(cat $(VERSION_FILE)) |
| 147 | + @echo "==> Pushing to trigger CI/CD..." |
| 148 | + @git push origin main --tags |
| 149 | + @echo "==> Release v$$(cat $(VERSION_FILE)) triggered!" |
| 150 | + @echo " Monitor: https://github.com/AsyncFuncAI/AsyncReview/actions" |
| 151 | + @echo "" |
| 152 | + @echo " After CI/CD completes, run: make publish-npm" |
| 153 | + |
| 154 | +# ============================================================ |
| 155 | +# npm Publishing (Local Control) |
| 156 | +# ============================================================ |
| 157 | + |
| 158 | +# Publish thin wrapper to npm (run this locally after CI/CD completes) |
| 159 | +publish-npm: $(VERSION_FILE) |
| 160 | + @echo "==> Publishing asyncreview@$(VERSION) to npm" |
| 161 | + @cd npx && npm version $(VERSION) --no-git-tag-version --allow-same-version |
| 162 | + @cd npx && npm run build |
| 163 | + @echo "==> Dry run first..." |
| 164 | + @cd npx && npm publish --dry-run |
| 165 | + @echo "" |
| 166 | + @read -p "Publish to npm? [y/N] " confirm && [ "$$confirm" = "y" ] || exit 1 |
| 167 | + @cd npx && npm publish --access public |
| 168 | + @echo "==> Published: https://www.npmjs.com/package/asyncreview" |
| 169 | + |
| 170 | +# Show help |
| 171 | +help: |
| 172 | + @echo "AsyncReview Runtime Build System" |
| 173 | + @echo "" |
| 174 | + @echo "Build Commands:" |
| 175 | + @echo " make build - Build runtime v$(VERSION) for $(PLATFORM)" |
| 176 | + @echo " make install - Install built runtime locally" |
| 177 | + @echo " make test - Test installed runtime" |
| 178 | + @echo " make quick - Build + install + test" |
| 179 | + @echo " make clean - Remove build artifacts" |
| 180 | + @echo "" |
| 181 | + @echo "Version Commands:" |
| 182 | + @echo " make version - Show current version" |
| 183 | + @echo " make bump-patch - Bump patch ($(VERSION) -> next patch)" |
| 184 | + @echo " make bump-minor - Bump minor version" |
| 185 | + @echo " make bump-major - Bump major version" |
| 186 | + @echo "" |
| 187 | + @echo "Release Commands:" |
| 188 | + @echo " make release-patch - Bump, commit, tag, push (triggers CI/CD)" |
| 189 | + @echo " make release-minor - Bump minor, triggers CI/CD" |
| 190 | + @echo " make release-major - Bump major, triggers CI/CD" |
| 191 | + @echo " make publish-npm - Publish thin wrapper to npm (local)" |
| 192 | + @echo "" |
| 193 | + @echo "Manual GitHub Release Commands:" |
| 194 | + @echo " make publish - Create GitHub release with local artifact" |
| 195 | + @echo " make publish-update - Add artifact to existing release" |
| 196 | + @echo "" |
| 197 | + @echo "Dev Commands:" |
| 198 | + @echo " make build-npx - Build TypeScript only" |
| 199 | + @echo " make dev URL=... Q=... - Run dev mode" |
| 200 | + |
0 commit comments