|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Auto Release Script |
| 4 | +# This script automates the release process for json-joy without human prompts |
| 5 | +# It uses version-bump.sh to determine the appropriate version bump |
| 6 | +# Usage: ./scripts/auto-release.sh |
| 7 | + |
| 8 | +set -e # Exit immediately if a command exits with a non-zero status |
| 9 | + |
| 10 | +# Color codes for output |
| 11 | +RED='\033[0;31m' |
| 12 | +GREEN='\033[0;32m' |
| 13 | +YELLOW='\033[1;33m' |
| 14 | +NC='\033[0m' # No Color |
| 15 | + |
| 16 | +echo -e "${GREEN}Starting automatic release process...${NC}\n" |
| 17 | + |
| 18 | +# Step 1: Verify code quality and correctness |
| 19 | +echo -e "${YELLOW}Step 1: Verifying code quality and correctness...${NC}" |
| 20 | +echo "Running lint..." |
| 21 | +yarn lint |
| 22 | + |
| 23 | +echo "Running format check..." |
| 24 | +yarn format |
| 25 | + |
| 26 | +echo "Running typecheck..." |
| 27 | +yarn typecheck |
| 28 | + |
| 29 | +echo "Running tests..." |
| 30 | +yarn test |
| 31 | + |
| 32 | +echo "Generating typedoc..." |
| 33 | +yarn typedoc |
| 34 | + |
| 35 | +echo -e "${GREEN}✓ Code quality verification completed${NC}\n" |
| 36 | + |
| 37 | +# Step 2: Prepare for release |
| 38 | +echo -e "${YELLOW}Step 2: Preparing for release...${NC}" |
| 39 | +echo "Cleaning..." |
| 40 | +yarn clean |
| 41 | + |
| 42 | +echo "Building..." |
| 43 | +yarn build |
| 44 | + |
| 45 | +echo -e "${GREEN}✓ Build completed${NC}\n" |
| 46 | + |
| 47 | +# Determine version bump from commit messages |
| 48 | +echo -e "${YELLOW}Determining version bump from commit messages...${NC}" |
| 49 | +VERSION_BUMP=$(./scripts/version-bump.sh) |
| 50 | + |
| 51 | +echo "Detected version bump: ${VERSION_BUMP}" |
| 52 | + |
| 53 | +# If no-bump, abort the release but exit with success |
| 54 | +if [ "$VERSION_BUMP" = "no-bump" ]; then |
| 55 | + echo -e "${YELLOW}No significant changes detected. Skipping release.${NC}" |
| 56 | + exit 0 |
| 57 | +fi |
| 58 | + |
| 59 | +echo -e "${GREEN}✓ Version bump determined: ${VERSION_BUMP}${NC}\n" |
| 60 | + |
| 61 | +# Step 3: Update version in root package.json |
| 62 | +echo -e "${YELLOW}Step 3: Updating version in root package.json...${NC}" |
| 63 | +npm version --allow-same-version --no-git-tag-version "${VERSION_BUMP}" |
| 64 | + |
| 65 | +NEW_VERSION=$(node -p "require('./package.json').version") |
| 66 | +echo -e "${GREEN}✓ Version updated to ${NEW_VERSION}${NC}\n" |
| 67 | + |
| 68 | +# Step 4: Synchronize versions across all packages |
| 69 | +echo -e "${YELLOW}Step 4: Synchronizing versions across all packages...${NC}" |
| 70 | +./scripts/sync-versions.ts |
| 71 | + |
| 72 | +echo -e "${GREEN}✓ Versions synchronized${NC}\n" |
| 73 | + |
| 74 | +# Step 5: Publish to NPM |
| 75 | +echo -e "${YELLOW}Step 5: Publishing to NPM...${NC}" |
| 76 | +yarn workspaces foreach -A --no-private npm publish |
| 77 | + |
| 78 | +echo -e "${GREEN}✓ Published to NPM${NC}\n" |
| 79 | + |
| 80 | +# Step 6: Create Git tag and push to remote |
| 81 | +echo -e "${YELLOW}Step 6: Creating Git tag and pushing to remote...${NC}" |
| 82 | +git add . |
| 83 | +git commit -m "chore: release v${NEW_VERSION}" |
| 84 | +git tag "v${NEW_VERSION}" |
| 85 | +git push origin --tags |
| 86 | + |
| 87 | +echo -e "${GREEN}✓ Git tag created and pushed${NC}\n" |
| 88 | + |
| 89 | +echo -e "${GREEN}🎉 Release v${NEW_VERSION} completed successfully!${NC}" |
0 commit comments