diff --git a/.github/release-please-config.json b/.github/release-please-config.json new file mode 100644 index 0000000..c1f3bcf --- /dev/null +++ b/.github/release-please-config.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "package-name": "mmt", + "release-type": "rust", + "extra-files": [ + { + "path": "README.md", + "type": "generic" + } + ] + } + } +} \ No newline at end of file diff --git a/.github/release-please-manifest.json b/.github/release-please-manifest.json new file mode 100644 index 0000000..cd7caa8 --- /dev/null +++ b/.github/release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.0" +} \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..23fece2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,88 @@ +name: CI + +on: + push: + branches: [main, master] + pull_request: {} + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -C debuginfo=0 + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Check formatting + run: cargo fmt --all --check + - name: Run Clippy + run: cargo clippy --all -- -D warnings + + release_please: + name: Release Management + needs: [check] + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + - uses: actions/checkout@v4 + - name: Create Release + id: release + uses: googleapis/release-please-action@v4 + with: + config-file: .github/release-please-config.json + manifest-file: .github/release-please-manifest.json + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish: + name: Publish for ${{ matrix.os }} + needs: release_please + if: ${{ needs.release_please.outputs.release_created == 'true' }} + strategy: + matrix: + os: [ubuntu-22.04, ubuntu-24.04] + runs-on: ${{ matrix.os }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y dh-make + + - name: Install cargo-deb + run: cargo install cargo-deb + + - name: Build and Package + run: | + cargo deb -v + + VERSION="${{ needs.release_please.outputs.tag_name }}" + VERSION=${VERSION#v} + mv target/debian/*.deb "./target/mmt_${VERSION}_amd64_${{ matrix.os }}.deb" + cd target/release + tar -czf "../../target/mmt_${VERSION}_amd64_${{ matrix.os }}.tar.gz" mmt + + - name: Upload Release Artifacts + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload --clobber ${{ needs.release_please.outputs.tag_name }} \ + ./target/*.deb \ + ./target/*.tar.gz \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index f0ca9a3..b7fefde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -874,7 +874,7 @@ dependencies = [ [[package]] name = "mmtui" -version = "0.1.1" +version = "0.2.0" dependencies = [ "crossterm", "ratatui", diff --git a/Cargo.toml b/Cargo.toml index 09027de..26604de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mmtui" -version = "0.1.1" +version = "0.2.0" edition = "2021" authors = ["Lutsai Aleksandr "] description = "Terminal User Interface disk mount manager for TUI file managers" diff --git a/src/main.rs b/src/main.rs index f0b57c9..4ee7137 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,7 +32,7 @@ async fn main() -> udisks2::Result<()> { loop { if let Ok(drv) = drives::collect_all(&config).await { s.lock().await.clone_from(&drv); - }; + } tokio::time::sleep(Duration::from_millis(500)).await; } }); @@ -53,7 +53,7 @@ async fn main() -> udisks2::Result<()> { if key.kind == KeyEventKind::Press { match tui.input(key).await { - InputResult::None => continue, + InputResult::None => {} InputResult::Quit => break, InputResult::QuitChangeDirectory(p) => { output_change_path = p; diff --git a/src/tui.rs b/src/tui.rs index 5d790a7..b8d8942 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -4,9 +4,7 @@ use ratatui::{ layout::{Alignment, Constraint, Layout}, style::Color, text::Line, - widgets::{ - Block, BorderType, Padding, Paragraph, Row, Table, TableState, Widget, Wrap, - }, + widgets::{Block, BorderType, Padding, Paragraph, Row, Table, TableState, Widget, Wrap}, Frame, }; @@ -132,11 +130,7 @@ impl Tui { .row_highlight_style(Color::Green) .highlight_symbol(">"); - frame.render_stateful_widget( - table, - block.inner(layout[0]), - &mut self.ts, - ); + frame.render_stateful_widget(table, block.inner(layout[0]), &mut self.ts); let descr = match &self.selected { Some(s) => {