Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build for macos #140

Merged
merged 2 commits into from
Jan 31, 2025
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
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: "Release"

on:
workflow_dispatch:
inputs:
tag:
description: "Specify tag to create"
required: true

jobs:
build:
name: Build
strategy:
matrix:
target:
- target: macos
os: macos-latest
make: bash scripts/build-macos.sh
package: bash scripts/package-macos.sh
runs-on: ${{ matrix.target.os }}
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Build
run: ${{ matrix.target.make }}

- name: Package DMG
run: ${{ matrix.target.package }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target.target }}
path: target/release/macos/harbor.dmg

create-release:
needs: build
name: Create Release
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Create Release
id: create-release
uses: actions/create-release@v1
with:
tag_name: ${{ github.event.inputs.tag }}
release_name: ${{ github.event.inputs.tag }}
draft: true
prerelease: false

add-assets:
needs: create-release
name: Add Assets

strategy:
matrix:
target:
- artifact: macos
asset_type: application/x-apple-diskimage

runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.target.artifact }}
path: ${{ matrix.target.artifact }}

- name: Upload asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./${{ matrix.target.artifact }}/harbor.dmg
asset_name: harbor.dmg
asset_content_type: ${{ matrix.target.asset_type }}
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ just release
```
**NOTE**: The first password you type in the box is saved as your password. There will be a proper onboarding workflow in the future.

### Building for macOS

To create a macOS app bundle:

1. Make sure you're in the nix develop shell:
```
nix develop
```

2. Run the macOS build script:
```
chmod +x scripts/build-macos.sh
./scripts/build-macos.sh
```

This will create a Harbor.app bundle in `target/release/macos/`. You can then move this app to your Applications folder or run it directly.

Note: The build script will compile Harbor for Apple Silicon (M1/M2/M3) Macs. Intel Mac support can be added if needed.

#### Database Changes
Reset local DB (for init, schema generation, etc.)

Expand Down
4 changes: 2 additions & 2 deletions harbor-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,15 +462,15 @@ impl HarborCore {
) -> anyhow::Result<ClientConfig> {
let download = Instant::now();
let config = {
#[cfg(all(debug_assertions, feature = "disable-tor"))]
#[cfg(feature = "disable-tor")]
let config = fedimint_api_client::api::net::Connector::Tcp
.download_from_invite_code(&invite_code)
.await
.map_err(|e| {
error!("Could not download federation info: {e}");
e
})?;
#[cfg(all(debug_assertions, not(feature = "disable-tor")))]
#[cfg(not(feature = "disable-tor"))]
let config = fedimint_api_client::api::net::Connector::Tor
.download_from_invite_code(&invite_code)
.await
Expand Down
Binary file added harbor-ui/assets/harbor_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions harbor-ui/assets/macos/Harbor.app/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>harbor</string>
<key>CFBundleIdentifier</key>
<string>cash.harbor.harbor</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Harbor</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>8a1cd00-dirty</string>
<key>CFBundleIconFile</key>
<string>harbor.icns</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSMainNibFile</key>
<string></string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>CFBundleDisplayName</key>
<string>Harbor</string>
<key>NSRequiresAquaSystemAppearance</key>
<string>NO</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Harbor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>lightning</string>
</array>
</dict>
</array>
</dict>
</plist>
Binary file not shown.
49 changes: 49 additions & 0 deletions scripts/build-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

set -e # Exit on error

TARGET="harbor-ui"
ASSETS_DIR="harbor-ui/assets"
RELEASE_DIR="target/release"
APP_NAME="Harbor.app"
APP_TEMPLATE="$ASSETS_DIR/macos/$APP_NAME"
APP_TEMPLATE_PLIST="$APP_TEMPLATE/Contents/Info.plist"
APP_DIR="$RELEASE_DIR/macos"
APP_BINARY="$RELEASE_DIR/$TARGET"
APP_BINARY_DIR="$APP_DIR/$APP_NAME/Contents/MacOS"
APP_EXTRAS_DIR="$APP_DIR/$APP_NAME/Contents/Resources"

DMG_NAME="harbor.dmg"
DMG_DIR="$RELEASE_DIR/macos"

# Get version from Cargo.toml
VERSION=$(grep -m1 '^version = ' harbor-ui/Cargo.toml | cut -d '"' -f2)
BUILD=$(git describe --always --dirty --exclude='*')

# Create a temporary copy of the Info.plist
cp "$APP_TEMPLATE_PLIST" "$APP_TEMPLATE_PLIST.tmp"

# Update version and build in the temporary file
sed -i.bak "s/{{ VERSION }}/$VERSION/g" "$APP_TEMPLATE_PLIST.tmp"
sed -i.bak "s/{{ BUILD }}/$BUILD/g" "$APP_TEMPLATE_PLIST.tmp"

# Move the temporary file back
mv "$APP_TEMPLATE_PLIST.tmp" "$APP_TEMPLATE_PLIST"
rm -f "$APP_TEMPLATE_PLIST.tmp.bak"

# build binary
export MACOSX_DEPLOYMENT_TARGET="11.0"

echo "Building Harbor for Apple Silicon..."
cd harbor-ui
cargo build --release --target=aarch64-apple-darwin --features vendored
cd ..

echo "Creating app bundle..."
# build app
mkdir -p "$APP_BINARY_DIR"
mkdir -p "$APP_EXTRAS_DIR"
cp -fRp "$APP_TEMPLATE" "$APP_DIR"
cp -fp "target/aarch64-apple-darwin/release/$TARGET" "$APP_BINARY_DIR/harbor"
touch -r "target/aarch64-apple-darwin/release/$TARGET" "$APP_DIR/$APP_NAME"
echo "✨ Created '$APP_NAME' in '$APP_DIR'"
15 changes: 15 additions & 0 deletions scripts/package-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e # Exit on error

RELEASE_DIR="target/release"
APP_DIR="$RELEASE_DIR/macos"
APP_NAME="Harbor.app"
DMG_NAME="harbor.dmg"
DMG_DIR="$RELEASE_DIR/macos"

# package dmg
echo "Packing disk image..."
ln -sf /Applications "$DMG_DIR/Applications"
hdiutil create "$DMG_DIR/$DMG_NAME" -volname "Harbor" -fs HFS+ -srcfolder "$APP_DIR" -ov -format UDZO
echo "✨ Packed '$APP_NAME' in '$DMG_DIR/$DMG_NAME'"
Loading