Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 37 additions & 5 deletions .github/workflows/check-editor-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,17 @@ jobs:
exit 0
fi

CURRENT_VERSION=$(sed -n "s/^\$plugin->version[[:space:]]*=[[:space:]]*\([0-9][0-9]*\);.*/\1/p" version.php | head -n1)
CURRENT_VERSION=$(python3 - <<'PY'
import re
from pathlib import Path

content = Path("version.php").read_text()
match = re.search(r"^\$plugin->version\s*=\s*(\d+);", content, re.MULTILINE)
if not match:
raise SystemExit("Could not read $plugin->version from version.php")
print(match.group(1))
PY
)
TODAY_PREFIX=$(date -u +%Y%m%d)
CURRENT_PREFIX=${CURRENT_VERSION%??}
CURRENT_SEQUENCE=${CURRENT_VERSION#????????}
Expand All @@ -91,10 +101,32 @@ jobs:
-e "s#(releases/download/)v[0-9][0-9A-Za-z.-]*#\1$TAG#g" \
-e "s#(exelearning-static-)v[0-9][0-9A-Za-z.-]*(\.zip)#\1$TAG\2#g" \
blueprint.json
sed -i -E \
-e "s/^\$plugin->version[[:space:]]*=.*/\$plugin->version = $NEXT_VERSION;/" \
-e "s/^\$plugin->release[[:space:]]*=.*/\$plugin->release = '$RELEASE';/" \
version.php

NEXT_VERSION="$NEXT_VERSION" RELEASE="$RELEASE" python3 - <<'PY'
import os
import re
from pathlib import Path

path = Path("version.php")
content = path.read_text()
content, version_count = re.subn(
r"^\$plugin->version\s*=.*$",
f"$plugin->version = {os.environ['NEXT_VERSION']};",
content,
count=1,
flags=re.MULTILINE,
)
content, release_count = re.subn(
r"^\$plugin->release\s*=.*$",
f"$plugin->release = '{os.environ['RELEASE']}';",
content,
count=1,
flags=re.MULTILINE,
)
if version_count != 1 or release_count != 1:
raise SystemExit("Could not update release metadata in version.php")
path.write_text(content)
PY

bash scripts/check-version.sh --release "$RELEASE"

Expand Down
41 changes: 36 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,17 @@ jobs:
exit 1
fi

CURRENT_VERSION=$(sed -n "s/^\$plugin->version[[:space:]]*=[[:space:]]*\([0-9][0-9]*\);.*/\1/p" version.php | head -n1)
CURRENT_VERSION=$(python3 - <<'PY'
import re
from pathlib import Path

content = Path("version.php").read_text()
match = re.search(r"^\$plugin->version\s*=\s*(\d+);", content, re.MULTILINE)
if not match:
raise SystemExit("Could not read $plugin->version from version.php")
print(match.group(1))
PY
)
CURRENT_PREFIX=${CURRENT_VERSION%??}
CURRENT_SEQUENCE=${CURRENT_VERSION#????????}
TODAY_PREFIX=$(date -u +%Y%m%d)
Expand All @@ -172,10 +182,31 @@ jobs:
NEXT_VERSION=$(printf '%s%02d' "$CURRENT_PREFIX" "$NEXT_SEQUENCE")
fi

sed -i -E \
-e "s/^\$plugin->version[[:space:]]*=.*/\$plugin->version = $NEXT_VERSION;/" \
-e "s/^\$plugin->release[[:space:]]*=.*/\$plugin->release = 'dev';/" \
version.php
NEXT_VERSION="$NEXT_VERSION" python3 - <<'PY'
import os
import re
from pathlib import Path

path = Path("version.php")
content = path.read_text()
content, version_count = re.subn(
r"^\$plugin->version\s*=.*$",
f"$plugin->version = {os.environ['NEXT_VERSION']};",
content,
count=1,
flags=re.MULTILINE,
)
content, release_count = re.subn(
r"^\$plugin->release\s*=.*$",
"$plugin->release = 'dev';",
content,
count=1,
flags=re.MULTILINE,
)
if version_count != 1 or release_count != 1:
raise SystemExit("Could not update development metadata in version.php")
path.write_text(content)
PY

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
Expand Down
Loading