Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
change install version script and add check in release workflow to ch…
Browse files Browse the repository at this point in the history
…eck version being published
  • Loading branch information
karuppiah7890 committed Nov 12, 2020
1 parent a963d7b commit 561900c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Check plugin and script version
uses: mikefarah/[email protected]
with:
cmd: ./scripts/check_version.sh plugin.yaml scripts/install_version.sh ${{ github.ref }}
-
name: Set up Go
uses: actions/setup-go@v2
Expand Down
50 changes: 50 additions & 0 deletions scripts/check_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh

# Checks plugin.yaml version and also the install version script version

set -e

plugin_yaml=$1
# example: refs/tags/0.0.1
install_version_script=$2
refTag=$3
expected_version=$(echo $refTag | cut -d "/" -f 3)

if [ -z $expected_version ];
then
echo "git tag value is empty"
exit 1
fi

if [ ! -e $plugin_yaml ];
then
echo "File $plugin_yaml does not exist!"
exit 1
fi

plugin_version=$(yq read $plugin_yaml version)

if [ "$plugin_version" != "$expected_version" ];
then
echo "Plugin version $plugin_version is not the expected version $expected_version"
exit 1
fi

if [ ! -e $install_version_script ];
then
echo "File $install_version_script does not exist!"
exit 1
fi

set +e

grep -q -F $expected_version $install_version_script
wrong_version=$?

set -e

if [ $wrong_version != 0 ];
then
echo "$install_version_script does not have the right version"
exit 1
fi
3 changes: 1 addition & 2 deletions scripts/install_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
## version of the plugin mentioned
## in the plugin.yaml

version="$(cat plugin.yaml | grep "version:" | cut -d '"' -f 2)"
./scripts/install.sh $version
./scripts/install.sh "0.0.3"

0 comments on commit 561900c

Please sign in to comment.