diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c389fca --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} \ No newline at end of file diff --git a/README.md b/README.md index 2d0361a..8186fb8 100644 --- a/README.md +++ b/README.md @@ -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.) diff --git a/harbor-client/src/lib.rs b/harbor-client/src/lib.rs index f1ab6f7..615dcd0 100644 --- a/harbor-client/src/lib.rs +++ b/harbor-client/src/lib.rs @@ -462,7 +462,7 @@ impl HarborCore { ) -> anyhow::Result { 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 @@ -470,7 +470,7 @@ impl HarborCore { 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 diff --git a/harbor-ui/assets/harbor_icon.png b/harbor-ui/assets/harbor_icon.png new file mode 100644 index 0000000..b40272f Binary files /dev/null and b/harbor-ui/assets/harbor_icon.png differ diff --git a/harbor-ui/assets/macos/Harbor.app/Contents/Info.plist b/harbor-ui/assets/macos/Harbor.app/Contents/Info.plist new file mode 100644 index 0000000..803ee7a --- /dev/null +++ b/harbor-ui/assets/macos/Harbor.app/Contents/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + harbor + CFBundleIdentifier + cash.harbor.harbor + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Harbor + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.1.0 + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 8a1cd00-dirty + CFBundleIconFile + harbor.icns + NSHighResolutionCapable + + NSMainNibFile + + NSSupportsAutomaticGraphicsSwitching + + CFBundleDisplayName + Harbor + NSRequiresAquaSystemAppearance + NO + CFBundleURLTypes + + + CFBundleURLName + Harbor + CFBundleURLSchemes + + lightning + + + + + diff --git a/harbor-ui/assets/macos/Harbor.app/Contents/Resources/harbor.icns b/harbor-ui/assets/macos/Harbor.app/Contents/Resources/harbor.icns new file mode 100644 index 0000000..6d09b2d Binary files /dev/null and b/harbor-ui/assets/macos/Harbor.app/Contents/Resources/harbor.icns differ diff --git a/scripts/build-macos.sh b/scripts/build-macos.sh new file mode 100755 index 0000000..24fe941 --- /dev/null +++ b/scripts/build-macos.sh @@ -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'" diff --git a/scripts/package-macos.sh b/scripts/package-macos.sh new file mode 100755 index 0000000..d698f44 --- /dev/null +++ b/scripts/package-macos.sh @@ -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'" \ No newline at end of file