File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ jobs:
131131 run : |
132132 set -euo pipefail
133133 VERSION=$(sed -n "s/^ *const VERSION = '\(.*\)';.*/\1/p" lib/ConvertApi/ConvertApi.php)
134- SEMVER='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0- 9A-Za-z-]+ (\.[0- 9A-Za-z-]+ )*)?$'
134+ SEMVER='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0- 9A-Za-z-]*) (\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0- 9A-Za-z-]*) )*)?$'
135135 if ! [[ "$VERSION" =~ $SEMVER ]]; then
136136 echo "::error file=lib/ConvertApi/ConvertApi.php::ConvertApi::VERSION '$VERSION' is not {major}.{minor}.{patch}[-{pre-release}]"
137137 exit 1
@@ -141,6 +141,11 @@ jobs:
141141 echo "::error file=lib/ConvertApi/ConvertApi.php::ConvertApi::VERSION $VERSION is lower than the latest release $LATEST"
142142 exit 1
143143 fi
144+ # SemVer sorts 3.0.1-beta.1 below 3.0.1, so a pre-release of the latest release is a step back.
145+ if [[ "$VERSION" == *-* ]] && [ "${VERSION%%-*}" = "$LATEST" ]; then
146+ echo "::error file=lib/ConvertApi/ConvertApi.php::ConvertApi::VERSION $VERSION is a pre-release of $LATEST, which is already released"
147+ exit 1
148+ fi
144149 {
145150 echo "version=$VERSION"
146151 echo "latest=$LATEST"
Original file line number Diff line number Diff line change 6161 run : |
6262 set -euo pipefail
6363 # SemVer 2.0 without build metadata (Composer ignores "+...").
64- SEMVER='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0- 9A-Za-z-]+ (\.[0- 9A-Za-z-]+ )*)?$'
64+ SEMVER='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0- 9A-Za-z-]*) (\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0- 9A-Za-z-]*) )*)?$'
6565 if ! [[ "$TAG" =~ $SEMVER ]]; then
6666 echo "::error::Tag '$TAG' is not v{major}.{minor}.{patch} or v{major}.{minor}.{patch}-{pre-release}, e.g. v3.0.1 or v3.1.0-beta.1"
6767 exit 1
@@ -139,10 +139,11 @@ jobs:
139139 TAG : ${{ github.event.release.tag_name }}
140140 SHA : ${{ steps.tag.outputs.sha }}
141141 run : |
142+ # Steps run with bash -e: a failed request or parse sets REF empty and the loop tries again.
142143 set -uo pipefail
143144 for _ in $(seq 1 30); do
144145 REF=$(curl -fsS -H 'Cache-Control: no-cache' "https://repo.packagist.org/p2/$PACKAGE.json" \
145- | jq -r --arg p "$PACKAGE" --arg v "$TAG" '.packages[$p][] | select(.version == $v) | .source.reference // empty')
146+ | jq -r --arg p "$PACKAGE" --arg v "$TAG" '.packages[$p][] | select(.version == $v) | .source.reference // empty') || REF=''
146147 if [ "$REF" = "$SHA" ]; then
147148 echo "$PACKAGE $TAG is on Packagist from $SHA"
148149 exit 0
Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ public function testClient()
4040
4141 public function testVersionIsSemVer ()
4242 {
43- $ this ->assertMatchesRegularExpression ('/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/ ' , ConvertApi::VERSION );
43+ $ id = '(0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*) ' ;
44+ $ this ->assertMatchesRegularExpression (
45+ "/^(0|[1-9] \\d*) \\.(0|[1-9] \\d*) \\.(0|[1-9] \\d*)(- $ id( \\. $ id)*)?$/ " ,
46+ ConvertApi::VERSION
47+ );
4448 }
4549}
You can’t perform that action at this time.
0 commit comments