mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
21 lines
721 B
Bash
21 lines
721 B
Bash
#!/usr/bin/env bash
|
|
set -uo pipefail
|
|
|
|
WORKING_DIR="${1:-.}"
|
|
PATTERN="magento/product-(community|enterprise)-edition|mage-os/product-community-edition"
|
|
|
|
cd "$WORKING_DIR"
|
|
|
|
if [ -f composer.lock ]; then
|
|
RESULT=$(jq -r --arg p "$PATTERN" '.packages[] | select(.name | test($p)) | "\(.name) \(.version)"' composer.lock | head -1)
|
|
elif [ -f composer.json ]; then
|
|
RESULT=$(jq -r --arg p "$PATTERN" '.require | to_entries[] | select(.key | test($p)) | "\(.key) \(.value)"' composer.json | head -1)
|
|
fi
|
|
|
|
PRODUCT=$(echo "${RESULT:-}" | awk '{print $1}')
|
|
VERSION=$(echo "${RESULT:-}" | awk '{print $2}' | sed 's/^v//')
|
|
PROJECT=$(echo "$PRODUCT" | sed 's/product-/project-/')
|
|
|
|
echo "version=\"$VERSION\""
|
|
echo "project=$PROJECT"
|