diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7530f187..fce403a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,14 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + - os: macOS-latest + - os: windows-latest + runs-on: ${{ matrix.os }} env: MACOSX_DEPLOYMENT_TARGET: 11.0 @@ -38,27 +45,29 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Setup Cache + - name: Setup Rust Cache uses: Swatinem/rust-cache@v2 + with: + key: ${{ hashFiles('Cross.toml') }} - - name: Install Linux Dependencies + - name: Install Cross if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libssl-dev libasound2-dev + run: cargo install cross - - name: Run Tests - run: cargo test - continue-on-error: true - - - name: Build Release - if: runner.os != 'macOS' - run: cargo build --release + - name: Build (Linux) + if: runner.os == 'Linux' + run: cross build --release --target ${{ matrix.target }} - - name: Build x86_64 and aarch64 for macOS + - name: Build Release (macOS) if: runner.os == 'macOS' run: | rustup target add x86_64-apple-darwin aarch64-apple-darwin cargo build --release --target x86_64-apple-darwin --target aarch64-apple-darwin + - name: Build Release (Windows) + if: runner.os == 'Windows' + run: cargo build --release + - name: Cache cargo-bundle if: runner.os == 'macOS' id: cache-cargo-bundle @@ -96,14 +105,14 @@ jobs: - name: Make Linux Binary Executable if: runner.os == 'Linux' - run: chmod +x target/release/psst-gui + run: chmod +x target/${{ matrix.target }}/release/psst-gui - name: Upload Linux Binary uses: actions/upload-artifact@v4 if: runner.os == 'Linux' with: - name: psst-gui - path: target/release/psst-gui + name: psst-gui-${{ matrix.target }} + path: target/${{ matrix.target }}/release/psst-gui - name: Upload Windows Executable uses: actions/upload-artifact@v4 @@ -115,18 +124,27 @@ jobs: deb: runs-on: ubuntu-latest needs: build + strategy: + matrix: + include: + - arch: amd64 + target: x86_64-unknown-linux-gnu + - arch: arm64 + target: aarch64-unknown-linux-gnu steps: - name: Checkout Repository uses: actions/checkout@v4 - - name: Download Linux Binary + - name: Download Linux Binaries uses: actions/download-artifact@v4 with: - name: psst-gui - path: ${{runner.workspace}} + name: psst-gui-${{ matrix.target }} + path: ${{runner.workspace}}/binaries - name: Move Binary - run: mkdir -p ${{runner.workspace}}/pkg/usr/bin/; mv ${{runner.workspace}}/psst-gui $_ + run: | + mkdir -p ${{runner.workspace}}/pkg/usr/bin/ + mv ${{runner.workspace}}/binaries/psst-gui ${{runner.workspace}}/pkg/usr/bin/ - name: Move Desktop Entry run: mkdir -p ${{runner.workspace}}/pkg/usr/share/applications/; mv .pkg/psst.desktop $_ @@ -150,18 +168,23 @@ jobs: run: mkdir -p ${{runner.workspace}}/pkg/usr/share/doc/psst-gui/; mv .pkg/copyright $_ - name: Move Package Config - run: mkdir -p ${{runner.workspace}}/pkg/; mv .pkg/DEBIAN $_/ + run: | + mkdir -p ${{runner.workspace}}/pkg/ + cp -r .pkg/DEBIAN $_/ + sed -i 's/Architecture: amd64/Architecture: ${{ matrix.arch }}/' ${{runner.workspace}}/pkg/DEBIAN/control - name: Set Version run: "echo Version: $(git rev-list --count HEAD) >> ${{runner.workspace}}/pkg/DEBIAN/control" - name: Build Package - run: cat ${{runner.workspace}}/pkg/DEBIAN/control && dpkg-deb -b ${{runner.workspace}}/pkg/ psst_$(git rev-list --count HEAD)_amd64.deb + run: | + cat ${{runner.workspace}}/pkg/DEBIAN/control + dpkg-deb -b ${{runner.workspace}}/pkg/ psst_$(git rev-list --count HEAD)_${{ matrix.arch }}.deb - name: Upload Debian Package uses: actions/upload-artifact@v4 with: - name: psst-deb + name: psst-deb-${{ matrix.arch }} path: "*.deb" appimage: diff --git a/Cargo.toml b/Cargo.toml index a11ac648..235f3777 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,6 @@ [workspace] resolver = "2" -members = [ - "psst-protocol", - "psst-core", - "psst-cli", - "psst-gui", -] +members = ["psst-protocol", "psst-core", "psst-cli", "psst-gui"] [profile.release] opt-level = 3 @@ -15,5 +10,6 @@ codegen-units = 1 [profile.dev.package.symphonia] opt-level = 2 + [profile.dev.package.libsamplerate] opt-level = 2 diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 00000000..f98ce5af --- /dev/null +++ b/Cross.toml @@ -0,0 +1,14 @@ +[build] +pre-build = [""" + dpkg --add-architecture $CROSS_DEB_ARCH && \ + apt-get update && apt-get --assume-yes install \ + libgtk-3-dev:$CROSS_DEB_ARCH \ + libssl-dev:$CROSS_DEB_ARCH \ + libasound2-dev:$CROSS_DEB_ARCH +"""] + +[target.x86_64-unknown-linux-gnu] +image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:edge" + +[target.aarch64-unknown-linux-gnu] +image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge" diff --git a/psst-gui/Cargo.toml b/psst-gui/Cargo.toml index 07f4604d..1413dc89 100644 --- a/psst-gui/Cargo.toml +++ b/psst-gui/Cargo.toml @@ -36,13 +36,21 @@ ureq = { version = "2.8.0", features = ["json", "socks-proxy"] } url = { version = "2.4.1" } # GUI -druid = { git = "https://github.com/jpochyla/druid", branch = "psst", features = ["im", "image", "jpeg", "png", "serde"] } +druid = { git = "https://github.com/jpochyla/druid", branch = "psst", features = [ + "im", + "image", + "jpeg", + "png", + "serde", +] } druid-enums = { git = "https://github.com/jpochyla/druid-enums" } -druid-shell = { git = "https://github.com/jpochyla/druid", branch = "psst", features = ["raw-win-handle"] } +druid-shell = { git = "https://github.com/jpochyla/druid", branch = "psst", features = [ + "raw-win-handle", +] } open = { version = "5.0.0" } raw-window-handle = { version = "0.5.2" } # Must stay compatible with Druid souvlaki = { version = "0.6.1" } -webbrowser = {version = "0.8.11"} +webbrowser = { version = "0.8.11" } [target.'cfg(windows)'.build-dependencies] winres = { version = "0.1.12" } @@ -52,11 +60,11 @@ image = { version = "0.24.7" } name = "Psst" identifier = "com.jpochyla.psst" icon = [ - "assets/logo_32.png", - "assets/logo_64.png", - "assets/logo_128.png", - "assets/logo_256.png", - "assets/logo_512.png", + "assets/logo_32.png", + "assets/logo_64.png", + "assets/logo_128.png", + "assets/logo_256.png", + "assets/logo_512.png", ] version = "0.1.0" resources = [] diff --git a/psst-gui/src/data/playlist.rs b/psst-gui/src/data/playlist.rs index c96f5624..9d9b1363 100644 --- a/psst-gui/src/data/playlist.rs +++ b/psst-gui/src/data/playlist.rs @@ -27,7 +27,7 @@ pub struct PlaylistRemoveTrack { pub struct Playlist { pub id: Arc, pub name: Arc, - #[serde(skip_serializing_if="Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none")] pub images: Option>, pub description: Arc, #[serde(rename = "tracks")] @@ -46,9 +46,9 @@ impl Playlist { } pub fn image(&self, width: f64, height: f64) -> Option<&Image> { - self.images.as_ref().and_then(|images| { - Image::at_least_of_size(images, width, height) - }) + self.images + .as_ref() + .and_then(|images| Image::at_least_of_size(images, width, height)) } pub fn url(&self) -> String {