-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from HarborWallet/macos-build
build for macos
- Loading branch information
Showing
8 changed files
with
223 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'" |