mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
test(get-magento-version): document and pin what happens in various kinds of installs
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user