Skip to content

Make binary available for installation#7

Closed
diogot wants to merge 3 commits intomainfrom
claude/binary-installation-setup-01Y2zcKo2ud6MRBhnXEKPBfr
Closed

Make binary available for installation#7
diogot wants to merge 3 commits intomainfrom
claude/binary-installation-setup-01Y2zcKo2ud6MRBhnXEKPBfr

Conversation

@diogot
Copy link
Owner

@diogot diogot commented Nov 19, 2025

This commit adds comprehensive Homebrew support for installing the ejson CLI:

Changes Made:

  1. Added --version flag to CLI (Sources/ejson/main.swift)

    • Responds to -v, --version, and version commands
    • Prints version and compatibility information
  2. Created Homebrew formula (Formula/ejson.rb)

    • Installs pre-built universal macOS binaries
    • Includes comprehensive tests (version, help, keygen)
    • Provides helpful caveats for first-time users
    • Supports both Intel and Apple Silicon
  3. Created Homebrew documentation (HOMEBREW.md)

    • Installation instructions for users
    • Tap setup guide for maintainers
    • Formula update procedures
    • Troubleshooting section
  4. Created formula update script (scripts/update-formula.sh)

    • Automates SHA256 checksum updates
    • Downloads and verifies releases
    • Updates version and URLs automatically
    • Provides clear instructions for committing
  5. Updated README.md

    • Added Homebrew as recommended installation method
    • Includes both tap and direct installation options
    • Links to detailed Homebrew documentation
  6. Updated RELEASING.md

    • Added post-release Homebrew formula update steps
    • Documents both in-repo and separate tap workflows

Installation Methods:

Users can now install ejson via:

  • brew tap diogot/ejson && brew install ejson (via tap)
  • brew install https://raw.githubusercontent.com/diogot/swift-ejson/main/Formula/ejson.rb (direct)
  • Traditional binary download (still supported)
  • Build from source (still supported)

Next Steps:

After the first release (v1.0.0):

  1. Run ./scripts/update-formula.sh 1.0.0 to update SHA256
  2. Commit and push the updated formula
  3. Optionally create a separate tap repository (diogot/homebrew-ejson)

This commit adds comprehensive Homebrew support for installing the ejson CLI:

## Changes Made:

1. **Added --version flag to CLI** (Sources/ejson/main.swift)
   - Responds to -v, --version, and version commands
   - Prints version and compatibility information

2. **Created Homebrew formula** (Formula/ejson.rb)
   - Installs pre-built universal macOS binaries
   - Includes comprehensive tests (version, help, keygen)
   - Provides helpful caveats for first-time users
   - Supports both Intel and Apple Silicon

3. **Created Homebrew documentation** (HOMEBREW.md)
   - Installation instructions for users
   - Tap setup guide for maintainers
   - Formula update procedures
   - Troubleshooting section

4. **Created formula update script** (scripts/update-formula.sh)
   - Automates SHA256 checksum updates
   - Downloads and verifies releases
   - Updates version and URLs automatically
   - Provides clear instructions for committing

5. **Updated README.md**
   - Added Homebrew as recommended installation method
   - Includes both tap and direct installation options
   - Links to detailed Homebrew documentation

6. **Updated RELEASING.md**
   - Added post-release Homebrew formula update steps
   - Documents both in-repo and separate tap workflows

## Installation Methods:

Users can now install ejson via:
- `brew tap diogot/ejson && brew install ejson` (via tap)
- `brew install https://raw.githubusercontent.com/diogot/swift-ejson/main/Formula/ejson.rb` (direct)
- Traditional binary download (still supported)
- Build from source (still supported)

## Next Steps:

After the first release (v1.0.0):
1. Run `./scripts/update-formula.sh 1.0.0` to update SHA256
2. Commit and push the updated formula
3. Optionally create a separate tap repository (diogot/homebrew-ejson)
This commit establishes a single source of truth for version management and
automates the entire release process via GitHub Actions.

## Version Management

**Single Source of Truth:**
- Version is now defined in `Sources/EJSONKit/Version.swift`
- All components (binary, releases, tags, formula) sync from this file
- No more version drift between components

**Created Files:**
- `Sources/EJSONKit/Version.swift` - Central version definition
- `scripts/get-version.sh` - Extracts version from code
- `VERSION_MANAGEMENT.md` - Comprehensive documentation

## Automated Release Workflow

**New Manual Workflow** (`.github/workflows/create-release.yml`):
- Trigger: Manual dispatch (requires typing "release" to confirm)
- Process:
  1. Extracts version from Version.swift
  2. Validates format and checks if tag exists
  3. Runs all tests
  4. Builds universal macOS binary
  5. Creates and pushes git tag
  6. Creates GitHub release with binaries
  7. **Automatically updates Homebrew formula with SHA256**
  8. Commits updated formula back to main
- Everything is automated - no manual SHA256 calculation needed

**Updated Existing Workflow** (`.github/workflows/release.yml`):
- Renamed to "Release (Tag-based)" for clarity
- Kept for backward compatibility
- Now serves as fallback if manual workflow is unavailable

## CLI Changes

**Updated Binary** (`Sources/ejson/main.swift`):
- Now imports version from EJSONKit.Version
- Responds to `--version`, `-v`, and `version` commands
- Prints: "ejson version 1.0.0"

## Documentation Updates

**RELEASING.md:**
- Completely rewritten for automated workflow
- New recommended process: Update Version.swift → Trigger workflow → Done
- Added version synchronization table
- Manual process documented as alternative

**HOMEBREW.md:**
- Added section on automated formula updates
- Explains version management
- Manual update process for edge cases

**README.md:**
- Added "Version Management" section
- Links to VERSION_MANAGEMENT.md
- Updated contributing guidelines

**VERSION_MANAGEMENT.md (NEW):**
- Complete guide to version management
- How version syncing works
- Benefits and validation
- Instructions for contributors and maintainers

## Release Process

**Before this commit:**
1. Manually update version in multiple places
2. Create and push tag
3. Wait for build
4. Download binary, calculate SHA256
5. Manually update Homebrew formula
6. Commit formula changes

**After this commit:**
1. Edit `Sources/EJSONKit/Version.swift`
2. Commit and push
3. Click "Run workflow" on GitHub Actions
4. Type "release" to confirm
5. Done! Everything automated.

## Benefits

1. ✅ **No version drift** - Single source ensures consistency
2. ✅ **Fully automated** - One-click releases
3. ✅ **Validated** - Prevents duplicate tags, invalid versions
4. ✅ **SHA256 auto-calculated** - No manual checksum work
5. ✅ **Formula auto-updated** - Committed back to main
6. ✅ **Traceable** - Version changes visible in git history
7. ✅ **Error-proof** - Workflow validates everything

## Version Synchronization

| Component           | Source                        | Method               |
|---------------------|-------------------------------|----------------------|
| Library Version     | Version.swift                 | Direct definition    |
| Binary Version      | CLI --version                 | Import from EJSONKit |
| Git Tag             | GitHub Actions                | Extract from code    |
| GitHub Release      | GitHub Actions                | Uses git tag         |
| Homebrew Formula    | Auto-updated by workflow      | SHA256 calculated    |

## Testing

To test the version extraction:
```bash
./scripts/get-version.sh  # Returns: 1.0.0
```

To test the binary version (after building):
```bash
swift build
.build/debug/ejson --version  # Returns: ejson version 1.0.0
```

## Next Steps

After merging to main, create the first release:
1. Go to: https://github.com/diogot/swift-ejson/actions/workflows/create-release.yml
2. Click "Run workflow"
3. Type "release" to confirm
4. Monitor the automated process
5. Verify release and formula were created/updated

This establishes the foundation for streamlined, automated releases going forward.
@diogot diogot closed this Nov 19, 2025
@diogot diogot deleted the claude/binary-installation-setup-01Y2zcKo2ud6MRBhnXEKPBfr branch November 19, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants