Skip to content

Commit

Permalink
Merge pull request #69 from alleyinteractive/hotfix/release-version
Browse files Browse the repository at this point in the history
Handle spaces after Version in a plugin header when finding a package version
  • Loading branch information
attackant authored Jan 3, 2024
2 parents 0ee6279 + 070e92c commit 1742b97
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions .github/workflows/built-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ jobs:
- name: Extract version
id: extract-version
run: |
PACKAGE_VERSION="null"
PACKAGE_VERSION=""
PLUGIN_NAME=$(basename $(pwd))
echo "Using Plugin Name: $PLUGIN_NAME"
extract-version() {
grep -E "Version: [0-9]+\.[0-9]+\.[0-9]+" $1 | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" | head -1
grep -E "Version:\s*[0-9]+\.[0-9]+\.[0-9]+" $1 | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" | head -1
}
if [ -f "$PLUGIN_NAME.php" ]; then
Expand All @@ -60,16 +62,24 @@ jobs:
PACKAGE_VERSION=$(extract-version "plugin.php")
fi
if [ -f composer.json ] && [ "$PACKAGE_VERSION" = "null" ]; then
if [ -f composer.json ] && [ -z "$PACKAGE_VERSION" ]; then
PACKAGE_VERSION=$(cat composer.json | jq -r '.version')
if [ "$PACKAGE_VERSION" = "null" ]; then
PACKAGE_VERSION=""
fi
fi
if [ -f package.json ] && [ "$PACKAGE_VERSION" = "null" ]; then
if [ -f package.json ] && [ -z "$PACKAGE_VERSION" ]; then
PACKAGE_VERSION=$(cat package.json | jq -r '.version')
if [ "$PACKAGE_VERSION" = "null" ]; then
PACKAGE_VERSION=""
fi
fi
# Validate that we have a semver version number
if [ "$PACKAGE_VERSION" != "null" ]; then
if [ -n "$PACKAGE_VERSION" ]; then
if ! [[ "$PACKAGE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Invalid version number: $PACKAGE_VERSION"
exit 1
Expand All @@ -78,17 +88,18 @@ jobs:
# Ignore the version if it's 0.0.0
if [ "$PACKAGE_VERSION" = "0.0.0" ]; then
PACKAGE_VERSION="null"
PACKAGE_VERSION=""
fi
echo "PACKAGE_VERSION: $PACKAGE_VERSION"
echo "Package Version: $PACKAGE_VERSION"
if [ $PACKAGE_VERSION = "null" ] || [ -z $PACKAGE_VERSION ]; then
if [ -z $PACKAGE_VERSION ]; then
echo "package_version=false" >> $GITHUB_OUTPUT
else
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
fi
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit 1742b97

Please sign in to comment.