diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..21add24 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,93 @@ +name: Build and Release + +on: + workflow_dispatch: + +env: + VERSION: 0.1.0 + +jobs: + # Release build job + release: + permissions: write-all + strategy: + fail-fast: false + matrix: + platform: + [macos-latest, macos-13, ubuntu-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies (ubuntu only) + if: matrix.platform == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y build-essential curl libssl-dev + + - name: Rust setup + uses: dtolnay/rust-toolchain@stable + + - name: Rust cache + uses: swatinem/rust-cache@v2 + + - name: Install app dependencies + run: cargo install cargo-packager --locked + + - name: Package Binary + run: cargo packager --release --verbose + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform }}-release-artifacts + path: | + ${{ matrix.platform == 'macos-latest' && 'target/release/slightlybettertext.app' || '' }} + ${{ matrix.platform == 'macos-latest' && 'target/release/slightlybettertext_*_aarch64.dmg' || '' }} + ${{ matrix.platform == 'macos-13' && 'target/release/slightlybettertext.app' || '' }} + ${{ matrix.platform == 'macos-13' && 'target/release/slightlybettertext_*_x64.dmg' || '' }} + ${{ matrix.platform == 'ubuntu-latest' && 'target/release/PKGBUILD' || '' }} + ${{ matrix.platform == 'ubuntu-latest' && 'target/release/slightlybettertext_*_amd64.deb' || '' }} + ${{ matrix.platform == 'ubuntu-latest' && 'target/release/slightlybettertext_*_x86_64.AppImage' || '' }} + ${{ matrix.platform == 'windows-latest' && 'target/release/slightlybettertext_*_x64_en-US.msi' || '' }} + ${{ matrix.platform == 'windows-latest' && 'target/release/slightlybettertext_*_x64-setup.exe' || '' }} + + # Upload to GitHub release job + upload_to_release: + permissions: write-all + runs-on: ubuntu-latest + needs: release + steps: + - name: Download release artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Create attestation for all builds + uses: actions/attest-build-provenance@v2 + with: + subject-path: | + artifacts/PKGBUILD + artifacts/slightlybettertext_*_aarch64.dmg + artifacts/slightlybettertext_*_x64.dmg + artifacts/slightlybettertext_*_amd64.deb + artifacts/slightlybettertext_*_x86_64.AppImage + artifacts/slightlybettertext_*_x64_en-US.msi + artifacts/slightlybettertext_*_x64-setup.exe + + - name: Release to GitHub + uses: softprops/action-gh-release@v2 + with: + draft: true + generate_release_notes: true + tag_name: slightlybettertext v${{ env.VERSION }} + files: | + artifacts/PKGBUILD + artifacts/slightlybettertext_*_aarch64.dmg + artifacts/slightlybettertext_*_x64.dmg + artifacts/slightlybettertext_*_amd64.deb + artifacts/slightlybettertext_*_x86_64.AppImage + artifacts/slightlybettertext_*_x64_en-US.msi + artifacts/slightlybettertext_*_x64-setup.exe diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..b8ca72c --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,40 @@ +name: Test project + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + run: rustup update stable + + - name: Set up user environment on macOS + run: | + mkdir -p $HOME/Downloads + mkdir -p $HOME/Desktop + mkdir -p $HOME/Documents + echo "XDG_DOWNLOAD_DIR=$HOME/Downloads" >> $GITHUB_ENV + echo "XDG_DESKTOP_DIR=$HOME/Desktop" >> $GITHUB_ENV + echo "XDG_DOCUMENTS_DIR=$HOME/Documents" >> $GITHUB_ENV + echo "HOME_DIR set to $HOME" + ls -la $HOME # Verify the user directories + + - name: Build + run: cargo build --verbose --release --no-default-features + + - name: Run tests + run: cargo test --verbose --release -- --show-output + env: + IGNORE_PANICS: true \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 71e429c..2653c13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] directories = "6.0.0" global-hotkey = "0.6.3" -iced = { version = "0.13.1", features=["highlighter", "tokio", "debug"] } +iced = { version = "0.13.1", features=["highlighter", "tokio", "debug", "image"] } log = "0.4.25" rfd = "0.15.2" simplelog = "0.12.2" diff --git a/assets/fonts/icons.ttf b/src/assets/fonts/icons.ttf similarity index 100% rename from assets/fonts/icons.ttf rename to src/assets/fonts/icons.ttf diff --git a/src/assets/images/logo.svg b/src/assets/images/logo.svg new file mode 100644 index 0000000..d7dcf08 --- /dev/null +++ b/src/assets/images/logo.svg @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/assets/logo.ico b/src/assets/logo.ico new file mode 100644 index 0000000..89b2304 Binary files /dev/null and b/src/assets/logo.ico differ diff --git a/src/main.rs b/src/main.rs index ef2bf2f..9d8cbcb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,11 +3,12 @@ use iced::Font; use log::LevelFilter; use simplelog::TermLogger; use editor::editor::Editor; +use std::sync::LazyLock; + mod editor; static APP_NAME: &str = "SlightlyBetterText"; -use std::sync::LazyLock; - +static LOGO: &[u8] = include_bytes!("assets/logo.ico"); static START_KEY: LazyLock = LazyLock::new(|| HotKey { id: 19012025, key: Code::Space, mods: Modifiers::CONTROL | Modifiers::ALT }); #[cfg(debug_assertions)] @@ -33,11 +34,12 @@ pub fn main() -> iced::Result { let mut window_settings = iced::window::Settings::default(); window_settings.visible = true; + window_settings.icon = Some(iced::window::icon::from_file_data(LOGO, None).expect("Failed to load icon")); iced::application(APP_NAME, Editor::update, Editor::view) .subscription(Editor::subscription) .theme(Editor::theme) - .font(include_bytes!("../assets/fonts/icons.ttf").as_slice()) + .font(include_bytes!("assets/fonts/icons.ttf").as_slice()) .default_font(Font::MONOSPACE) .centered() .window(window_settings)