Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test-macos:
name: Test on macOS
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check Swift version
run: swift --version

- name: Build
run: swift build

- name: Run tests
run: swift test

- name: Build CLI
run: swift build -c release

test-linux:
name: Test on Linux
runs-on: ubuntu-latest
container:
image: swift:5.9
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
apt-get update
apt-get install -y libsodium-dev

- name: Check Swift version
run: swift --version

- name: Build
run: swift build

- name: Run tests
run: swift test

- name: Build CLI
run: swift build -c release
126 changes: 126 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
build-macos:
name: Build macOS Universal Binary
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check Swift version
run: swift --version

- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Run tests
run: swift test

- name: Build release binary
run: ./scripts/build-release.sh ${{ steps.get_version.outputs.VERSION }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: macos-universal
path: |
release/*.tar.gz
release/*.sha256

create-release:
name: Create GitHub Release
needs: [build-macos]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download macOS artifact
uses: actions/download-artifact@v4
with:
name: macos-universal
path: release/

- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Generate release notes
id: release_notes
run: |
cat > release_notes.md << 'EOF'
## Installation

### macOS (Universal Binary - x86_64 + ARM64)

Download and install:
```bash
curl -L https://github.com/${{ github.repository }}/releases/download/v${{ steps.get_version.outputs.VERSION }}/ejson-${{ steps.get_version.outputs.VERSION }}-macos-universal.tar.gz | tar xz
sudo mv ejson /usr/local/bin/
ejson --version
```

Or with wget:
```bash
wget https://github.com/${{ github.repository }}/releases/download/v${{ steps.get_version.outputs.VERSION }}/ejson-${{ steps.get_version.outputs.VERSION }}-macos-universal.tar.gz
tar xzf ejson-${{ steps.get_version.outputs.VERSION }}-macos-universal.tar.gz
sudo mv ejson /usr/local/bin/
ejson --version
```

### Verify Checksum

```bash
# Download checksum file
curl -L https://github.com/${{ github.repository }}/releases/download/v${{ steps.get_version.outputs.VERSION }}/ejson-${{ steps.get_version.outputs.VERSION }}-macos-universal.tar.gz.sha256 -o ejson.sha256

# Verify (macOS)
shasum -a 256 -c ejson.sha256

# Verify (Linux)
sha256sum -c ejson.sha256
```

## Features

- 🔐 NaCl Box encryption compatible with Shopify EJSON
- 🔄 Full compatibility with Go EJSON implementation
- ⚡ Fast and native Swift implementation
- 📦 Universal macOS binary (works on both Intel and Apple Silicon)

## Usage

```bash
# Generate a keypair
ejson keygen

# Encrypt a file
ejson encrypt secrets.json

# Decrypt a file
ejson decrypt secrets.json
```

For more information, see the [README](https://github.com/${{ github.repository }}/blob/main/README.md).
EOF

- name: Create Release
uses: softprops/action-gh-release@v2
with:
body_path: release_notes.md
files: |
release/*.tar.gz
release/*.sha256
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ playground.xcworkspace
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.build/
release/

# CocoaPods
#
Expand Down
11 changes: 5 additions & 6 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,20 @@ The library has been fully implemented with:

## Installing Swift for Testing

This project requires **Swift 6.2** or later.
This project requires **Swift 5.9** or later.

### Prerequisites

**IMPORTANT:** Install libsodium first (required for EJSONKit cryptography):
**Linux only:** Install libsodium-dev (required for EJSONKit cryptography on Linux):

```bash
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install -y libsodium-dev

# macOS (using Homebrew)
brew install libsodium
```

**macOS:** No additional dependencies needed. The swift-sodium package includes bundled libsodium (Clibsodium.xcframework) for Apple platforms.

### Option 1: Direct Download from swift.org (Recommended)

This is the most reliable method for getting Swift 6.2.1.
Expand Down Expand Up @@ -310,7 +309,7 @@ warning: Using a system installation of libsodium - This is unsupported.
Build complete! (2.00s)
```

**Note:** The warning about using system libsodium is expected and safe to ignore. The library will work correctly with the system-installed libsodium.
**Note:** On Linux, you may see a warning "Using a system installation of libsodium - This is unsupported." This is expected and safe to ignore. The library will work correctly with the system-installed libsodium. On macOS, the bundled Clibsodium.xcframework is used automatically with no warnings.

### Run the test suite
```bash
Expand Down
15 changes: 0 additions & 15 deletions Package.resolved

This file was deleted.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 6.2
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,18 +284,51 @@ EJSONKit includes a command-line tool compatible with the [Go EJSON CLI](https:/

### Installation

Build the CLI:
#### Pre-built Binaries (Recommended)

Download the latest release for your platform from [GitHub Releases](https://github.com/diogot/swift-ejson/releases):

**macOS (Universal Binary - Intel & Apple Silicon):**

```bash
swift build -c release
# Download and install the latest version
VERSION="1.0.0" # Replace with latest version
curl -L "https://github.com/diogot/swift-ejson/releases/download/v${VERSION}/ejson-${VERSION}-macos-universal.tar.gz" | tar xz
sudo mv ejson /usr/local/bin/
ejson help
```

The executable will be at `.build/release/ejson`. You can copy it to your PATH:
**Verify the checksum:**

```bash
# Download checksum
curl -L "https://github.com/diogot/swift-ejson/releases/download/v${VERSION}/ejson-${VERSION}-macos-universal.tar.gz.sha256" -o ejson.sha256

# Verify
shasum -a 256 -c ejson.sha256
```

#### Build from Source

If you prefer to build from source:

```bash
# Clone the repository
git clone https://github.com/diogot/swift-ejson.git
cd swift-ejson

# Build the CLI
swift build -c release

# Install to PATH
cp .build/release/ejson /usr/local/bin/
```

**Requirements:**
- Swift 5.9+
- Linux only: libsodium-dev (`apt-get install libsodium-dev`)
- macOS: No additional dependencies (uses bundled libsodium)

### Usage

```
Expand Down Expand Up @@ -391,12 +424,13 @@ swift test

## Dependencies

- [swift-sodium](https://github.com/jedisct1/swift-sodium) (v0.9.1+) - Provides NaCl cryptography primitives
- [swift-sodium](https://github.com/jedisct1/swift-sodium) (v0.9.1+) - Provides NaCl cryptography primitives with bundled libsodium

## Requirements

- Swift 6.2+
- Swift 5.9+
- macOS 10.15+ / iOS 13+ / tvOS 13+ / watchOS 6+
- Linux: libsodium-dev package required

## Contributing

Expand Down
Loading