From 6ee9c1ef9e284805c0867777d49bcaee58ec7bea 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 | 79 +++++++++++++++++++++++++++++++++++++ Cargo.toml | 6 ++- src/input/data.rs | 3 +- src/output/generator.rs | 4 +- 4 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c76b0cf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,79 @@ +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 }} + release: + runs-on: ubuntu-latest + needs: build + if: startsWith(github.ref, 'refs/tags/') + + steps: + - name: Download All Artifacts + uses: actions/download-artifact@v4 + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: | + ./wiki-extractor-* diff --git a/Cargo.toml b/Cargo.toml index d3faee9..bb90937 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wiki-extractor" -version = "0.1.5" +version = "0.1.6" edition = "2021" description = "Wikipedia dump download and cleanup tool" authors = ["Tin Švagelj "] @@ -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;