Skip to content

Commit

Permalink
Merge pull request #8 from Kosette:feature/ci
Browse files Browse the repository at this point in the history
fix: call mpv failed when opening app from Finder
  • Loading branch information
tsukinaha authored Mar 27, 2024
2 parents 91ce1a0 + 7814110 commit 4052f85
Show file tree
Hide file tree
Showing 18 changed files with 229 additions and 203 deletions.
75 changes: 5 additions & 70 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ jobs:
strategy:
matrix:
include:
# x86_64-windows-msvc
- arch: x86_64-windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
artifact: tsukimi.exe
ext: .exe
# x86_64-windows-gnu
- arch: x86_64-windows-gnu
os: windows-latest
target: x86_64-pc-windows-gnu
artifact: tsukimi.exe
ext: .exe
# x86_64-linux-gnu
- arch: x86_64-linux-gnu
os: ubuntu-latest
Expand All @@ -46,51 +34,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Build ${{ matrix.target }}
if: ${{ matrix.target == 'x86_64-pc-windows-msvc' }}
run: |
rustup default stable-msvc
py -3.12 -m pip install --user pipx
py -3.12 -m pipx ensurepath
pipx install gvsbuild
$env:Path = "C:\gtk-build\gtk\x64\release\lib\pkgconfig;C:\gtk-build\gtk\x64\release\bin;C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\msys64\mingw64\lib;C:\msys64\mingw64\include;" + $env:Path
$env:LIB = "C:\gtk-build\gtk\x64\release\lib;C:\msys64\mingw64\lib;" + $env:LIB
$env:INCLUDE = "C:\gtk-build\gtk\x64\release\include;C:\gtk-build\gtk\x64\release\include\cairo;C:\gtk-build\gtk\x64\release\include\glib-2.0;C:\gtk-build\gtk\x64\release\include\gobject-introspection-1.0;C:\gtk-build\gtk\x64\release\lib\glib-2.0\include;C:\msys64\mingw64\include;" + $env:INCLUDE
$env:PKG_CONFIG_PATH = "C:\gtk-build\gtk\x64\release\lib\pkgconfig;" + $env:PKG_CONFIG_PATH
gvsbuild build gtk4 libadwaita adwaita-icon-theme
cargo build --release --locked --target ${{ matrix.target }}
mkdir artifact
cp target/${{matrix.target}}/release/${{ matrix.artifact }} artifact/tsukimi-${{ matrix.arch }}${{ matrix.ext }}
cp C:\gtk-build\gtk\x64\release\bin\*.dll artifact/
compress-archive -path artifact/* -destination artifact/tsukimi-${{matrix.arch}}.zip
- name: Build ${{ matrix.target }}
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
run: |
rustup toolchain install stable-gnu
rustup default stable-gnu
C:\msys64\usr\bin\pacman.exe -S --needed --noconfirm mingw-w64-x86_64-gtk4 mingw-w64-x86_64-gettext mingw-w64-x86_64-libxml2 mingw-w64-x86_64-librsvg mingw-w64-x86_64-pkgconf mingw-w64-x86_64-gcc mingw-w64-x86_64-libadwaita
C:\msys64\usr\bin\pacman.exe -Syu --noconfirm
- name: Build ${{ matrix.target }}
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
run: |
$env:Path = "C:\msys64\mingw64\bin;C:\msys64\mingw64\lib;C:\msys64\mingw64\include;" + $env:Path;
cargo build --release --locked --target ${{ matrix.target }}
mkdir artifact/
cp target/${{matrix.target}}/release/${{ matrix.artifact }} artifact/tsukimi-${{ matrix.arch }}${{ matrix.ext }}
cp C:/msys64/mingw64/bin/*.dll artifact
compress-archive -path artifact/* -destination artifact/tsukimi-${{matrix.arch}}.zip
- name: Build ${{matrix.target}}
if: ${{matrix.target == 'x86_64-unknown-linux-gnu'}}
run: |
mkdir artifact
docker build -t tsukimi .
docker run -d --name tsukimi tsukimi
docker cp tsukimi:/usr/src/tsukimi/. artifact/
cd artifact
tar -czf tsukimi-${{matrix.arch}}.tar.gz tsukimi
- name: Build ${{matrix.target}}
if: ${{matrix.target == 'x86_64-apple-darwin'}}
Expand All @@ -101,17 +51,13 @@ jobs:
cargo build --release --locked --target ${{matrix.target}}
mkdir artifact
cp target/${{matrix.target}}/release/${{matrix.artifact}} artifact/
cd artifact/
tar -czf tsukimi-${{matrix.arch}}.tar.gz ./*
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: tsukimi-${{matrix.arch}}
path: |
artifact/*.deb
artifact/tsukimi-*.zip
artifact/tsukimi-*.tar.gz
artifact/*
compression-level: 0

publish:
Expand All @@ -129,31 +75,21 @@ jobs:

- name: Package MacOS x86_64
run: |
tar -xzf tsukimi-x86_64-apple-darwin/tsukimi-x86_64-apple-darwin.tar.gz
mkdir -p Tsukimi.app/Contents/MacOS
mkdir -p Tsukimi.app/Contents/Resources
cp share/macos/Info.plist Tsukimi.app/Contents/
cp share/macos/AppIcon.icns Tsukimi.app/Contents/Resources/
mv tsukimi Tsukimi.app/Contents/MacOS/
mv tsukimi-x86_64-apple-darwin/tsukimi Tsukimi.app/Contents/MacOS/
tar -czf tsukimi-x86_64-apple-darwin.tar.gz Tsukimi.app/
- name: Package Windows GNU
run: |
mv tsukimi-x86_64-windows-gnu/*.zip .
- name: Package Windows MSVC
run: |
mv tsukimi-x86_64-windows-msvc/*.zip .
- name: Package Linux GNU
run: |
mv tsukimi-x86_64-linux-gnu/*.tar.gz .
mv tsukimi-x86_64-linux-gnu/*.deb .
mv tsukimi-x86_64-linux-gnu/* .
tar -czf tsukimi-x86_64-linux-gnu.tar.gz tsukimi
- name: Calculate hash
run: |
sha512sum *.zip > tsukimi.sha512sum
sha512sum *.tar.gz >> tsukimi.sha512sum
sha512sum *.tar.gz > tsukimi.sha512sum
sha512sum *.deb >> tsukimi.sha512sum
- name: Get latest tag name
Expand All @@ -165,7 +101,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
*.zip
*.tar.gz
*.deb
tsukimi.sha512sum
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ fn main() {
"resources/resources.gresource.xml",
"tsukimi.gresource",
);
}
}
35 changes: 34 additions & 1 deletion share/macos/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleDisplayName</key>
<string>Tsukimi</string>
<key>CFBundleIdentifier</key>
<string>com.inaha.tsukimi</string>
<string>moe.tsuna.tsukimi</string>
<key>CFBundleExecutable</key>
<string>tsukimi</string>
<key>CFBundleIconFile</key>
Expand All @@ -20,6 +20,39 @@
<key>LSMinimumSystemVersion</key>
<string>12.7.3</string>

<!-- 网络权限 -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

<!-- 读写用户目录权限 -->
<key>NSHomeDirectory</key>
<string>Tsukimi needs to store user token and cache</string>

<!-- 访问其他应用权限 -->
<key>NSAppleEventsUsageDescription</key>
<string>Tsukimi needs to control MPV player to play videos</string>

<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Services</string>
</dict>
<key>NSMessage</key>
<string>runningServiceCommand</string>
<key>NSRequiredContext</key>
<dict>
<key>NSApplicationActivationBundleID</key>
<string>io.mpv</string>
</dict>
</dict>
</array>

<key>CFBundleVersion</key>
<string>0.0.3</string>
<key>CFBundleShortVersionString</key>
Expand Down
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ const APP_ID: &str = "moe.tsuna.tsukimi";

fn main() -> glib::ExitCode {
// Register and include resources
gio::resources_register_include!("tsukimi.gresource")
.expect("Failed to register resources.");
gio::resources_register_include!("tsukimi.gresource").expect("Failed to register resources.");

// Create a new application
let app = adw::Application::builder().application_id(APP_ID).build();
Expand All @@ -19,4 +18,4 @@ fn main() -> glib::ExitCode {

// Run the application
app.run()
}
}
8 changes: 4 additions & 4 deletions src/ui/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn set_image(id: String, mutex: Arc<Mutex<()>>) -> Box {
let imgbox = Box::new(Orientation::Vertical, 5);

let (sender, receiver) = async_channel::bounded::<String>(1);

let image = gtk::Picture::new();
image.set_halign(gtk::Align::Fill);
image.set_content_fit(gtk::ContentFit::Cover);
Expand Down Expand Up @@ -180,7 +180,7 @@ pub fn set_backdropimage(id: String, mutex: Arc<Mutex<()>>) -> Box {
while let Ok(_) = receiver.recv().await {
let path = format!("{}/.local/share/tsukimi/{}.png",dirs::home_dir().expect("msg").display(), idfuture);
let file = gtk::gio::File::for_path(&path);
image.set_file(Some(&file));
image.set_file(Some(&file));
revealer.set_reveal_child(true);
}
}));
Expand All @@ -189,7 +189,7 @@ pub fn set_backdropimage(id: String, mutex: Arc<Mutex<()>>) -> Box {
imgbox
}

pub fn setimage(id: String,mutex: Arc<Mutex<()>>) -> Revealer {
pub fn setimage(id: String, mutex: Arc<Mutex<()>>) -> Revealer {
let (sender, receiver) = async_channel::bounded::<String>(1);

let image = gtk::Picture::new();
Expand Down Expand Up @@ -248,7 +248,7 @@ pub fn setimage(id: String,mutex: Arc<Mutex<()>>) -> Revealer {
revealer
}

pub fn setlogoimage(id: String,mutex: Arc<Mutex<()>>) -> Revealer {
pub fn setlogoimage(id: String, mutex: Arc<Mutex<()>>) -> Revealer {
let (sender, receiver) = async_channel::bounded::<String>(1);

let image = gtk::Picture::new();
Expand Down
4 changes: 2 additions & 2 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
mod provider;
mod image;
mod moviedrop;
mod network;
mod new_dropsel;
mod provider;
mod widgets;
mod moviedrop;
use gtk::gdk::Display;
use gtk::{prelude::*, CssProvider};

Expand Down
25 changes: 17 additions & 8 deletions src/ui/moviedrop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::network::SearchResult;
use gtk::prelude::*;
use gtk::Orientation;

pub fn newmediadropsel(playbackinfo: network::Media,info:SearchResult) -> gtk::Box {
pub fn newmediadropsel(playbackinfo: network::Media, info: SearchResult) -> gtk::Box {
let hbox = gtk::Box::new(Orientation::Horizontal, 5);
let leftvbox = gtk::Box::new(Orientation::Vertical, 5);
leftvbox.set_margin_start(80);
Expand Down Expand Up @@ -73,7 +73,9 @@ pub fn newmediadropsel(playbackinfo: network::Media,info:SearchResult) -> gtk::B
let playbutton = gtk::Button::with_label("播放");
playbutton.connect_clicked(move |_| {
let nameselected = namedropdown.selected_item();
let nameselected = nameselected.and_downcast_ref::<gtk::StringObject>().unwrap();
let nameselected = nameselected
.and_downcast_ref::<gtk::StringObject>()
.unwrap();
let nameselected = nameselected.string();
let subselected = subdropdown.selected_item();
if subselected.is_none() {
Expand All @@ -83,9 +85,9 @@ pub fn newmediadropsel(playbackinfo: network::Media,info:SearchResult) -> gtk::B
let name = info.Id.clone();
let sourceid = media.Id.clone();
network::runtime().spawn(async move {
let _ = network::markwatched(name,sourceid).await;
let _ = network::markwatched(name, sourceid).await;
});
network::mpv_play(directurl.expect("no url"),media.Name.clone());
network::mpv_play(directurl.expect("no url"), media.Name.clone());
}
}
return;
Expand All @@ -104,16 +106,23 @@ pub fn newmediadropsel(playbackinfo: network::Media,info:SearchResult) -> gtk::B
let name = info.Id.clone();
let sourceid = media.Id.clone();
network::runtime().spawn(async move {
let _ = network::markwatched(name,sourceid).await;
let _ = network::markwatched(name, sourceid).await;
});
let _ = network::mpv_play_withsub(directurl.expect("no url"),suburl.expect("no url"),media.Name.clone());
let _ = network::mpv_play_withsub(
directurl.expect("no url"),
suburl.expect("no url"),
media.Name.clone(),
);
} else {
let name = info.Id.clone();
let sourceid = media.Id.clone();
network::runtime().spawn(async move {
let _ = network::markwatched(name,sourceid).await;
let _ = network::markwatched(name, sourceid).await;
});
let _ = network::mpv_play(directurl.expect("no url"),media.Name.clone());
let _ = network::mpv_play(
directurl.expect("no url"),
media.Name.clone(),
);
}
}
}
Expand Down
Loading

0 comments on commit 4052f85

Please sign in to comment.