From 5785c5d969c7dbb71179a92ffa8856e107453df0 Mon Sep 17 00:00:00 2001 From: Matt Burridge <81111055+mburridge96@users.noreply.github.com> Date: Thu, 21 Nov 2024 13:10:14 +0000 Subject: [PATCH] Updated CI for cli tool deployment. Improved docs for graph_vector refactor --- .github/workflows/cli.yml | 106 ++++++++++++++++++++++++++++++----- .github/workflows/python.yml | 5 ++ Cargo.lock | 4 +- Cargo.toml | 2 +- cli/Cargo.toml | 4 +- cli/README.md | 9 +++ docs/ro-crate-schema.svg | 5 -- docs/ro-crate-schmea.svg | 10 ++++ python/Cargo.toml | 2 +- 9 files changed, 121 insertions(+), 26 deletions(-) delete mode 100644 docs/ro-crate-schema.svg create mode 100644 docs/ro-crate-schmea.svg diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index e2b6712..f3936e5 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -1,28 +1,104 @@ -# .github/workflows/release.yml +name: Release Rust CLI on: push: + branches: [ "main" ] + tags: + - '*' + pull_request: + branches: [ "main" ] + workflow_run: + workflows: + - Rust + types: + - completed + workflow_run: + workflows: + - Rust + types: + - completed jobs: - release: - name: release ${{ matrix.target }} - runs-on: ubuntu-latest + build-and-release: strategy: - fail-fast: false matrix: include: - - target: x86_64-pc-windows-gnu + - platform: windows + rust_target: x86_64-pc-windows-gnu archive: zip - - target: x86_64-unknown-linux-musl - archive: tar.gz tar.xz tar.zst - - target: x86_64-apple-darwin + runs-on: ubuntu-latest + - platform: linux-tar-gz + rust_target: x86_64-unknown-linux-musl + archive: tar.gz + runs-on: ubuntu-latest + - platform: linux-tar-xz + rust_target: x86_64-unknown-linux-musl + archive: tar.xz + runs-on: ubuntu-latest + - platform: linux-tar-zst + rust_target: x86_64-unknown-linux-musl + archive: tar.zst + runs-on: ubuntu-latest + - platform: macos + rust_target: x86_64-apple-darwin archive: zip + runs-on: macos-latest + + runs-on: ${{ matrix.runs-on }} + steps: - - uses: actions/checkout@master - - name: Compile and release - uses: rust-build/rust-build.action@v1.4.5 + # Checkout the repository + - name: Checkout repository + uses: actions/checkout@v4 + + # Install Rust + - name: Install Rust + run: | + rustup install stable + rustup target add ${{ matrix.rust_target }} + + # Build CLI tool + - name: Build CLI tool + run: | + if [[ "${{ matrix.runs-on }}" == "macos-latest" ]]; then + cd cli && cargo build --release --target=${{ matrix.rust_target }} + else + cargo install cross + cd cli && cross build --release --target=${{ matrix.rust_target }} + fi + cd ../ && mkdir -p dist/${{ matrix.platform }} + + # Package the binary + - name: Package Binary + run: | + BINARY=target/${{ matrix.rust_target }}/release/rocraters + WIN_BINARY=target/${{ matrix.rust_target }}/release/rocraters.exe + ARCHIVE=dist/${{ matrix.platform }}/rocraters-${{ matrix.rust_target }}.${{ matrix.archive }} + if [[ "${{ matrix.archive }}" == "zip" ]]; then + if [[ "${{ matrix.platform }}" == "windows" ]]; then + zip -j $ARCHIVE $WIN_BINARY + else + zip -j $ARCHIVE $BINARY + fi + elif [[ "${{ matrix.archive }}" == "tar.gz" ]]; then + tar -czvf $ARCHIVE -C target/${{ matrix.rust_target }}/release rocraters + elif [[ "${{ matrix.archive }}" == "tar.xz" ]]; then + tar -cJvf $ARCHIVE -C target/${{ matrix.rust_target }}/release rocraters + elif [[ "${{ matrix.archive }}" == "tar.zst" ]]; then + tar --zstd -cvf $ARCHIVE -C target/${{ matrix.rust_target }}/release rocraters + fi + + # Upload artifacts + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: rocraters-${{ matrix.platform }}-${{ matrix.archive }} + path: dist/${{ matrix.platform }}/* + + - name: Create GitHub Release + if: github.ref_type == 'tag' + uses: softprops/action-gh-release@v1 + with: + files: dist/${{ matrix.platform }}/* env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - RUSTTARGET: ${{ matrix.target }} - ARCHIVE_TYPES: ${{ matrix.archive }} diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index c98121e..5630de6 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -7,6 +7,11 @@ on: - '*' pull_request: branches: [ "main" ] + workflow_run: + workflows: + - Rust + types: + - completed env: PACKAGE_NAME: rocraters diff --git a/Cargo.lock b/Cargo.lock index 751a272..dfb4949 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -958,7 +958,7 @@ dependencies = [ [[package]] name = "ro-crate-rs" -version = "0.4.6" +version = "0.4.7" dependencies = [ "chrono", "rand", @@ -974,7 +974,7 @@ dependencies = [ [[package]] name = "ro-crate-rs-cli" -version = "0.4.5" +version = "0.4.6" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index d37f5a7..daf832e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ro-crate-rs" -version = "0.4.6" +version = "0.4.7" edition = "2021" repository = "https://github.com/intbio-ncl/ro-crate-rs" authors = ["Matt Burridge "] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 684a92e..0ae7e56 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ro-crate-rs-cli" -version = "0.4.5" +version = "0.4.6" edition = "2021" repository = "https://github.com/intbio-ncl/ro-crate-rs" authors = ["Matt Burridge "] @@ -13,7 +13,7 @@ categories = ["command-line-utilities"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ro-crate-rs = {path = "../"} +ro-crate-rs = {path = "../", version = "0.4.7"} clap = { version = "4.4.16", features = ["derive"] } chrono = "0.4" serde_json = "1.0" diff --git a/cli/README.md b/cli/README.md index a2b3175..eb81ec6 100644 --- a/cli/README.md +++ b/cli/README.md @@ -5,3 +5,12 @@ The ro-crate-rs cli tool can be used to immediately interface with RO-Crates wit # Basics This cli allows basic interaction with an RO-Crate, such as reading, writing, updating, validating and so on. + +# Installion + +Via Cargo (need rust installed): +``` +cargo install ro-crate-rs-cli +``` + +Or via github release page, choose your target platform and download the binary. Once download it can be used in whichever command line you choose. diff --git a/docs/ro-crate-schema.svg b/docs/ro-crate-schema.svg deleted file mode 100644 index c2cec5f..0000000 --- a/docs/ro-crate-schema.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - CreateReadInitialisationrocrate.rsread.rsDeserialiseRoCratedatastructure context:RoCrateContextgraph: Vec<GraphVector>MetadataDescriptorRootDataEntityDataEntityContextualEntityFallbackValuewrite.rsro-crate-metadata.jsoncrate.zipWriteSerialisedata_entity.rscontextual_entity.rsroot.rsmetadata_descriptor.rsEmbedded ContextExtended ContextReference Contextmodify.rs(focused on dynamic_entites)contraints.rsschema.rsDeserialiseValidateFileStruct FieldData structureReferencesrelated toKeyDeserialise / serialiseSerde Lib \ No newline at end of file diff --git a/docs/ro-crate-schmea.svg b/docs/ro-crate-schmea.svg new file mode 100644 index 0000000..79af0cc --- /dev/null +++ b/docs/ro-crate-schmea.svg @@ -0,0 +1,10 @@ + + + + + + + + CreateReadInitialisationrocrate.rsread.rsDeserialiseRoCratedatastructure context:RoCrateContextgraph:Vec<GraphVector>MetadataDescriptorRootDataEntityDataEntityContextualEntitywrite.rsro-crate-metadata.jsoncrate.zipWriteSerialisedata_entity.rscontextual_entity.rsroot.rsmetadata_descriptor.rsEmbedded ContextExtended ContextReference Contextmodify.rs(focused on dynamic_entites)contraints.rsschema.rsDeserialiseValidateFileStruct FieldData structureReferencesrelated toKeyDeserialise / serialiseSerde Lib \ No newline at end of file diff --git a/python/Cargo.toml b/python/Cargo.toml index 3c20aae..a8e9b5f 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rocraters-python" -version = "0.4.1" +version = "0.4.2" edition = "2021" authors = ["Matt Burridge "] description = "Lightweight Python library for RO-Crate manipulation implemented in Rust"