Skip to content

Commit ce9e46d

Browse files
authored
Create verify-version.yml
1 parent 57c491f commit ce9e46d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: 'Home Assistant helper: verify-version'
2+
description: 'GitHub action helper: verify-version'
3+
inputs:
4+
ignore-dev:
5+
description: Skip check if the branch is 'dev'
6+
required: false
7+
default: false
8+
ignore-master:
9+
description: Skip check if the branch is 'master'
10+
required: false
11+
default: false
12+
runs:
13+
using: "composite"
14+
steps:
15+
- shell: bash
16+
env:
17+
INPUTS_IGNORE_DEV: ${{ inputs.ignore-dev }}
18+
INPUTS_IGNORE_MASTER: ${{ inputs.ignore-master }}
19+
ACTION_PATH: ${{ github.action_path }}
20+
REF: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref }}
21+
UV_SYSTEM_PYTHON: "true"
22+
run: |
23+
pip install uv
24+
uv pip install tomli
25+
setup_version="$(python3 $ACTION_PATH/../read_version.py)"
26+
branch_version=$(echo "$REF" | awk -F"/" '{print $NF}' )
27+
28+
if [[ "${branch_version}" == "" ]]; then
29+
echo "::error::Verson is empty"
30+
exit 1
31+
fi
32+
33+
if [[ "$INPUTS_IGNORE_DEV" =~ true|True ]] && [ "${branch_version}" == "dev" ]; then
34+
exit 0
35+
elif [[ "$INPUTS_IGNORE_MASTER" =~ true|True ]] && [ "${branch_version}" == "master" ]; then
36+
exit 0
37+
elif [ "${setup_version}" != "${branch_version}" ]; then
38+
echo "Version of tag ${branch_version} don't match with ${setup_version}!"
39+
exit 1
40+
fi

0 commit comments

Comments
 (0)