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

Linux package #189

Merged
merged 2 commits into from
Feb 24, 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
73 changes: 59 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@ permissions:
contents: write

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 }}
build-mac:
name: Build MacOS
runs-on: macos
environment: signing
steps:
- uses: actions/checkout@v4
Expand All @@ -37,10 +30,9 @@ jobs:
env-vars: CARGO USE_VENDOR_FEATURE

- name: Build
run: nix develop --command bash -c "${{ matrix.target.make }}"
run: nix develop --command bash -c "bash scripts/build-macos.sh"

- name: Sign macOS
if: matrix.target.target == 'macos'
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
Expand All @@ -52,7 +44,7 @@ jobs:
run: nix develop --command bash -c "scripts/sign-macos.sh"

- name: Package DMG
run: nix develop --command bash -c "${{ matrix.target.package }}"
run: nix develop --command bash -c "bash scripts/package-macos.sh"

- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2
Expand All @@ -62,4 +54,57 @@ jobs:
draft: true
prerelease: false
generate_release_notes: true
files: target/release/macos/harbor.dmg
files: target/release/macos/harbor.dmg
build-linux:
name: Build linux
runs-on: ubuntu-22.04
environment: signing
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
env-vars: CARGO USE_VENDOR_FEATURE

- name: Install linux deps
if: matrix.target.target == 'linux'
run: |
sudo apt update
sudo apt install \
build-essential \
git \
dpkg \
pkg-config \
libdbus-1-dev \
libsqlcipher-dev \
libudev-dev \
libxkbcommon-dev \
libfontconfig1-dev \
libasound2-dev

- name: Build
run: bash scripts/package-linux.sh package

- name: Set artifact path
run: |
echo "ARTIFACT_PATH=$(bash scripts/package-linux.sh archive_path)" >> "$GITHUB_ENV"
echo "DEB_PATH=$(bash scripts/package-linux.sh deb_path)" >> "$GITHUB_ENV"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: linux
path: |
${{ env.ARTIFACT_PATH }}
${{ env.DEB_PATH }}

- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.event.inputs.tag || github.ref_name }}
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
draft: true
prerelease: false
generate_release_notes: true
files: |
${{ env.ARTIFACT_PATH }}
${{ env.DEB_PATH }}
7 changes: 7 additions & 0 deletions harbor-ui/assets/harbor_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added harbor-ui/assets/harbor_icon_512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions harbor-ui/assets/linux/cash.harbor.harbor.appdata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<content_rating type="oars-1.1">
</content_rating>
<id>cash.harbor.harbor</id>
<metadata_license>MIT</metadata_license>
<project_license>MIT</project_license>
<name>Harbor</name>
<summary>Harbor is an ecash desktop wallet for better bitcoin privacy.</summary>
<description>
<p>
Harbor is an ecash desktop wallet for better bitcoin privacy. Use this tool to interact with ecash mints,
moving money in and out using existing Bitcoin wallets. As you use mints, you may be able to increase the
privacy of your money. Harbor also aims to demystify ecash mints for users and make them easier to use.
</p>
</description>
<launchable type="desktop-id">cash.harbor.harbor.desktop</launchable>
<url type="homepage">Harbor.cash</url>
<url type="bugtracker">https://github.com/HarborWallet/harbor/issues</url>
<screenshots>
<screenshot type="default">
<caption>harbor logo</caption>
<image>
https://camo.githubusercontent.com/36432bbea8022f7f873a7e5fcf983ed4e3a84a8764be44b5eb2ab5e9056cbaf4/68747470733a2f2f626c6f672e6d7574696e7977616c6c65742e636f6d2f636f6e74656e742f696d616765732f73697a652f77323030302f323032342f30352f686172626f722d707265766965772e6a706567
</image>
</screenshot>
</screenshots>
<developer_name>Harbor Wallet Devs</developer_name>
<releases>
<release version="0.2.0"
date="2025-02-14"/>
</releases>
</component>
10 changes: 10 additions & 0 deletions harbor-ui/assets/linux/cash.harbor.harbor.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Name=Habor
Comment=Fedimint ecash desktop wallet for better bitcoin privacy
Type=Application
Keywords=bitcoin;lightning;ecash;privacy;tor;fedimint;
Categories=Office;Finance;
Exec=harbor-ui %U
Icon=cash.harbor.harbor
StartupWMClass=cash.harbor.harbor
Terminal=false
119 changes: 119 additions & 0 deletions scripts/package-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/bash
set -e # Exit on any error

TARGET="harbor-ui"
ARCH="amd64" # Debian uses amd64 instead of x86_64
RELEASE_DIR="target/release"
ASSETS_DIR="harbor-ui/assets"
ARCHIVE_DIR="$RELEASE_DIR/archive"
VERSION=$(grep -m1 '^version = ' harbor-ui/Cargo.toml | cut -d '"' -f2)
ARCHIVE_NAME="$TARGET-$VERSION-$ARCH-linux.tar.gz"
ARCHIVE_PATH="$RELEASE_DIR/$ARCHIVE_NAME"
DEB_NAME="${TARGET}_${VERSION}_${ARCH}.deb"
DEB_PATH="$RELEASE_DIR/$DEB_NAME"

build() {
cargo build --release --target=x86_64-unknown-linux-gnu --features vendored -p harbor-ui
}

archive_name() {
echo $ARCHIVE_NAME
}

archive_path() {
echo $ARCHIVE_PATH
}

deb_path() {
echo $DEB_PATH
}

create_deb() {
local PACKAGE_ROOT="$RELEASE_DIR/debian"
local INSTALL_ROOT="$PACKAGE_ROOT/usr"

# Create directory structure
mkdir -p "$PACKAGE_ROOT/DEBIAN"
mkdir -p "$INSTALL_ROOT/bin"
mkdir -p "$INSTALL_ROOT/share/applications"
mkdir -p "$INSTALL_ROOT/share/metainfo"
mkdir -p "$INSTALL_ROOT/share/icons/hicolor/512x512/apps"
mkdir -p "$INSTALL_ROOT/share/icons/hicolor/scalable/apps"

# Create control file
cat > "$PACKAGE_ROOT/DEBIAN/control" << EOF
Package: harbor
Version: $VERSION
Architecture: $ARCH
Maintainer: benthecarman <[email protected]> Paul Miller <[email protected]>
Description: Harbor UI Application
Fedimint ecash desktop wallet for better bitcoin privacy
Section: utils
Priority: optional
Homepage: https://harbor.cash
Depends: libc6
EOF

# Copy application binary
install -Dm755 "target/x86_64-unknown-linux-gnu/release/$TARGET" "$INSTALL_ROOT/bin/harbor-ui"

# Install PNG icon
install -Dm644 "harbor-ui/assets/harbor_icon_512x512.png" \
"$INSTALL_ROOT/share/icons/hicolor/512x512/apps/cash.harbor.harbor.png"

# Install SVG icon
install -Dm644 "harbor-ui/assets/harbor_icon.svg" \
"$INSTALL_ROOT/share/icons/hicolor/scalable/apps/cash.harbor.harbor.svg"

# Install .desktop file
install -Dm644 "harbor-ui/assets/linux/cash.harbor.harbor.desktop" \
"$INSTALL_ROOT/share/applications/cash.harbor.harbor.desktop"

# Install AppStream metadata
install -Dm644 "harbor-ui/assets/linux/cash.harbor.harbor.appdata.xml" \
"$INSTALL_ROOT/share/metainfo/cash.harbor.harbor.appdata.xml"

# Add post-installation script to update icon cache
cat > "$PACKAGE_ROOT/DEBIAN/postinst" << 'EOF'
#!/bin/sh
set -e
if [ -x "$(command -v update-desktop-database)" ]; then
update-desktop-database -q
fi
if [ -x "$(command -v gtk-update-icon-cache)" ]; then
gtk-update-icon-cache -f -t /usr/share/icons/hicolor
fi
EOF

# Make post-installation script executable
chmod 755 "$PACKAGE_ROOT/DEBIAN/postinst"

# Build deb package
dpkg-deb --build "$PACKAGE_ROOT" "$DEB_PATH"
echo "Created Debian package: $DEB_PATH"
}

package() {
build || { echo "Build failed"; exit 1; }

# Create tar.gz archive
install -Dm755 target/x86_64-unknown-linux-gnu/release/$TARGET -t $ARCHIVE_DIR/bin
install -Dm644 $ASSETS_DIR/linux/cash.harbor.harbor.appdata.xml -t $ARCHIVE_DIR/share/metainfo
install -Dm644 $ASSETS_DIR/linux/cash.harbor.harbor.desktop -t $ARCHIVE_DIR/share/applications
cp -r $ASSETS_DIR/icons $ARCHIVE_DIR/share/
cp -fp "target/x86_64-unknown-linux-gnu/release/$TARGET" "$ARCHIVE_DIR/harbor"
tar czvf $ARCHIVE_PATH -C $ARCHIVE_DIR .

# Create deb package
create_deb
}

case "$1" in
"package") package;;
"archive_name") archive_name;;
"archive_path") archive_path;;
"deb_path") deb_path;;
*)
echo "available commands: package, archive_name, archive_path, deb_path"
;;
esac
Loading