@@ -23,13 +23,41 @@ jobs:
23
23
- name : Checkout repository
24
24
uses : actions/checkout@v4
25
25
26
+ - name : Set up Python
27
+ uses : actions/setup-python@v5
28
+ with :
29
+ python-version : 3.x
30
+
31
+ - name : Install dependencies
32
+ run : |
33
+ python -m pip install --upgrade pip
34
+ pip install packaging
35
+
26
36
- name : Validate version format
27
37
run : |
28
38
if ! [[ ${{ github.event.inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
29
39
echo "Invalid version format. Must be X.Y.Z"
30
40
exit 1
31
41
fi
32
42
43
+ - name : Get current version
44
+ id : current_version
45
+ run : |
46
+ CURRENT_VERSION=$(grep -oP '__version__ = "\K[^"]+' ardupilot_methodic_configurator/__init__.py)
47
+ echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
48
+
49
+ - name : Compare versions
50
+ run : |
51
+ python3 - <<EOF
52
+ from packaging import version
53
+ current = version.parse("${{ steps.current_version.outputs.current_version }}")
54
+ new = version.parse("${{ github.event.inputs.version }}")
55
+ if new <= current:
56
+ print(f"Error: New version {new} must be greater than current version {current}")
57
+ exit(1)
58
+ print(f"Version increase valid: {current} -> {new}")
59
+ EOF
60
+
33
61
- name : Update version in __init__.py
34
62
run : |
35
63
sed -i 's/__version__ = ".*"/__version__ = "${{ github.event.inputs.version }}"/' ardupilot_methodic_configurator/__init__.py
45
73
- name : Create and push tag
46
74
run : |
47
75
git tag -a "v${{ github.event.inputs.version }}" -m "${{ github.event.inputs.tag_message }}"
48
- git push origin "v${{ github.event.inputs.version }}"
76
+ git push origin "v${{ github.event.inputs.version }}"
0 commit comments