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
33 changes: 33 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: PR Validation

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]

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

- name: Run test suite
run: swift test --filter "SubtreeTests"

linux:
name: Test on Linux
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3

- name: Run Linux test suite
run: |
docker run --rm -v "$(pwd):/workspace" -w /workspace swift:6.1 \
bash -c "swift package resolve && swift test --filter 'SubtreeTests'"
162 changes: 162 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: Build Release Artifacts

on:
release:
types: [published]

jobs:
macos:
name: Build macOS binary
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build macOS binary
run: swift build -c release --arch arm64 --arch x86_64 -Xswiftc -Osize

- name: Strip macOS binary
run: strip -rSTx .build/apple/Products/Release/subtree

- name: Test binary functionality
run: |
.build/apple/Products/Release/subtree --help
echo "✅ macOS binary responds to --help"

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: subtree_macos
path: .build/apple/Products/Release/subtree
retention-days: 5

linux:
name: Build Linux binaries
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install cross-binutils for aarch64
run: sudo apt install -y binutils-aarch64-linux-gnu

- name: Build and export binaries
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
target: output
outputs: type=local,dest=artifacts

- name: Test and organize binaries
run: |
# Test that binaries were built successfully
echo "✅ Linux AMD64 binary built: $(file artifacts/linux_amd64/subtree)"
echo "✅ Linux ARM64 binary built: $(file artifacts/linux_arm64/subtree)"

# Strip and organize AMD64 binary
strip artifacts/linux_amd64/subtree
mv artifacts/linux_amd64/subtree "${HOME}/subtree_linux"

# Strip and organize ARM64 binary
aarch64-linux-gnu-strip artifacts/linux_arm64/subtree
mv artifacts/linux_arm64/subtree "${HOME}/subtree_linux_aarch64"

- name: Upload AMD64 Artifact
uses: actions/upload-artifact@v4
with:
name: subtree_linux
path: ~/subtree_linux
retention-days: 5

- name: Upload ARM64 Artifact
uses: actions/upload-artifact@v4
with:
name: subtree_linux_aarch64
path: ~/subtree_linux_aarch64
retention-days: 5

upload:
name: Upload release artifacts
runs-on: ubuntu-20.04
needs: [macos, linux]
steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: downloaded_artifacts

- name: Display structure of downloaded files
run: ls -R downloaded_artifacts

- name: Prepare release binaries
run: |
VERSION="${{ github.event.release.tag_name }}"

# Copy and rename binaries for release upload
cp downloaded_artifacts/subtree_macos/subtree "subtree_${VERSION}_macos"
cp downloaded_artifacts/subtree_linux/subtree_linux "subtree_${VERSION}_linux_x86_64"
cp downloaded_artifacts/subtree_linux_aarch64/subtree_linux_aarch64 "subtree_${VERSION}_linux_arm64"

# Make all binaries executable
chmod +x subtree_${VERSION}_*

- name: Build artifact bundle
run: |
VERSION="${{ github.event.release.tag_name }}"
BUNDLE_DIR="subtree.artifactbundle"

mkdir -p "${BUNDLE_DIR}"

# Organize binaries by platform (universal macOS binary)
mkdir -p "${BUNDLE_DIR}/macos"
mkdir -p "${BUNDLE_DIR}/linux-x86_64"
mkdir -p "${BUNDLE_DIR}/linux-arm64"

# Copy binaries to bundle structure
cp downloaded_artifacts/subtree_macos/subtree "${BUNDLE_DIR}/macos/subtree"
cp downloaded_artifacts/subtree_linux/subtree_linux "${BUNDLE_DIR}/linux-x86_64/subtree"
cp downloaded_artifacts/subtree_linux_aarch64/subtree_linux_aarch64 "${BUNDLE_DIR}/linux-arm64/subtree"

# Create artifact bundle manifest
cat > "${BUNDLE_DIR}/artifactbundle.json" << EOF
{
"schemaVersion": "1.0",
"artifacts": {
"subtree": {
"version": "${VERSION}",
"type": "executable",
"variants": [
{
"path": "macos/subtree",
"supportedTriples": ["arm64-apple-macosx", "x86_64-apple-macosx"]
},
{
"path": "linux-x86_64/subtree",
"supportedTriples": ["x86_64-unknown-linux-gnu"]
},
{
"path": "linux-arm64/subtree",
"supportedTriples": ["aarch64-unknown-linux-gnu"]
}
]
}
}
}
EOF

# Create zip archive
zip -r "subtree.artifactbundle.zip" "${BUNDLE_DIR}"

- name: Upload release binaries
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'subtree_${{ github.event.release.tag_name }}_macos subtree_${{ github.event.release.tag_name }}_linux_x86_64 subtree_${{ github.event.release.tag_name }}_linux_arm64 subtree.artifactbundle.zip'
93 changes: 93 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

## macOS
.DS_Store

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
Packages/
Package.pins
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/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
*.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
Loading