Skip to content

Commit 54a3571

Browse files
committed
feat: Implement robust Python runtime environment management with Deno support and new build/release infrastructure.
1 parent 22faff2 commit 54a3571

File tree

17 files changed

+1054
-918
lines changed

17 files changed

+1054
-918
lines changed

.github/workflows/release.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# AsyncReview Release Workflow
2+
#
3+
# Triggered on version tags (v*)
4+
# Builds runtime for all platforms and publishes to GitHub Releases
5+
# (npm publishing is done locally via `make publish-npm`)
6+
7+
name: Release
8+
9+
on:
10+
push:
11+
tags:
12+
- 'v*'
13+
14+
env:
15+
NODE_VERSION: '20'
16+
PYTHON_VERSION: '3.12'
17+
DENO_VERSION: '2.6.6'
18+
19+
jobs:
20+
# Build runtime for each platform
21+
build:
22+
name: Build ${{ matrix.platform }}
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
matrix:
26+
include:
27+
- os: macos-14 # Apple Silicon
28+
platform: darwin-arm64
29+
- os: macos-13 # Intel Mac
30+
platform: darwin-x64
31+
- os: ubuntu-latest
32+
platform: linux-x64
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: ${{ env.NODE_VERSION }}
41+
42+
- name: Setup Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: ${{ env.PYTHON_VERSION }}
46+
47+
- name: Get version from tag
48+
id: version
49+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
50+
51+
- name: Build runtime
52+
run: |
53+
chmod +x scripts/build_runtime_local.sh
54+
./scripts/build_runtime_local.sh ${{ steps.version.outputs.VERSION }}
55+
56+
- name: Upload artifact
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: runtime-${{ matrix.platform }}
60+
path: dist/asyncreview-runtime-v${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.tar.gz
61+
62+
# Create GitHub Release with all platform artifacts
63+
release:
64+
name: Create Release
65+
needs: build
66+
runs-on: ubuntu-latest
67+
permissions:
68+
contents: write
69+
70+
steps:
71+
- uses: actions/checkout@v4
72+
73+
- name: Get version from tag
74+
id: version
75+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
76+
77+
- name: Download all artifacts
78+
uses: actions/download-artifact@v4
79+
with:
80+
path: dist
81+
pattern: runtime-*
82+
merge-multiple: true
83+
84+
- name: List artifacts
85+
run: ls -la dist/
86+
87+
- name: Create GitHub Release
88+
uses: softprops/action-gh-release@v1
89+
with:
90+
name: AsyncReview v${{ steps.version.outputs.VERSION }}
91+
body: |
92+
## AsyncReview v${{ steps.version.outputs.VERSION }}
93+
94+
### Installation
95+
```bash
96+
npx asyncreview review --url <github-pr-url> -q "your question"
97+
```
98+
99+
### Platform Runtimes
100+
The runtime is automatically downloaded on first use. Supported platforms:
101+
- macOS (Apple Silicon) - `darwin-arm64`
102+
- macOS (Intel) - `darwin-x64`
103+
- Linux (x64) - `linux-x64`
104+
105+
### Manual Download
106+
If you prefer to install manually, download the appropriate tarball for your platform.
107+
108+
---
109+
110+
**Note:** After GitHub Release is created, publish to npm locally with:
111+
```bash
112+
make publish-npm
113+
```
114+
files: dist/*.tar.gz
115+
fail_on_unmatched_files: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ wheels/
1919
*.egg-info/
2020
.installed.cfg
2121
*.egg
22+
.runtime_stage/
2223

2324
# Virtual environments
2425
.venv/

Makefile

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
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+

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.5.1

0 commit comments

Comments
 (0)