diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6f17a93c..d7241b54 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [macos-latest, windows-latest] runs-on: ${{ matrix.os }} @@ -42,12 +42,6 @@ jobs: toolchain: stable cache: true - - name: Install dependencies (ubuntu only) - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt-get install -y gcc g++ libasound2-dev libfontconfig-dev libwayland-dev libxkbcommon-x11-dev libssl-dev libzstd-dev libvulkan1 libgit2-dev make cmake clang jq netcat-openbsd git curl gettext-base elfutils libsqlite3-dev musl-tools musl-dev build-essential - - name: install cargo packager run: | cargo install cargo-packager --locked diff --git a/.goreleaser.yaml b/.goreleaser.yaml deleted file mode 100644 index 8bba2946..00000000 --- a/.goreleaser.yaml +++ /dev/null @@ -1,49 +0,0 @@ -# yaml-language-server: $schema=https://goreleaser.com/static/schema.json -# vim: set ts=2 sw=2 tw=0 fo=cnqoj - -version: 2 -pro: true - -before: - hooks: - - rustup default stable - - cargo install --locked cargo-zigbuild - - cargo fetch --locked - -builds: - - builder: rust - flags: - - --release - - --package=coop - targets: - - x86_64-unknown-linux-gnu - - x86_64-apple-darwin - - x86_64-pc-windows-gnu - - aarch64-unknown-linux-gnu - - aarch64-apple-darwin - -archives: - - formats: [tar.gz] - name_template: >- - {{ .ProjectName }}_ - {{- title .Os }}_ - {{- if eq .Arch "amd64" }}x86_64 - {{- else if eq .Arch "386" }}i386 - {{- else }}{{ .Arch }}{{ end }} - format_overrides: - - goos: windows - formats: [zip] - -changelog: - sort: asc - filters: - exclude: - - "^docs:" - - "^test:" - -release: - footer: >- - - --- - - Released by [GoReleaser](https://github.com/goreleaser/goreleaser). diff --git a/Cargo.lock b/Cargo.lock index 2a0ba5d4..74603a80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -178,7 +178,7 @@ dependencies = [ [[package]] name = "assets" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "gpui", @@ -417,7 +417,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "auto_update" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "common", @@ -987,7 +987,7 @@ dependencies = [ [[package]] name = "client_keys" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "global", @@ -1089,7 +1089,7 @@ dependencies = [ [[package]] name = "collections" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "indexmap", "rustc-hash 2.1.1", @@ -1124,7 +1124,7 @@ dependencies = [ [[package]] name = "common" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "chrono", @@ -1180,7 +1180,7 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "coop" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "assets", @@ -1491,7 +1491,7 @@ dependencies = [ [[package]] name = "derive_refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "proc-macro2", "quote", @@ -2277,7 +2277,7 @@ checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "global" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "dirs 5.0.1", @@ -2371,7 +2371,7 @@ dependencies = [ [[package]] name = "gpui" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "anyhow", "as-raw-xcb-connection", @@ -2464,7 +2464,7 @@ dependencies = [ [[package]] name = "gpui_macros" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -2476,7 +2476,7 @@ dependencies = [ [[package]] name = "gpui_tokio" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "gpui", "tokio", @@ -2707,7 +2707,7 @@ dependencies = [ [[package]] name = "http_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "anyhow", "bytes", @@ -2726,7 +2726,7 @@ dependencies = [ [[package]] name = "http_client_tls" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "rustls", "rustls-platform-verifier", @@ -2820,7 +2820,7 @@ dependencies = [ [[package]] name = "i18n" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "rust-i18n", ] @@ -2937,7 +2937,7 @@ dependencies = [ [[package]] name = "identity" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "client_keys", @@ -3527,7 +3527,7 @@ dependencies = [ [[package]] name = "media" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "anyhow", "bindgen 0.71.1", @@ -4899,7 +4899,7 @@ dependencies = [ [[package]] name = "refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "derive_refineable", "workspace-hack", @@ -4936,7 +4936,7 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "registry" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "chrono", @@ -5051,7 +5051,7 @@ dependencies = [ [[package]] name = "reqwest_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "anyhow", "bytes", @@ -5587,7 +5587,7 @@ checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749" [[package]] name = "semantic_version" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "anyhow", "serde", @@ -5722,7 +5722,7 @@ dependencies = [ [[package]] name = "settings" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "global", @@ -5982,7 +5982,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sum_tree" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "arrayvec", "log", @@ -6274,7 +6274,7 @@ dependencies = [ [[package]] name = "theme" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "gpui", @@ -6403,7 +6403,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "title_bar" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "common", @@ -6774,7 +6774,7 @@ dependencies = [ [[package]] name = "ui" -version = "1.0.0" +version = "1.0.0-beta" dependencies = [ "anyhow", "common", @@ -6974,7 +6974,7 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "util" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#4d79edc7533d6d0a8e29004c789bc6041a97993d" +source = "git+https://github.com/zed-industries/zed#a50d0f2586873fa92d4bfa3b09a3c332455002fa" dependencies = [ "anyhow", "async-fs", diff --git a/Cargo.toml b/Cargo.toml index da30676e..dc152e2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["crates/*"] default-members = ["crates/coop"] [workspace.package] -version = "1.0.0" +version = "1.0.0-beta" edition = "2021" publish = false diff --git a/crates/coop/Cargo.toml b/crates/coop/Cargo.toml index 3534fca7..60547a0c 100644 --- a/crates/coop/Cargo.toml +++ b/crates/coop/Cargo.toml @@ -8,6 +8,24 @@ publish.workspace = true name = "coop" path = "src/main.rs" +[package.metadata.packager] +name = "Coop" +product-name = "Coop" +description = "Chat Freely, Stay Private on Nostr" +identifier = "dev.coop.Coop" +category = "SocialNetworking" +version = "1.0.0-beta" +out-dir = "./dist" +before-packaging-command = "cargo build --release" +resources = ["Cargo.toml", "src"] +icons = [ + "resources/32x32.png", + "resources/128x128.png", + "resources/128x128@2x.png", + "resources/icon.icns", + "resources/icon.ico", +] + [dependencies] assets = { path = "../assets" } ui = { path = "../ui" } diff --git a/crates/coop/resources/coop.desktop.in b/crates/coop/resources/coop.desktop.in new file mode 100644 index 00000000..d6b73215 --- /dev/null +++ b/crates/coop/resources/coop.desktop.in @@ -0,0 +1,14 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=$APP_NAME +GenericName=Chat Application +Comment=Chat Freely, Stay Private on Nostr. +TryExec=$APP_CLI +StartupNotify=$DO_STARTUP_NOTIFY +Exec=$APP_CLI $APP_ARGS +Icon=$APP_ICON +Categories=Network;InstantMessaging; +Keywords=chat;messaging;nostr;privacy; +MimeType=x-scheme-handler/nostr;x-scheme-handler/coop; +Actions=NewChat; diff --git a/crates/coop/resources/flatpak/coop.metainfo.xml.in b/crates/coop/resources/flatpak/coop.metainfo.xml.in new file mode 100644 index 00000000..6c72a95e --- /dev/null +++ b/crates/coop/resources/flatpak/coop.metainfo.xml.in @@ -0,0 +1,62 @@ + + + $APP_ID + MIT + AGPL-3.0-or-later and Apache-2.0 and GPL-3.0-or-later + + $APP_NAME + Chat Freely, Stay Private on Nostr + + Ren Amamiya + + +

+ Chat Freely, Stay Private on Nostr +

+
+ + $APP_ID.desktop + + + $BRANDING_LIGHT + $BRANDING_DARK + + + + intense + intense + + + https://coopchat.com + https://github.com/lumehq/coop/issues + https://coopchat.com/faq + https://coopchat.com/docs/getting-started + https://coopchat.com/community-links + https://github.com/lumehq/coop + https://github.com/lumehq/coop/blob/main/CONTRIBUTING.md + + + offline-only + + + pointing + keyboard + 768 + + + + + Coop + https://coopchat.com/img/flatpak/flatpak-1.png + + + + + @release_info@ + + +

Dummy release to keep flatpak-builder AppStream metadata validation from complaining

+
+
+
+
diff --git a/crates/coop/resources/flatpak/manifest-template.json b/crates/coop/resources/flatpak/manifest-template.json new file mode 100644 index 00000000..eee6caee --- /dev/null +++ b/crates/coop/resources/flatpak/manifest-template.json @@ -0,0 +1,58 @@ +{ + "id": "$APP_ID", + "runtime": "org.freedesktop.Platform", + "runtime-version": "23.08", + "sdk": "org.freedesktop.Sdk", + "sdk-extensions": ["org.freedesktop.Sdk.Extension.rust-stable"], + "command": "coop", + "finish-args": [ + "--talk-name=org.freedesktop.Flatpak", + "--device=dri", + "--share=ipc", + "--share=network", + "--socket=wayland", + "--socket=fallback-x11", + "--socket=pulseaudio", + "--filesystem=host" + ], + "build-options": { + "append-path": "/usr/lib/sdk/rust-stable/bin" + }, + "modules": [ + { + "name": "coop", + "buildsystem": "simple", + "build-options": { + "env": { + "APP_ID": "$APP_ID", + "APP_ICON": "$APP_ID", + "APP_NAME": "$APP_NAME", + "BRANDING_LIGHT": "$BRANDING_LIGHT", + "BRANDING_DARK": "$BRANDING_DARK", + "APP_CLI": "coop", + "APP_ARGS": "--foreground %U", + "DO_STARTUP_NOTIFY": "false" + } + }, + "build-commands": [ + "install -Dm644 $ICON_FILE.png /app/share/icons/hicolor/512x512/apps/$APP_ID.png", + "envsubst < coop.desktop.in > coop.desktop && install -Dm644 coop.desktop /app/share/applications/$APP_ID.desktop", + "envsubst < flatpak/coop.metainfo.xml.in > coop.metainfo.xml && install -Dm644 coop.metainfo.xml /app/share/metainfo/$APP_ID.metainfo.xml", + "sed -i -e '/@release_info@/{r flatpak/release-info/$CHANNEL' -e 'd}' /app/share/metainfo/$APP_ID.metainfo.xml", + "install -Dm755 bin/coop /app/bin/coop", + "install -Dm755 libexec/coop /app/libexec/coop", + "install -Dm755 lib/* -t /app/lib" + ], + "sources": [ + { + "type": "archive", + "path": "./target/release/$ARCHIVE" + }, + { + "type": "dir", + "path": "./crates/coop/resources" + } + ] + } + ] +} diff --git a/crates/coop/resources/app-icon.icns b/crates/coop/resources/icon.icns similarity index 100% rename from crates/coop/resources/app-icon.icns rename to crates/coop/resources/icon.icns diff --git a/crates/coop/resources/app-icon.ico b/crates/coop/resources/icon.ico similarity index 100% rename from crates/coop/resources/app-icon.ico rename to crates/coop/resources/icon.ico diff --git a/crates/coop/resources/app-icon.png b/crates/coop/resources/icon.png similarity index 100% rename from crates/coop/resources/app-icon.png rename to crates/coop/resources/icon.png diff --git a/crates/coop/resources/snap/snapcraft.yaml.in b/crates/coop/resources/snap/snapcraft.yaml.in new file mode 100644 index 00000000..8d28ee7c --- /dev/null +++ b/crates/coop/resources/snap/snapcraft.yaml.in @@ -0,0 +1,58 @@ +name: coop +title: Coop +base: core24 +version: "$RELEASE_VERSION" +summary: The editor for what's next +description: | + Chat Freely, Stay Private on Nostr. +grade: stable +confinement: classic +compression: lzo +website: https://coopchat.com/ +source-code: https://github.com/lumehq/coop +issues: https://github.com/lumehq/coop/issues +contact: https://reya.su + +parts: + coop: + plugin: dump + source: "https://github.com/lumehq/coop/releases/download/v$RELEASE_VERSION/coop-linux-x86_64.tar.gz" + + organize: + # These renames seem to not be necessary, but it's tidier. + bin: usr/bin + libexec: usr/libexec + + stage-packages: + - libasound2t64 + # snapcraft has a lint that this is unused, but without it Coop exits with + # "Missing Vulkan entry points: LibraryLoadFailure" in blade_graphics. + - libvulkan1 + # snapcraft has a lint that this is unused, but without it Coop exits with + # "NoWaylandLib" when run with Wayland. + - libwayland-client0 + - libxcb1 + - libxkbcommon-x11-0 + - libxkbcommon0 + + build-attributes: + - enable-patchelf + + prime: + # Omit unneeded files from the tarball + - -lib + - -licenses.md + - -share + + # Omit unneeded files from stage-packages + - -etc + - -usr/share/doc + - -usr/share/lintian + - -usr/share/man + +apps: + coop: + command: usr/bin/coop + common-id: dev.coop.Coop + environment: + COOP_BUNDLE_TYPE: snap diff --git a/crates/global/src/constants.rs b/crates/global/src/constants.rs index abaa22e1..ad065bf8 100644 --- a/crates/global/src/constants.rs +++ b/crates/global/src/constants.rs @@ -1,5 +1,5 @@ pub const APP_NAME: &str = "Coop"; -pub const APP_ID: &str = "su.reya.coop"; +pub const APP_ID: &str = "dev.coop.Coop"; pub const APP_PUBKEY: &str = "b1813fb01274b32cc5db6d1198e7c79dda0fb430899f63c7064f651a41d44f2b"; pub const KEYRING_URL: &str = "Coop Safe Storage"; diff --git a/locales/app.yml b/locales/app.yml index 8bf0fe43..e50fc753 100644 --- a/locales/app.yml +++ b/locales/app.yml @@ -44,7 +44,7 @@ welcome: title: en: "Welcome to Coop" subtitle: - en: "Secure Communication on Nostr." + en: "Chat Freely, Stay Private on Nostr." onboarding: choose_account: diff --git a/script/bundle-linux b/script/bundle-linux new file mode 100755 index 00000000..7a5d4881 --- /dev/null +++ b/script/bundle-linux @@ -0,0 +1,123 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +# Function for displaying help info +help_info() { + echo " +Usage: ${0##*/} [options] +Build a release .tar.gz for Linux. + +Options: + -h, --help Display this help and exit. + --flatpak Set COOP_BUNDLE_TYPE=flatpak so that this can be included in system info + " +} + +# Parse all arguments manually +while [[ $# -gt 0 ]]; do + case $1 in + -h|--help) + help_info + exit 0 + ;; + --flatpak) + export COOP_BUNDLE_TYPE=flatpak + shift + ;; + --) + shift + break + ;; + -*) + echo "Unknown option: $1" >&2 + help_info + exit 1 + ;; + *) + echo "Error: Unexpected argument: $1" >&2 + help_info + exit 1 + ;; + esac +done + +export COOP_BUNDLE=true + +target_dir="${CARGO_TARGET_DIR:-target}" + +version="$(script/get-crate-version coop)" +# Set RELEASE_VERSION so it's compiled into GPUI and it knows about the version. +export RELEASE_VERSION="${version}" + +commit=$(git rev-parse HEAD | cut -c 1-7) + +version_info=$(rustc --version --verbose) +host_line=$(echo "$version_info" | grep host) +target_triple=${host_line#*: } +musl_triple=${target_triple%-gnu}-musl +remote_server_triple=${REMOTE_SERVER_TARGET:-"${musl_triple}"} +rustup_installed=false + +if command -v rustup >/dev/null 2>&1; then + rustup_installed=true +fi + +export CC=$(which clang) + +# Build binary in release mode +export RUSTFLAGS="${RUSTFLAGS:-} -C link-args=-Wl,--disable-new-dtags,-rpath,\$ORIGIN/../lib" +cargo build --release --target "${target_triple}" --package coop + +# Strip debug symbols and save them for upload to DigitalOcean +objcopy --only-keep-debug "${target_dir}/${target_triple}/release/coop" "${target_dir}/${target_triple}/release/coop.dbg" +objcopy --strip-debug "${target_dir}/${target_triple}/release/coop" + +gzip -f "${target_dir}/${target_triple}/release/coop.dbg" + +# Move everything that should end up in the final package +# into a temp directory. +temp_dir=$(mktemp -d) +coop_dir="${temp_dir}/coop.app" + +# Binary +mkdir -p "${coop_dir}/bin" "${coop_dir}/libexec" +cp "${target_dir}/${target_triple}/release/coop" "${coop_dir}/libexec/coop" +cp "${target_dir}/${target_triple}/release/cli" "${coop_dir}/bin/coop" + +# Libs +find_libs() { + ldd ${target_dir}/${target_triple}/release/coop |\ + cut -d' ' -f3 |\ + grep -v '\<\(libstdc++.so\|libc.so\|libgcc_s.so\|libm.so\|libpthread.so\|libdl.so\|libasound.so\)' +} + +mkdir -p "${coop_dir}/lib" +rm -rf "${coop_dir}/lib/*" +cp $(find_libs) "${coop_dir}/lib" + +# Icons +mkdir -p "${coop_dir}/share/icons/hicolor/512x512/apps" +cp "crates/coop/resources/icon.png" "${coop_dir}/share/icons/hicolor/512x512/apps/coop.png" +mkdir -p "${coop_dir}/share/icons/hicolor/1024x1024/apps" +cp "crates/coop/resources/icon@2x.png" "${coop_dir}/share/icons/hicolor/1024x1024/apps/coop.png" + +# .desktop +export DO_STARTUP_NOTIFY="true" +export APP_CLI="coop" +export APP_ICON="coop" +export APP_ARGS="%U" +export APP_NAME="Coop" + +mkdir -p "${coop_dir}/share/applications" +envsubst < "crates/coop/resources/coop.desktop.in" > "${coop_dir}/share/applications/coop.desktop" + +# Create archive out of everything that's in the temp directory +arch=$(uname -m) +target="linux-${arch}" +archive="coop-${target}.tar.gz" + +rm -rf "${archive}" +remove_match="coop(-[a-zA-Z0-9]+)?-linux-$(uname -m)\.tar\.gz" +ls "${target_dir}/release" | grep -E ${remove_match} | xargs -d "\n" -I {} rm -f "${target_dir}/release/{}" || true +tar -czvf "${target_dir}/release/$archive" -C ${temp_dir} "coop.app" diff --git a/script/flatpak/bundle-flatpak b/script/flatpak/bundle-flatpak new file mode 100755 index 00000000..bb538d25 --- /dev/null +++ b/script/flatpak/bundle-flatpak @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -euo pipefail +cd "$(dirname "$0")/../.." +shopt -s extglob + +script/bundle-linux --flatpak +archive_match="zed(-[a-zA-Z0-9]+)?-linux-$(uname -m)\.tar\.gz" +archive=$(ls "target/release" | grep -E ${archive_match}) + +export ARCHIVE="$archive" +export APP_ID="dev.coop.Coop" +export APP_NAME="Coop" +export BRANDING_LIGHT="#99c1f1" +export BRANDING_DARK="#1a5fb4" +export ICON_FILE="icon" + +envsubst < "crates/coop/resources/flatpak/manifest-template.json" > "$APP_ID.json" +flatpak-builder --user --install --force-clean build "$APP_ID.json" +flatpak build-bundle ~/.local/share/flatpak/repo "target/release/$APP_ID.flatpak" "$APP_ID" +echo "Created 'target/release/$APP_ID.flatpak'" diff --git a/script/flatpak/deps b/script/flatpak/deps new file mode 100755 index 00000000..dec24dfc --- /dev/null +++ b/script/flatpak/deps @@ -0,0 +1,9 @@ +#!/bin/sh + +flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo + +arch=$(arch) +fd_version=23.08 +flatpak install -y --user org.freedesktop.Platform/${arch}/${fd_version} +flatpak install -y --user org.freedesktop.Sdk/${arch}/${fd_version} +flatpak install -y --user org.freedesktop.Sdk.Extension.rust-stable/${arch}/${fd_version} diff --git a/script/freebsd b/script/freebsd old mode 100644 new mode 100755 diff --git a/script/get-crate-version b/script/get-crate-version new file mode 100755 index 00000000..d642eb08 --- /dev/null +++ b/script/get-crate-version @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -eu + +if [[ $# -ne 1 ]]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +CRATE_NAME=$1 + +cargo metadata \ + --no-deps \ + --format-version=1 \ + | jq \ + --raw-output \ + ".packages[] | select(.name == \"${CRATE_NAME}\") | .version" diff --git a/script/snap-build b/script/snap-build new file mode 100755 index 00000000..18288fcb --- /dev/null +++ b/script/snap-build @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +mkdir -p snap/gui + +export DO_STARTUP_NOTIFY="true" +export APP_NAME="Coop" +export APP_CLI="coop" +export APP_ICON="\${SNAP}/meta/gui/coop.png" +export APP_ARGS="%U" +envsubst < "crates/coop/resources/coop.desktop.in" > "snap/gui/coop.desktop" +cp "crates/coop/resources/icon.png" "snap/gui/coop.png" + +RELEASE_VERSION="$1" envsubst < crates/coop/resources/snap/snapcraft.yaml.in > snap/snapcraft.yaml + +# Clean seems to be needed to actually check that the snapcraft.yaml +# works. For example, when a `stage-package` is removed, it will +# still remain on rebuild. +snapcraft clean + +snapcraft diff --git a/script/snap-try b/script/snap-try new file mode 100755 index 00000000..70cebe13 --- /dev/null +++ b/script/snap-try @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# This script is intended to be run after `snap-build`. +# +# It expects a version to be passed as the first argument, and expects +# the built `.snap` for that version to be in the current directory. +# +# This will uninstall the current `coop` snap, replacing it with a snap +# that directly uses the `snap/unpacked` directory. + +set -euxo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Rerun as root +[ "$UID" -eq 0 ] || exec sudo bash -e "$0" "$@" + +snap remove coop || true +mkdir -p snap +rm -rf snap/unpacked +unsquashfs -dest snap/unpacked "coop_$1_amd64.snap" +snap try --classic snap/unpacked