diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 80ac4177..e18dc823 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,10 +18,10 @@ jobs: os: windows-latest target: x86_64-pc-windows-msvc - platform: windows-arm64 - os: windows-latest + os: windows-11-arm target: aarch64-pc-windows-msvc - platform: macos-x64 - os: macos-latest + os: macos-13 target: x86_64-apple-darwin - platform: macos-arm64 os: macos-latest @@ -30,7 +30,7 @@ jobs: os: ubuntu-latest target: x86_64-unknown-linux-gnu - platform: linux-arm64 - os: ubuntu-latest + os: ubuntu-24.04-arm target: aarch64-unknown-linux-gnu steps: @@ -48,7 +48,7 @@ jobs: working-directory: crates/coop run: | cargo install cargo-packager --locked - cargo packager --release --target ${{ matrix.target }} --config before-packaging-command="cargo build --release --target ${{ matrix.target }}" + cargo packager --release - name: Upload Windows/macOS artifacts if: runner.os != 'Linux' @@ -56,9 +56,9 @@ jobs: with: name: ${{ matrix.platform }}-artifacts path: | - crates/coop/dist/*.dmg - crates/coop/dist/*.msi - crates/coop/dist/*.exe + dist/*.dmg + dist/*.msi + dist/*.exe if-no-files-found: error # Linux builds using custom scripts @@ -68,20 +68,6 @@ jobs: sudo apt-get update sudo apt-get install -y flatpak flatpak-builder snapd squashfs-tools jq gettext-base - # Install cross-compilation tools for ARM64 - - name: Install ARM64 cross-compilation tools - if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu' - run: | - sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu - - - name: Configure cross-compilation environment - if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu' - run: | - echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV - echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV - echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - - name: Install Snapcraft if: runner.os == 'Linux' run: sudo snap install snapcraft --classic @@ -91,53 +77,41 @@ jobs: run: | chmod +x script/get-crate-version chmod +x script/linux - chmod +x script/snap-build + chmod +x script/bundle-snap chmod +x script/bundle-linux chmod +x script/flatpak/deps chmod +x script/flatpak/bundle-flatpak - name: Install required dependencies if: runner.os == 'Linux' - working-directory: script - run: ./linux + run: ./script/linux # Only build Flatpak and Snap for x86_64 (most common use case) - - name: Build Flatpak (x86_64 only) - if: runner.os == 'Linux' && matrix.target == 'x86_64-unknown-linux-gnu' - working-directory: script/flatpak + - name: Build Flatpak + if: runner.os == 'Linux' run: | - ./deps - ./bundle-flatpak + ./script/bundle-linux --flatpak + ./script/flatpak/deps + ./script/flatpak/bundle-flatpak - - name: Build Snap (x86_64 only) - if: runner.os == 'Linux' && matrix.target == 'x86_64-unknown-linux-gnu' + - name: Build Snap + if: runner.os == 'Linux' run: | VERSION=$(script/get-crate-version coop) - script/snap-build $VERSION + ./script/bundle-linux + ./script/bundle-snap $VERSION - # For ARM64, build a simple binary package - - name: Build ARM64 binary - if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu' - run: | - cargo build --release --target ${{ matrix.target }} - - - name: Create ARM64 tarball - if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu' - run: | - VERSION=$(script/get-crate-version coop) - mkdir -p linux-artifacts - cd target/aarch64-unknown-linux-gnu/release - tar -czf ../../../linux-artifacts/coop-${VERSION}-linux-aarch64.tar.gz coop - ls -la ../../../linux-artifacts/ - - - name: Collect Linux x86_64 artifacts - if: runner.os == 'Linux' && matrix.target == 'x86_64-unknown-linux-gnu' + - name: Collect Linux artifacts + if: runner.os == 'Linux' + working-directory: ${{ github.workspace }} run: | mkdir -p linux-artifacts - # Find and copy flatpak files - find . -name "*.flatpak" -exec cp {} linux-artifacts/ \; - # Find and copy snap files - find . -name "*.snap" -exec cp {} linux-artifacts/ \; + # Copy the tarball created by bundle-linux + find target/release -name "*.tar.gz" -exec cp {} linux-artifacts/ \; + # Find and copy flatpak files (if they exist) + find . -name "*.flatpak" -exec cp {} linux-artifacts/ \; || true + # Find and copy snap files (if they exist) + find . -name "*.snap" -exec cp {} linux-artifacts/ \; || true ls -la linux-artifacts/ - name: Upload Linux artifacts diff --git a/crates/coop/resources/icon@2x.png b/crates/coop/resources/icon@2x.png new file mode 100644 index 00000000..ea995412 Binary files /dev/null and b/crates/coop/resources/icon@2x.png differ diff --git a/crates/coop/resources/snap/snapcraft.yaml.in b/crates/coop/resources/snap/snapcraft.yaml.in index 0e972556..89597d7e 100644 --- a/crates/coop/resources/snap/snapcraft.yaml.in +++ b/crates/coop/resources/snap/snapcraft.yaml.in @@ -2,7 +2,7 @@ name: coop title: Coop base: core24 version: "$RELEASE_VERSION" -summary: The editor for what's next +summary: Chat Freely, Stay Private on Nostr description: | Chat Freely, Stay Private on Nostr. grade: stable @@ -16,7 +16,7 @@ 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" + source: target/release/coop-linux-$ARCH_SUFFIX.tar.gz organize: # These renames seem to not be necessary, but it's tidier. diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e9326a9c..806f8019 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -7,4 +7,5 @@ targets = [ "aarch64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", + "aarch64-pc-windows-msvc", ] diff --git a/script/bundle-freebsd b/script/bundle-freebsd new file mode 100644 index 00000000..46409041 --- /dev/null +++ b/script/bundle-freebsd @@ -0,0 +1 @@ +# TODO diff --git a/script/bundle-linux b/script/bundle-linux index 7a5d4881..8cdd0f2f 100755 --- a/script/bundle-linux +++ b/script/bundle-linux @@ -83,7 +83,7 @@ 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" +cp "${target_dir}/${target_triple}/release/coop" "${coop_dir}/bin/coop" # Libs find_libs() { diff --git a/script/bundle-snap b/script/bundle-snap new file mode 100755 index 00000000..a1fa64c5 --- /dev/null +++ b/script/bundle-snap @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Get system architecture +ARCH=$(uname -m) +case "$ARCH" in + x86_64) ARCH_SUFFIX="x86_64" ;; + aarch64) ARCH_SUFFIX="aarch64" ;; + *) echo "Unsupported architecture: $ARCH"; exit 1 ;; +esac + +# Setup GUI files +mkdir -p snap/gui +export DO_STARTUP_NOTIFY="true" +export APP_NAME="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" + +# Generate snapcraft.yaml with version and architecture +RELEASE_VERSION="$1" ARCH_SUFFIX="$ARCH_SUFFIX" envsubst < crates/coop/resources/snap/snapcraft.yaml.in > snap/snapcraft.yaml + +# Clean previous builds +snapcraft clean + +# Build snap with architecture in filename +SNAP_NAME="coop_${1}_${ARCH_SUFFIX}.snap" +snapcraft --destructive-mode --output "$SNAP_NAME" + +echo "Created snap package: $SNAP_NAME" diff --git a/script/flatpak/bundle-flatpak b/script/flatpak/bundle-flatpak index 47929dbd..2ef0ba1d 100755 --- a/script/flatpak/bundle-flatpak +++ b/script/flatpak/bundle-flatpak @@ -4,18 +4,32 @@ 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" +# Get system architecture +ARCH=$(uname -m) +case "$ARCH" in + x86_64) ARCH_SUFFIX="x86_64" ;; + aarch64) ARCH_SUFFIX="aarch64" ;; + *) echo "Unsupported architecture: $ARCH"; exit 1 ;; +esac + +archive_match="coop(-[a-zA-Z0-9]+)?-linux-${ARCH_SUFFIX}\.tar\.gz" archive=$(ls "target/release" | grep -E ${archive_match}) export ARCHIVE="$archive" export APP_ID="su.reya.coop" export APP_NAME="Coop" -export BRANDING_LIGHT="#99c1f1" -export BRANDING_DARK="#1a5fb4" +export BRANDING_LIGHT="#FFE629" +export BRANDING_DARK="#FFE629" export ICON_FILE="icon" +export CHANNEL="stable" +# Generate manifest envsubst < "crates/coop/resources/flatpak/manifest-template.json" > "$APP_ID.json" + +# Build Flatpak 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'" + +# Create bundle with architecture suffix +OUTPUT_FILE="target/release/${APP_ID}_${ARCH_SUFFIX}.flatpak" +flatpak build-bundle ~/.local/share/flatpak/repo "$OUTPUT_FILE" "$APP_ID" +echo "Created '$OUTPUT_FILE'" diff --git a/script/snap-build b/script/snap-build deleted file mode 100755 index 18288fcb..00000000 --- a/script/snap-build +++ /dev/null @@ -1,27 +0,0 @@ -#!/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/try-snap similarity index 100% rename from script/snap-try rename to script/try-snap