diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000000..7786feb15a --- /dev/null +++ b/.github/workflows/README.md @@ -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. \ No newline at end of file diff --git a/.github/workflows/build-snap.yml b/.github/workflows/build-snap.yml new file mode 100644 index 0000000000..58b68b72aa --- /dev/null +++ b/.github/workflows/build-snap.yml @@ -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 diff --git a/.gitignore b/.gitignore index f2d27c0f8d..31d0105d2c 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/client/cmd/dexc-desktop/README.md b/client/cmd/dexc-desktop/README.md index 2d8e0deea9..7c83a3f4d2 100644 --- a/client/cmd/dexc-desktop/README.md +++ b/client/cmd/dexc-desktop/README.md @@ -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. diff --git a/client/cmd/dexc-desktop/go.mod b/client/cmd/dexc-desktop/go.mod index efd0bd14b1..b4312d7970 100644 --- a/client/cmd/dexc-desktop/go.mod +++ b/client/cmd/dexc-desktop/go.mod @@ -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 diff --git a/client/cmd/dexc-desktop/go.sum b/client/cmd/dexc-desktop/go.sum index 9f18e1f3ad..92f5dad199 100644 --- a/client/cmd/dexc-desktop/go.sum +++ b/client/cmd/dexc-desktop/go.sum @@ -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= diff --git a/client/cmd/dexc-desktop/pkg/common.sh b/client/cmd/dexc-desktop/pkg/common.sh new file mode 100644 index 0000000000..b327a380e1 --- /dev/null +++ b/client/cmd/dexc-desktop/pkg/common.sh @@ -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}" + diff --git a/client/cmd/dexc-desktop/pkg/pkg-debian.sh b/client/cmd/dexc-desktop/pkg/pkg-debian.sh index a82eb8bcd5..5dbdce2a97 100755 --- a/client/cmd/dexc-desktop/pkg/pkg-debian.sh +++ b/client/cmd/dexc-desktop/pkg/pkg-debian.sh @@ -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 @@ -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/ @@ -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}}" @@ -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}" < "${POSTRM_PATH}" < "${DOT_DESKTOP_BUILDPATH}" < "$SNAPCRAFT_YML" + +/snap/bin/snapcraft --verbose --output $BUILD_DIR/ diff --git a/client/cmd/dexc-desktop/pkg/publish-snap.sh b/client/cmd/dexc-desktop/pkg/publish-snap.sh new file mode 100755 index 0000000000..fec2f2bb10 --- /dev/null +++ b/client/cmd/dexc-desktop/pkg/publish-snap.sh @@ -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 diff --git a/client/cmd/dexc-desktop/snap/local/snapcraft.yaml.in b/client/cmd/dexc-desktop/snap/local/snapcraft.yaml.in new file mode 100644 index 0000000000..13dab21f3d --- /dev/null +++ b/client/cmd/dexc-desktop/snap/local/snapcraft.yaml.in @@ -0,0 +1,102 @@ +name: dexc +adopt-info: metainfo +version: '$VERSION' +license: BlueOak-1.0.0 + +base: core22 +grade: stable +confinement: strict + +architectures: + - build-on: amd64 +compression: lzo + +plugs: + dbus-svc: + bus: system + interface: dbus + name: org.freedesktop.portal + dbus-statusnotifier: + bus: session + interface: dbus + name: org.kde.StatusNotifierWatcher + dbus-dbusmenu: + bus: session + interface: dbus + name: com.canonical.dbusmenu + +apps: + dexc: + common-id: org.decred.dcrdex + command: usr/bin/dexc + desktop: usr/share/applications/dexc.desktop + extensions: [gnome] + environment: + GTK_USE_PORTAL: "1" + #TMPDIR: $XDG_RUNTIME_DIR + #XDG_CURRENT_DESKTOP: Unity + #DISABLE_WAYLAND: 1 + plugs: + - home + - opengl + - x11 + - desktop + - desktop-legacy + - network + - network-status + - browser-support + - screen-inhibit-control + - dbus-svc + - dbus-dbusmenu + - dbus-statusnotifier + +parts: + metainfo: + plugin: nil + source: . + parse-info: [./src/org.decred.dcrdex.metainfo.xml] + + dexc-desktop: + plugin: dump + source: ./build/$DEB_NAME.deb + source-type: deb + override-build: | + craftctl default + # Point icon to the correct location + sed -i -e 's|Icon=.*$|Icon=usr/share/icons/hicolor/scalable/apps/dexc.svg|' $SNAPCRAFT_PART_INSTALL/usr/share/applications/dexc.desktop + + prime: + - -usr/lib/x86_64-linux-gnu/libEGL_mesa* + - -usr/lib/x86_64-linux-gnu/libGLX_mesa* + - -usr/lib/x86_64-linux-gnu/libGLESv2* + - -usr/lib/x86_64-linux-gnu/libcaca++* + - -usr/lib/x86_64-linux-gnu/libcolordprivate* + - -usr/lib/x86_64-linux-gnu/libdconf* + - -usr/lib/x86_64-linux-gnu/libexslt* + - -usr/lib/x86_64-linux-gnu/libgstcheck-1.0* + - -usr/lib/x86_64-linux-gnu/libgstcontroller-1.0* + - -usr/lib/x86_64-linux-gnu/libicuio* + - -usr/lib/x86_64-linux-gnu/libicutest* + - -usr/lib/x86_64-linux-gnu/libjacknet* + - -usr/lib/x86_64-linux-gnu/libjackserver* + - -usr/lib/x86_64-linux-gnu/liborc-test-0.4* + - -usr/lib/x86_64-linux-gnu/libpulse-simple* + - -usr/lib/x86_64-linux-gnu/libunwind-coredump* + - -usr/lib/x86_64-linux-gnu/libunwind-ptrace* + - -usr/lib/x86_64-linux-gnu/libunwind-x86_64* + - -usr/lib/x86_64-linux-gnu/libwoff2enc* + - -usr/lib/x86_64-linux-gnu/libicutu* + - -usr/lib/x86_64-linux-gnu/libsamplerate* + - -usr/lib/x86_64-linux-gnu/libxcb-dri2* + - -usr/lib/x86_64-linux-gnu/libxcb-glx* + - -usr/lib/x86_64-linux-gnu/libxcb-present* + - -usr/lib/x86_64-linux-gnu/libxcb-randr* + - -usr/lib/x86_64-linux-gnu/libxcb-sync* + - -usr/lib/x86_64-linux-gnu/libxcb-xfixes* + - -usr/lib/x86_64-linux-gnu/libxshmfence* + + stage-packages: + - desktop-file-utils + - libwebkit2gtk-4.0-37 + - libgtk-3-0 + diff --git a/client/cmd/dexc-desktop/src/dexc-symbolic.svg b/client/cmd/dexc-desktop/src/dexc-symbolic.svg new file mode 100644 index 0000000000..ed7c5b7afc --- /dev/null +++ b/client/cmd/dexc-desktop/src/dexc-symbolic.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/client/cmd/dexc-desktop/src/dexc.png b/client/cmd/dexc-desktop/src/dexc.png index 3c7d7e01db..467c4f260b 100644 Binary files a/client/cmd/dexc-desktop/src/dexc.png and b/client/cmd/dexc-desktop/src/dexc.png differ diff --git a/client/cmd/dexc-desktop/src/dexc.svg b/client/cmd/dexc-desktop/src/dexc.svg new file mode 100644 index 0000000000..f6bb97f7c9 --- /dev/null +++ b/client/cmd/dexc-desktop/src/dexc.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/cmd/dexc-desktop/src/org.decred.dcrdex.desktop b/client/cmd/dexc-desktop/src/org.decred.dcrdex.desktop new file mode 100644 index 0000000000..ab45725f8b --- /dev/null +++ b/client/cmd/dexc-desktop/src/org.decred.dcrdex.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=Decred DEX Client +Comment=Multi-wallet backed by Decred DEX +Categories=Office;Finance; +Icon=org.decred.dcrdex +Exec=dexc +Terminal=false +StartupWMClass=DCRDEX diff --git a/client/cmd/dexc-desktop/src/org.decred.dcrdex.metainfo.xml b/client/cmd/dexc-desktop/src/org.decred.dcrdex.metainfo.xml new file mode 100644 index 0000000000..a4b48073d5 --- /dev/null +++ b/client/cmd/dexc-desktop/src/org.decred.dcrdex.metainfo.xml @@ -0,0 +1,30 @@ + + + org.decred.dcrdex + org.decred.dcrdex.desktop + DCRDEX + Decentralized cryptocurrency exchange + MIT + BlueOak-1.0.0 + https://dex.decred.org + https://chat.decred.org/#/room/#dex:decred.org + The Decred Developers + +

+ Non-custodial peer-to-peer exchange where your funds never leave your wallet. + Trade Bitcoin, USDC, Ethereum, Decred, Dogecoin, Zcash and more without KYC + and fees, using atomic swaps technology. +

+
+ + + https://raw.githubusercontent.com/decred/umbrel-app-store/master/decred-dcrdex/images/screenshot_1.png + + + https://raw.githubusercontent.com/decred/umbrel-app-store/master/decred-dcrdex/images/screenshot_2.png + + + https://raw.githubusercontent.com/decred/umbrel-app-store/master/decred-dcrdex/images/screenshot_3.png + + +