-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: reject release if the tag fails any version validation
- must be consistent in the repo and the tag - must be more recent than latest on NPM This solution requires jq, but that's OK because every runner image on GitHub Actions has jq pre-installed. Some of the tests with jq are equivalent to, e.g., `npm view dist/packages/web-component version` but doing them with `jq` allows us to apply them earlier, before we even make the builds.
- Loading branch information
Showing
2 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/sh | ||
|
||
INPUT_TAG="$1" | ||
|
||
if [ -z "$INPUT_TAG" ]; then | ||
echo "Usage: $0 <tag>" | ||
exit 1 | ||
fi | ||
|
||
VERSION=${INPUT_TAG#v} | ||
BAD= | ||
|
||
if [ "$(jq -r .version packages/web-component/package.json)" != "$VERSION" ]; then | ||
echo "ERROR: version mismatch in packages/web-component/package.json" | ||
BAD=1 | ||
fi | ||
|
||
if [ "$(jq -r .version packages/ngx-web-component/package.json)" != "$VERSION" ]; then | ||
echo "ERROR: version mismatch in packages/ngx-web-component/package.json" | ||
BAD=1 | ||
fi | ||
|
||
if [ "$(jq -r '.peerDependencies."@readalongs/web-component"' packages/ngx-web-component/package.json)" != "$VERSION" ]; then | ||
echo "ERROR: peer dependency on @readalongs/web-component version mismatch in packages/ngx-web-component/package.json" | ||
BAD=1 | ||
fi | ||
|
||
if [ "$(jq -r .singleFileBundleVersion packages/studio-web/package.json)" != "$VERSION" ]; then | ||
echo "ERROR: singleFileBundleVersion mismatch in packages/studio-web/package.json" | ||
BAD=1 | ||
fi | ||
|
||
version_less_than() { | ||
{ echo "$1"; echo "$2"; } | sort -V -C && [ "$1" != "$2" ] | ||
} | ||
|
||
NPM_VERSION_WEBC=$(npm view @readalongs/web-component version) | ||
echo "Published NPM @readalongs/web-component version: $NPM_VERSION_WEBC" | ||
NPM_VERSION_NGXWEBC=$(npm view @readalongs/ngx-web-component version) | ||
echo "Published NPM @readalongs/ngx-web-component version: $NPM_VERSION_NGXWEBC" | ||
echo "New version: $VERSION" | ||
|
||
if [ "$NPM_VERSION_WEBC" != "$NPM_VERSION_NGXWEBC" ]; then | ||
echo "WARNING: published NPM @readalongs/web-component and @readalongs/ngx-web-component versions differ" | ||
fi | ||
|
||
if ! version_less_than "$NPM_VERSION_WEBC" "$VERSION"; then | ||
echo "ERROR: new version $VERSION is not greater than published NPM @readalongs/web-component version $NPM_VERSION_WEBC" | ||
BAD=1 | ||
fi | ||
|
||
if ! version_less_than "$NPM_VERSION_NGXWEBC" "$VERSION"; then | ||
echo "ERROR: new version $VERSION is not greater than published NPM @readalongs/ngx-web-component version $NPM_VERSION_NGXWEBC" | ||
BAD=1 | ||
fi | ||
|
||
if [ -n "$BAD" ]; then | ||
exit 1 | ||
fi |