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

dexc-desktop: Icons, deb builder and metadata fixes #2582

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 7 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

## Build and Publish Snap Package workflow

This workflow builds a `snap` package and uploads it to the [Snap Store](https://snapcraft.io/store). It has a `workflow_dispatch` trigger so it can be triggered manually only, it is not hooked up to any other GH event.

The store upload requires the `SNAPCRAFT_STORE_CREDENTIALS` variable to be set in [Github Secrets](https://github.com/decred/dcrdex/settings/secrets/actions).
See https://github.com/snapcore/action-publish for details.
48 changes: 48 additions & 0 deletions .github/workflows/build-snap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Publish Snap Package

on:
# manually trigger the workflow from the Actions tab
workflow_dispatch:

jobs:
build-snap:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 0

- name: Compile frontend
working-directory: client/webserver/site
run: |
npm install
npm run build

- name: Install deb deps
run: |
sudo apt-get update
sudo apt-get -y install libgtk-3-dev libwebkit2gtk-4.0-dev build-essential

- name: Build deb package
working-directory: client/cmd/dexc-desktop
run: pkg/pkg-debian.sh

- name: Prepare snapcraft.yml
working-directory: client/cmd/dexc-desktop
run: pkg/prepare-snap.sh

- name: Build snap package
uses: snapcore/action-build@2ee46bc29d163c9c836f2820cc46b39664bf0de2 # v1.1.3
id: build
with:
path: client/cmd/dexc-desktop

- name: Publish snap to Snap Store
uses: snapcore/action-publish@0a8d537ae06f4a292e8b4ef1084cd5631b3c6871 # v1.1.1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
with:
snap: ${{ steps.build.outputs.snap }}
release: stable
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ client/asset/eth/cmd/getgas/getgas
client/asset/eth/cmd/deploy/deploy
client/cmd/dexc-desktop/pkg/installers
server/noderelay/cmd/sourcenode/sourcenode
client/cmd/dexc-desktop/snap/snapcraft.yaml
43 changes: 36 additions & 7 deletions client/cmd/dexc-desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,41 @@ The dexc-desktop client is a cross-platform desktop application for the DEX clie
## Debian
Build with `./pkg/pkg-debian.sh`. The deb archive is located in **./build**.

For development, you'll need to install the WebKit Development Libraries.
`apt install libgtk-3-dev libwebkit2gtk-4.0-dev`
For production, they are specified as DEPENDS in the control file and the
package manager will install them.
For development, you'll need to install the WebKit Development Libraries and the standard build toolchain:

```bash
apt install libgtk-3-dev libwebkit2gtk-4.0-dev build-essential
```
For production, they are specified as DEPENDS in the control file and the package manager will install them.

## Snap

This build environment uses LXD containers under the hood. It's advised to run this on an Ubuntu system (ideally in a VM; the Snap components require system-wide installation). Ubuntu takes care of the configuration of the toolchain, other distributions require additional steps to initialize LXD.

Build environment setup:

```bash
sudo apt-get install snapd
sudo snap install --classic snapcraft
```

Run the build:

```bash
./pkg/pkg-snap.sh
```

This builds the snap package in **./build**. Note that this is dependent on the Debian package being in place so be sure to run `./pkg/pkg-debian.sh` first.

### Testing locally

```bash
sudo snap install --dangerous build/dexc_*.snap
```

### Publishing to the Snap store

The snap can be uploaded to the Snap Store using `./pkg/publish-snap.sh`. Once the publish is complete the package can be installed on other systems using `snap install dexc`.

## MacOS (darwin)
Build with `./pkg/pkg-darwin.sh` for `amd64` MacOS machines. If running on an
`arm64` machine, you'll need to build with `TARGETS=darwin/arm64 ./pkg/pkg-darwin.sh` instead.
The `.dmg` click installer can be located in **./pkg/installers** after a successful build.
Build with `./pkg/pkg-darwin.sh` for `amd64` MacOS machines. If running on an `arm64` machine, you'll need to build with `TARGETS=darwin/arm64 ./pkg/pkg-darwin.sh` instead. The `.dmg` click installer can be located in **./pkg/installers** after a successful build.
2 changes: 1 addition & 1 deletion client/cmd/dexc-desktop/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ require (
github.com/decred/dcrd/dcrec/edwards/v2 v2.0.3 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/decred/dcrd/dcrjson/v4 v4.0.1 // indirect
github.com/decred/dcrd/dcrutil/v4 v4.0.1 // indirect
github.com/decred/dcrd/dcrutil/v4 v4.0.2-0.20231005000813-c102e54b4128 // indirect
github.com/decred/dcrd/gcs/v4 v4.0.0 // indirect
github.com/decred/dcrd/hdkeychain/v3 v3.1.1 // indirect
github.com/decred/dcrd/lru v1.1.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions client/cmd/dexc-desktop/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etly
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/decred/dcrd/dcrjson/v4 v4.0.1 h1:vyQuB1miwGqbCVNm8P6br3V65WQ6wyrh0LycMkvaBBg=
github.com/decred/dcrd/dcrjson/v4 v4.0.1/go.mod h1:2qVikafVF9/X3PngQVmqkbUbyAl32uik0k/kydgtqMc=
github.com/decred/dcrd/dcrutil/v4 v4.0.1 h1:E+d2TNbpOj0f1L9RqkZkEm1QolFjajvkzxWC5WOPf1s=
github.com/decred/dcrd/dcrutil/v4 v4.0.1/go.mod h1:7EXyHYj8FEqY+WzMuRkF0nh32ueLqhutZDoW4eQ+KRc=
github.com/decred/dcrd/dcrutil/v4 v4.0.2-0.20231005000813-c102e54b4128 h1:hDyaGr+CuE9M/fCC7raFGH89wPd49tnjuc4wftISwa4=
github.com/decred/dcrd/dcrutil/v4 v4.0.2-0.20231005000813-c102e54b4128/go.mod h1:7EXyHYj8FEqY+WzMuRkF0nh32ueLqhutZDoW4eQ+KRc=
github.com/decred/dcrd/gcs/v4 v4.0.0 h1:bet+Ax1ZFUqn2M0g1uotm0b8F6BZ9MmblViyJ088E8k=
github.com/decred/dcrd/gcs/v4 v4.0.0/go.mod h1:9z+EBagzpEdAumwS09vf/hiGaR8XhNmsBgaVq6u7/NI=
github.com/decred/dcrd/hdkeychain/v3 v3.1.1 h1:4WhyHNBy7ec6qBUC7Fq7JFVGSd7bpuR5H+AJRID8Lyk=
Expand Down
22 changes: 22 additions & 0 deletions client/cmd/dexc-desktop/pkg/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# This file defines common variables to be source'd by the various build scripts
# in this directory.

# pick up the release tag from git
# VER=$(git describe --tags --always | sed -e 's/^v//')
VER="0.7.0"
META= # "release"
REV="0"

APP="dexc"
ARCH="amd64"

# The build directory will be deleted at the beginning of every build. The
# directory is .gitignore'd.
BUILD_DIR="./build"

# DEB_NAME follows the prescribed format for debian packaging.
DEB_NAME="${APP}_${VER}-${REV}_${ARCH}"

echo "Build version: ${VER}-${REV}_${ARCH}"

70 changes: 24 additions & 46 deletions client/cmd/dexc-desktop/pkg/pkg-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,14 @@
# A good getting-started guide for Debian packaging can be found at
# https://www.internalpointers.com/post/build-binary-deb-package-practical-guide

set -ex
set -e

APP="dexc"
VER="0.7.0-pre"
META= # "release"
REV="0"
ARCH="amd64"
# turn this on for debugging, keep noise down for prod builds
# set -x

# DEB_NAME follows the prescribed format for debian packaging.
DEB_NAME="${APP}_${VER}-${REV}_${ARCH}"
source $(dirname "$0")/common.sh

# The build directory will be deleted at the beginning of every build. The
# directory is .gitignore'd.
BUILD_DIR="./build"

# A directory for binary source files e.g. image files.
# A directory containing metadata files
SRC_DIR="./src"

# The DEB_DIR represents the root directory in our target system. The directory
Expand All @@ -36,16 +28,11 @@ POSTINST_PATH="${CONTROL_DIR}/postinst"
POSTRM_PATH="${CONTROL_DIR}/postrm"

# The dexc binary.
BIN_TARGETDIR="/usr/lib/dexc"
BIN_TARGETDIR="/usr/bin"
BIN_BUILDDIR="${DEB_DIR}${BIN_TARGETDIR}"
BIN_FILENAME="${APP}"
BIN_BUILDPATH="${BIN_BUILDDIR}/${BIN_FILENAME}"

ICON_FILENAME="dexc.png"
SRC_TARGETDIR="${BIN_TARGETDIR}/src"
SRC_BUILDDIR="${DEB_DIR}${SRC_TARGETDIR}"
LIBICON_BUILDPATH="${SRC_BUILDDIR}/${ICON_FILENAME}"

# The Desktop Entry is a format for "installing" programs on Linux, creating
# an entry in the main menu.
# https://specifications.freedesktop.org/desktop-entry-spec/latest/
Expand All @@ -54,18 +41,10 @@ DOT_DESKTOP_BUILDDIR="${DEB_DIR}${DOT_DESKTOP_TARGETDIR}"
DOT_DESKTOP_FILENAME="dexc.desktop"
DOT_DESKTOP_BUILDPATH="${DOT_DESKTOP_BUILDDIR}/${DOT_DESKTOP_FILENAME}"

# This will be the icon shown for the program in the taskbar. I know that both
# PNG and SVG will work. If it's a bitmap, should probably be >= 128 x 128 px.
ICON_TARGETDIR="/usr/share/pixmaps"
ICON_BUILDDIR="${DEB_DIR}${ICON_TARGETDIR}"
DESKTOPICON_BUILDPATH="${ICON_BUILDDIR}/${ICON_FILENAME}"

# Prepare the directory structure.
rm -fr "${BUILD_DIR}"
mkdir -p -m 0755 "${CONTROL_DIR}"
mkdir -p "${SRC_BUILDDIR}" # subdir of BIN_BUILDDIR
mkdir -p "${DOT_DESKTOP_BUILDDIR}"
mkdir -p "${ICON_BUILDDIR}"

# Build dexc
LDFLAGS="-s -w -X main.Version=${VER}${META:++${META}}"
Expand All @@ -83,40 +62,39 @@ Depends: libgtk-3-0, libwebkit2gtk-4.0-37
Description: A multi-wallet backed by Decred DEX
EOF

# Symlink the binary and update the desktop icons, refresh the "start" menu.
# Copy icons
# This will be the icon shown for the program in the taskbar. I know that both
# PNG and SVG will work. If it's a bitmap, should probably be >= 128 x 128 px.
ICON_TARGETDIR="/usr/share/icons/hicolor"
ICON_BUILDDIR="${DEB_DIR}${ICON_TARGETDIR}"
install -Dm644 -t "${ICON_BUILDDIR}/scalable/apps" "${SRC_DIR}/dexc.svg"
install -Dm644 -t "${ICON_BUILDDIR}/128x128/apps" "${SRC_DIR}/dexc.png"
install -Dm644 -t "${ICON_BUILDDIR}/symbolic/apps" "${SRC_DIR}/dexc-symbolic.svg"

# AppStream metadata
# https://wiki.debian.org/AppStream
install -Dm644 -t "${DEB_DIR}/usr/share/metainfo" "${SRC_DIR}/org.decred.dcrdex.metainfo.xml"

# Update the desktop icons, refresh the "start" menu.
cat > "${POSTINST_PATH}" <<EOF
ln -s "${BIN_TARGETDIR}/${BIN_FILENAME}" "/usr/bin/${BIN_FILENAME}"
update-desktop-database
EOF
chmod 775 "${POSTINST_PATH}"

# Remove symlink from postinst.
cat > "${POSTRM_PATH}" <<EOF
rm "/usr/bin/${BIN_FILENAME}"
EOF
chmod 775 "${POSTRM_PATH}"

# Example file:
# https://specifications.freedesktop.org/desktop-entry-spec/latest/apa.html
cat > "${DOT_DESKTOP_BUILDPATH}" <<EOF
[Desktop Entry]
Version=${VER}
Version=1.0
Name=Decred DEX Client
Comment=Multi-wallet backed by Decred DEX
Exec=${BIN_TARGETDIR}/${BIN_FILENAME}
Icon=${ICON_TARGETDIR}/${ICON_FILENAME}
Exec=${BIN_FILENAME}
Icon=${APP}
Terminal=false
Type=Application
Categories=Office;Development;
Categories=Office;Finance;
EOF
chmod 644 "${DOT_DESKTOP_BUILDPATH}"

# Icon
cp "${SRC_DIR}/${ICON_FILENAME}" "${DESKTOPICON_BUILDPATH}"
chmod 644 "${DESKTOPICON_BUILDPATH}"

cp "${SRC_DIR}/${ICON_FILENAME}" "${LIBICON_BUILDPATH}"
chmod 644 "${LIBICON_BUILDPATH}"

# Build the installation archive (.deb file).
dpkg-deb --build --root-owner-group "${DEB_DIR}"
14 changes: 14 additions & 0 deletions client/cmd/dexc-desktop/pkg/pkg-snap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -ex

SCRIPT_DIR=$(dirname "$0")

source $SCRIPT_DIR/common.sh

SNAPCRAFT_YML_IN=snap/local/snapcraft.yaml.in
SNAPCRAFT_YML=snap/snapcraft.yaml
sed -e "s/\$VERSION/$VER/g" \
-e "s/\$DEB_NAME/$DEB_NAME/g" "$SNAPCRAFT_YML_IN" > "$SNAPCRAFT_YML"

/snap/bin/snapcraft --verbose --output $BUILD_DIR/
7 changes: 7 additions & 0 deletions client/cmd/dexc-desktop/pkg/publish-snap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

source $(dirname "$0")/common.sh

snapcraft login

snapcraft upload --release=stable $BUILD_DIR/${APP}_${VER}_${ARCH}.snap
Loading