Skip to content

fix: sync encryption key across devices to enable cross-device decrypt #32

fix: sync encryption key across devices to enable cross-device decrypt

fix: sync encryption key across devices to enable cross-device decrypt #32

Workflow file for this run

name: CI Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --workspace
- run: cargo clippy --workspace -- -D warnings
build-desktop:
name: Desktop ${{ matrix.name }}
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: linux-x64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: hostsync
cross: false
- name: linux-arm64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact: hostsync
cross: true
- name: windows-x64
os: windows-latest
target: x86_64-pc-windows-msvc
artifact: hostsync.exe
cross: false
- name: windows-arm64
os: windows-latest
target: aarch64-pc-windows-msvc
artifact: hostsync.exe
cross: false
- name: macos-x64
os: macos-latest
target: x86_64-apple-darwin
artifact: hostsync
cross: false
- name: macos-arm64
os: macos-latest
target: aarch64-apple-darwin
artifact: hostsync
cross: false
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.cross
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
- name: Build
run: cargo build --release --target ${{ matrix.target }} -p hostsync-desktop
- name: Strip (Unix)
if: runner.os != 'Windows' && !matrix.cross
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact }}
- name: Strip (Linux cross)
if: matrix.cross
run: aarch64-linux-gnu-strip target/${{ matrix.target }}/release/${{ matrix.artifact }}
- name: Create macOS .app bundle
if: runner.os == 'macOS'
run: |
APP="HostSync.app"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp target/${{ matrix.target }}/release/${{ matrix.artifact }} "$APP/Contents/MacOS/hostsync"
cp crates/hostsync-desktop/Info.plist "$APP/Contents/"
codesign --force --deep -s - "$APP"
- name: Create macOS .dmg
if: runner.os == 'macOS'
run: |
mkdir -p dmg-staging
cp -r HostSync.app dmg-staging/
ln -s /Applications dmg-staging/Applications
hdiutil create -volname "HostSync" -srcfolder dmg-staging -ov -format UDZO "HostSync-${{ matrix.name }}.dmg"
- uses: actions/upload-artifact@v4
if: runner.os == 'macOS'
with:
name: hostsync-${{ matrix.name }}
path: HostSync-${{ matrix.name }}.dmg
- uses: actions/upload-artifact@v4
if: runner.os != 'macOS'
with:
name: hostsync-${{ matrix.name }}
path: target/${{ matrix.target }}/release/${{ matrix.artifact }}
build-android:
name: Android APK
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Build Rust .so for all Android ABIs
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android,i686-linux-android
- uses: Swatinem/rust-cache@v2
with:
key: android
- run: cargo install cargo-ndk
- name: Build Rust native libraries
run: cargo ndk -t arm64-v8a -t armeabi-v7a -t x86_64 -t x86 -o mobile/android/app/src/main/jniLibs build --release -p hostsync-core
# Build APK with Gradle
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build APK
working-directory: mobile/android
run: |
# Ensure debug keystore exists for signing
mkdir -p ~/.android
if [ ! -f ~/.android/debug.keystore ]; then
keytool -genkey -v -keystore ~/.android/debug.keystore \
-storepass android -alias androiddebugkey -keypass android \
-keyalg RSA -keysize 2048 -validity 10000 \
-dname "CN=Android Debug,O=Android,C=US"
fi
gradle assembleRelease --no-daemon
- name: Rename APK
run: |
mv mobile/android/app/build/outputs/apk/release/app-release.apk HostSync.apk 2>/dev/null || \
mv mobile/android/app/build/outputs/apk/release/app-release-unsigned.apk HostSync.apk
- uses: actions/upload-artifact@v4
with:
name: android-apk
path: HostSync.apk
build-ios:
name: iOS IPA
needs: test
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
# Build Rust .a for iOS
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-ios
- uses: Swatinem/rust-cache@v2
with:
key: ios
- name: Build Rust static libraries
run: |
cargo build --release --target aarch64-apple-ios -p hostsync-core
cargo build --release --target aarch64-apple-ios-sim -p hostsync-core
cargo build --release --target x86_64-apple-ios -p hostsync-core
# Copy device .a into Xcode project directory
- name: Place static library
run: cp target/aarch64-apple-ios/release/libhostsync_core.a mobile/ios/
# Build with xcodebuild (no codesign)
- name: Build iOS app
working-directory: mobile/ios
run: |
xcodebuild -project HostSync.xcodeproj \
-scheme HostSync \
-configuration Release \
-sdk iphoneos \
-archivePath build/HostSync.xcarchive \
archive \
CODE_SIGN_IDENTITY="-" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO
# Package IPA
- name: Create IPA
run: |
cd mobile/ios/build/HostSync.xcarchive/Products/Applications
mkdir Payload
cp -r HostSync.app Payload/
zip -r ../../../../HostSync.ipa Payload
- uses: actions/upload-artifact@v4
with:
name: ios-ipa
path: mobile/ios/HostSync.ipa
# Also upload universal sim lib for developers
- name: Create universal sim library
run: |
lipo -create \
target/aarch64-apple-ios-sim/release/libhostsync_core.a \
target/x86_64-apple-ios/release/libhostsync_core.a \
-output libhostsync_core-ios-sim-universal.a
- uses: actions/upload-artifact@v4
with:
name: ios-sim-universal
path: libhostsync_core-ios-sim-universal.a
pre-release:
name: Pre-release
needs: [build-desktop, build-android, build-ios]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate tag
id: tag
run: echo "tag=nightly-$(date +'%Y%m%d-%H%M%S')" >> "$GITHUB_OUTPUT"
- name: Package artifacts
run: |
cd artifacts
for dir in hostsync-linux-*; do
[ -d "$dir" ] && chmod +x "$dir/hostsync" && tar czf "${dir}.tar.gz" -C "$dir" hostsync
done
for dir in hostsync-windows-*; do
[ -d "$dir" ] && (cd "$dir" && zip "../${dir}.zip" hostsync.exe)
done
- name: Create Pre-release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: "Pre-release ${{ steps.tag.outputs.tag }}"
prerelease: true
generate_release_notes: true
files: |
artifacts/hostsync-linux-x64.tar.gz
artifacts/hostsync-linux-arm64.tar.gz
artifacts/hostsync-windows-x64.zip
artifacts/hostsync-windows-arm64.zip
artifacts/hostsync-macos-x64/HostSync-macos-x64.dmg
artifacts/hostsync-macos-arm64/HostSync-macos-arm64.dmg
artifacts/android-apk/HostSync.apk
artifacts/ios-ipa/HostSync.ipa