Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Python3 Helper script for RegEx and made inputs auto select from RegEx #69

Open
wants to merge 3 commits into
base: updater
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions semver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/python
import sys
import re
import json

# Joomla_5.0.0-alpha2-Alpha-Update_Package.zip

# 5.0.0-alpha2 - shall be the Version semver

# Alpha shall be the stability in the template file

total = len(sys.argv)
# cmdargs = str(sys.argv)

SEMVER_REGEX="^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
SEMVER_FULLNAME_REGEX="^.*(?P<version>((?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)).*$"

p = re.compile(SEMVER_FULLNAME_REGEX)
m = p.match(sys.argv[1])
print(json.dumps(m.groupdict()))
35 changes: 20 additions & 15 deletions sign.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,23 @@ function userConfirm() {
}

function checkReleaseFolder() {
release_folder_status="$(find ./release/ -iname '*.zip')"
if [[ $release_folder_status != "" ]]; then
echo '=> Move file from release to updates/stage/targets'
for file in ./release**/*.zip; do
echo $file
mv "$file" updates/staged/targets/
done
else
echo '=> Relase Folder has no ZIP files, is this correct?'
userConfirm
fi
release_folder_status="$(find ./release/ -iname '*.zip')"
if [[ $release_folder_status != "" ]]; then
echo '=> Move file from release to updates/stage/targets'
for file in ./release**/*.zip; do
echo "$file"
# INFO
# the semver.py return a json string
# Example File ./release/Joomla_5.0.6-Stable-Update_Package.zip will return
# {"version": "5.0.6-Stable-Update", "major": "5", "minor": "0", "patch": "6", "prerelease": "Stable-Update", "buildmetadata": null}
versionJSON=$(python3 semver.py "$file")
UPDATE_VERSION="$(jq .version <<< "$versionJSON" | tr -d '"')"
mv "$file" updates/staged/targets/
done
else
echo '=> Relase Folder has no ZIP files, is this correct?'
userConfirm
fi
}


Expand Down Expand Up @@ -134,12 +140,11 @@ elif [[ $TUF_PARAMS = "DEBUG" ]]; then
elif [[ $TUF_PARAMS = "prepare-release" ]]; then
checkReleaseFolder
echo "=> Add update files and sign them"
localread "Please enter the Update Version:" "" UPDATE_VERSION
localread "Please enter the Update Name:" "Joomla! ${UPDATE_VERSION}" UPDATE_NAME
localread "Please enter the Update Description:" "${UPDATE_NAME} Release" UPDATE_DESCRIPTION
UPDATE_NAME="Joomla! ${UPDATE_VERSION}"
UPDATE_DESCRIPTION="${UPDATE_NAME} Release"
# INFO Url must be asked
localread "Please enter the Update Info URL:" "https://www.joomla.org/announcements/release-news/" UPDATE_INFO_URL
localread "Please enter the Update Info Titel:" "${UPDATE_NAME} Release" UPDATE_INFO_TITLE
UPDATE_INFO_TITLE="${UPDATE_NAME} Release"
sed -i -e "s/GIT_TARGET_BRANCH_NAME=.*/GIT_TARGET_BRANCH_NAME=release\/${GIT_BASE_BRANCH_NAME}\/${UPDATE_VERSION}/g" "$DOCKER_ENV_FILE"
docker run --rm \
--env-file "${DOCKER_ENV_FILE}" \
Expand Down