Added compare for windows #74
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MetricsHub Version Check | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Enter the version to compare' | |
required: true | |
default: '0.9.0000-SNAPSHOT' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Run MetricsHub and get version | |
id: get_version | |
run: | | |
cd artifacts/metricshub/bin | |
VERSION_OUTPUT=$(./metricshub --version) | |
echo "$VERSION_OUTPUT" | |
# Extract the version number using grep and regex | |
AGENT_VERSION=$(echo "$VERSION_OUTPUT" | grep -oP '(?<=MetricsHub Agent version )[\d.-]+-SNAPSHOT') | |
echo "MetricsHub Agent version: $AGENT_VERSION" | |
echo "::set-output name=agent_version::$AGENT_VERSION" | |
shell: bash | |
- name: Compare versions | |
run: | | |
INPUT_VERSION="${{ github.event.inputs.version }}" | |
AGENT_VERSION="${{ steps.get_version.outputs.agent_version }}" | |
if [ "$INPUT_VERSION" = "$AGENT_VERSION" ]; then | |
echo "The input version matches the current MetricsHub Agent version." | |
else | |
echo "The input version does not match the current MetricsHub Agent version." | |
exit 1 | |
fi | |
shell: bash | |
sanity-check-windows: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Java | |
uses: actions/setup-java@v1 | |
with: | |
java-version: '17' | |
- name: Run MetricsHub and get version | |
id: get_version_windows | |
run: | | |
cd artifacts/metricshub/bin | |
$VERSION_OUTPUT = ./metricshub.exe --version | |
echo $VERSION_OUTPUT | |
# Extract the version number using PowerShell regex | |
$AGENT_VERSION = $VERSION_OUTPUT -match 'MetricsHub Agent version ([\d.-]+-SNAPSHOT)' | Out-Null; $matches[1] | |
echo "MetricsHub Agent version: $AGENT_VERSION" | |
echo "::set-output name=agent_version::$AGENT_VERSION" | |
shell: pwsh | |
- name: Compare versions | |
run: | | |
$INPUT_VERSION = "${{ github.event.inputs.version }}" | |
$AGENT_VERSION = "${{ steps.get_version_windows.outputs.agent_version }}" | |
if ($INPUT_VERSION -eq $AGENT_VERSION) { | |
echo "The input version matches the current MetricsHub Agent version." | |
} else { | |
echo "The input version does not match the current MetricsHub Agent version." | |
exit 1 | |
} | |
shell: pwsh |