diff --git a/README.md b/README.md index c765ded..9a70e35 100644 --- a/README.md +++ b/README.md @@ -37,5 +37,6 @@ _A collection of GitHub Action helpers, these are considered internal to the Hom - [git-init](./helpers/git-init/action.yml) - [info](./helpers/info/action.yml) - [jq](./helpers/jq/action.yml) +- [verify-version](./helpers/action.yml) - [version](./helpers/version/action.yml) - [version-push](./helpers/version-push/action.yml) diff --git a/helpers/verify-version/action.yml b/helpers/verify-version/action.yml new file mode 100644 index 0000000..fbbf33d --- /dev/null +++ b/helpers/verify-version/action.yml @@ -0,0 +1,27 @@ +name: 'Home Assistant helper: verify-version' +description: 'GitHub action helper: verify-version' +inputs: + ignore-dev: + description: Skip check if the branch is 'dev' + required: false + default: false + ignore-master: + description: Skip check if the branch is 'master' + required: false + default: false +runs: + using: "composite" + steps: + - shell: bash + run: | + setup_version="$(python3 setup.py -V)" + branch_version=$(echo "${{ github.ref }}" | awk -F"/" '{print $NF}' ) + + if [[ "${{ inputs.ignore-dev }}" =~ true|True ]] && [ "${branch_version}" == "dev" ]; then + exit 0 + elif [[ "${{ inputs.ignore-master }}" =~ true|True ]] && [ "${branch_version}" == "master" ]; then + exit 0 + elif [ "${setup_version}" != "${branch_version}" ]; then + echo "Version of tag ${branch_version} don't match with ${setup_version}!" + exit 1 + fi