Skip to content

Commit

Permalink
Update cicd pipeline and odm-cli script
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielefantiniblindata committed Feb 14, 2025
1 parent d2e7b0f commit 8b251a7
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 85 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ jobs:
run: |
JAR_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "JAR_VERSION=${JAR_VERSION}" >> $GITHUB_ENV
- name: Inject Version into odm-cli script
run: |
sed -i "s/VERSION=\"latest\"/VERSION=\"${{ env.JAR_VERSION }}\"/" odm-cli
- name: Upload JAR to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: target/odm-cli-${{ env.JAR_VERSION }}.jar
files: |
target/odm-cli-${{ env.JAR_VERSION }}.jar
odm-cli
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,43 @@

## About

This repository is the home of the Open Data Mesh CLI.
The Open Data Mesh Command Line tool provides a range of functionalities to support users within the Open Data Mesh
ecosystem. Key features include an efficient way to create, validate, and manage data product descriptors, ensuring
compliance with Open Data Mesh standards.

## Installation
## Setup

Download the cli
---
To run the application properly, you must have a Java JDK installed.

```bash
echo TODO
```
- **Linux**
```sh
sudo apt update && sudo apt install -y openjdk-17-jdk
```
- **Windows**
```powershell
winget install --id Oracle.JDK.17 -e
```

---

or compile it from the code
Download the cli.

```bash
git clone git@github.com:opendatamesh-initiative/odm-platform.git
cd odm-cli
mvn clean package spring-boot:repackage
cd odm-cli
wget -qO odm-cli $(wget -qO- https://api.github.com/repos/opendatamesh-initiative/odm-cli/releases/latest | grep "browser_download_url.odm-cli" | cut -d '"' -f 4)
```

test the cli
---
Test the cli.

```bash
./odmcli --version
```

## Configuration

By default, the `odmcli` stores its configuration files in a directory called `.odmcli` within your `$HOME` directory.

`odmcli` manages most of the files in the configuration directory and you shouldn't modify them. However, you can modify
the `config.json` file to control certain aspects of how the `odmcli` command behaves.

You can modify the `odmcli` command behavior using environment variables or command-line options. You can also use
options within `config.json` to modify some of the same behavior. If an environment variable and the `--config` flag are
set, the flag precedes the environment variable. Command line options override environment variables and environment
variables override properties you specify in a `config.json` file.
By default, the `odmcli` stores its configuration file in a directory called `.odmcli` within your `$HOME` directory.
The

## Usage

Expand Down
86 changes: 86 additions & 0 deletions odm-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/bash
REPO_URL="https://github.com/opendatamesh-initiative/odm-cli"
API_URL="https://api.github.com/repos/opendatamesh-initiative/odm-cli/releases/latest"
INSTALL_DIR="$HOME/.odmcli"
EXTENSIONS_DIR="$INSTALL_DIR/extensions"
VERSION_FILE="$INSTALL_DIR/version.txt"
CONFIG_FILE="$INSTALL_DIR/application.yml"

# Version injected during release, fallback if not replaced
VERSION="latest"

# Get the latest version if not explicitly set
if [[ "$VERSION" == "latest" ]]; then
echo "Fetching the latest release version..."
VERSION=$(wget -qO- "$API_URL" | grep '"tag_name":' | cut -d '"' -f 4 | sed 's/[^0-9.]//g')
fi

mkdir -p "$INSTALL_DIR" "$EXTENSIONS_DIR"
cd "$INSTALL_DIR"

# Set JAR file name
JAR_NAME="odm-cli-${VERSION}.jar"

# Check if the specified version is already installed
if [[ -f "$VERSION_FILE" && "$(cat "$VERSION_FILE")" == "$VERSION" && -f "$JAR_NAME" ]]; then
echo "Version $VERSION is already installed."
else
echo "Downloading version: $VERSION"
DOWNLOAD_URL="https://github.com/opendatamesh-initiative/odm-cli/releases/download/v${VERSION}/${JAR_NAME}"

if wget --spider "$DOWNLOAD_URL" 2>/dev/null; then
wget -O "$JAR_NAME" "$DOWNLOAD_URL"
echo "$VERSION" > "$VERSION_FILE"
echo "JAR downloaded successfully: $JAR_NAME"
else
echo "Error: Unable to download version $VERSION. Please check the release version."
exit 1
fi
fi

# Check if JAR file exists before executing
if [[ ! -f "$JAR_NAME" ]]; then
echo "Error: JAR file $JAR_NAME not found. Exiting."
exit 1
fi

# Check for newer versions
LATEST_VERSION=$(wget -qO- "$API_URL" | grep '"tag_name":' | cut -d '"' -f 4 | sed 's/[^0-9.]//g')
if [[ "$VERSION" != "$LATEST_VERSION" ]]; then
echo "A newer version ($LATEST_VERSION) is available. Consider upgrading!"
fi

# Read extensions from application.yml (if exists)
if [[ -f "$CONFIG_FILE" ]]; then
echo "Reading extensions from $CONFIG_FILE"
grep "url:" "$CONFIG_FILE" | awk '{print $2}' | while read -r EXT_URL; do
EXT_NAME=$(basename "$EXT_URL")
EXT_PATH="$EXTENSIONS_DIR/$EXT_NAME"

if [[ -f "$EXT_PATH" ]]; then
echo "Extension $EXT_NAME already exists. Skipping download."
else
echo "Downloading extension: $EXT_NAME"
wget -O "$EXT_PATH" "$EXT_URL"
fi
done
fi

# Construct Java command
JAVA_CMD="java"

# Add external configuration as a system property if application.yml exists
if [[ -f "$CONFIG_FILE" ]]; then
JAVA_CMD+=" -Dspring.config.additional-location=file:$CONFIG_FILE"
fi

# Add loader path if extensions exist
if [[ -d "$EXTENSIONS_DIR" && "$(ls -A "$EXTENSIONS_DIR")" ]]; then
JAVA_CMD+=" -Dloader.path=$EXTENSIONS_DIR"
fi

# Ensure JAR is correctly referenced
JAVA_CMD+=" -jar $JAR_NAME"

# Run odm-cli with optional arguments
eval "$JAVA_CMD" "$@"
63 changes: 0 additions & 63 deletions odm-cliw

This file was deleted.

0 comments on commit 8b251a7

Please sign in to comment.