From df4802c98f0d5cd646e80e444973ab0537c6f004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20=C5=A0vagelj?= Date: Sat, 22 Jun 2024 00:22:15 +0200 Subject: [PATCH] Add CI/CD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tin Å vagelj --- .github/workflows/build.yml | 65 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 23 +++++++++++++ Cargo.toml | 4 +++ src/input/data.rs | 3 +- src/output/generator.rs | 4 +-- 5 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..99b8edc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,65 @@ +name: Build + +on: + push: + branches: + - trunk + +jobs: + build: + name: Build - ${{ matrix.platform.release_for }} + runs-on: ${{ matrix.platform.os }} + strategy: + matrix: + platform: + - release_for: ARM64 Linux + os: ubuntu-latest + target: aarch64-unknown-linux-gnu + bin: wiki-extractor + name: wiki-extractor-gnu-linux-aarch64 + - release_for: 32-bit MSVC + os: windows-latest + target: i686-pc-windows-msvc + bin: wiki-extractor.exe + name: wiki-extractor-windows-i686.exe + - release_for: 32-bit Linux + os: ubuntu-latest + target: i686-unknown-linux-gnu + bin: wiki-extractor + name: wiki-extractor-gnu-linux-i686 + - release_for: 64-bit macOS + os: macos-latest + target: x86_64-apple-darwin + bin: wiki-extractor + name: wiki-extractor-darwin-x86_64 + - release_for: 64-bit MSVC + os: windows-latest + target: x86_64-pc-windows-msvc + bin: wiki-extractor.exe + name: wiki-extractor-windows-x86_64.exe + - release_for: 64-bit Linux + os: ubuntu-latest + target: x86_64-unknown-linux-gnu + bin: wiki-extractor + name: wiki-extractor-gnu-linux-x86_64 + - release_for: 64-bit FreeBSD + os: ubuntu-latest + target: x86_64-unknown-freebsd + bin: wiki-extractor + name: wiki-extractor-freebsd-x86_64 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly + - uses: clechasseur/rs-cargo@v2 + with: + command: build + args: --release --all-features + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.platform.name }} + path: target/release/${{ matrix.platform.bin }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1ad7869 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +name: Release + +on: + workflow_run: + workflows: ["Build"] + types: + - completed + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Download Artifacts + uses: actions/download-artifact@v4 + + - name: Create GitHub Release + id: create_release + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v2 + with: + files: | + ./wiki-extractor-* diff --git a/Cargo.toml b/Cargo.toml index d3faee9..ed3918a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,3 +35,7 @@ itertools = "0.13" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" + +[profile.release] +strip = "symbols" +lto = true diff --git a/src/input/data.rs b/src/input/data.rs index 250b238..6434a47 100644 --- a/src/input/data.rs +++ b/src/input/data.rs @@ -3,7 +3,6 @@ use std::{ fmt::Display, fs::File, io::{ErrorKind, Seek}, - os::unix::ffi::OsStrExt, path::{Path, PathBuf}, str::FromStr, }; @@ -235,7 +234,7 @@ impl TryFrom<&Path> for FileName { }, ) })? - .as_bytes() + .as_encoded_bytes() .to_vec(), ) .map_err(|it| std::io::Error::new(ErrorKind::InvalidData, it.utf8_error()))?, diff --git a/src/output/generator.rs b/src/output/generator.rs index 75a6b0a..18353d9 100644 --- a/src/output/generator.rs +++ b/src/output/generator.rs @@ -2,10 +2,10 @@ use std::{ collections::HashSet, fs::File, io::{ErrorKind, Write as _}, - path::{Path, PathBuf}, sync::Arc, future::IntoFuture, + path::{Path, PathBuf}, sync::Arc, }; -use futures::{Future, future::BoxFuture}; +use futures::future::BoxFuture; use itertools::Itertools; use parse_wiki_text_2::Configuration as MediawikiConfig;