File tree 3 files changed +68
-22
lines changed
3 files changed +68
-22
lines changed Original file line number Diff line number Diff line change 16
16
run : |
17
17
git config --global user.name "SDK Releaser Bot"
18
18
git config --global user.email "[email protected] "
19
-
20
- for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do
21
- # Extract the change regarding the version from the pyproject.toml file
22
- version_changes=$(git diff HEAD~1..HEAD $file | grep "version =")
23
- # Check if the extracted change is not empty
24
- if [ -n "$version_changes" ]; then
25
- # Split all found version changes, so we can compare the old and new version.
26
- splitted_version_changes=($(echo "$version_changes" | grep -oP '(?<=version = )[^ ]*'))
27
- # Only create a tag if there has been an actual change in the version, not just a format change.
28
- if [ $(echo "${splitted_version_changes[@]}" | tr ' ' '\n' | sort -u | wc -l) -ne 1 ]; then
29
- dirpath=$(dirname $file)
30
- # Extract just the version number
31
- current_version=$(grep -o "version = .*" ${file} | cut -d '=' -f 2-)
32
- dirpath=$(dirname $file)
33
- cleaned_version=$(echo "$current_version" | tr -d '" ')
34
- # Create the tag based on the updated service and the new version
35
- tag=$(echo "${dirpath}/${cleaned_version}")
36
- git tag -a $tag -m "Release $cleaned_version"
37
- git push origin tag $tag
38
- fi
39
- fi
40
- done
19
+
20
+ scripts/trigger_script.sh
21
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Check if the directory is provided as an argument
4
+ if [ $# -lt 1 ] || [ $# -gt 2 ]; then
5
+ echo " Usage: $0 <directory> [option]"
6
+ echo " Options:"
7
+ echo " -v | --version Print just the version number"
8
+ echo " -p | --path-version Print the concatenation of the path and the version"
9
+ exit 1
10
+ fi
11
+
12
+ # Check if the directory exists
13
+ if [ ! -d " $1 " ]; then
14
+ echo " Directory '$1 ' does not exist"
15
+ exit 1
16
+ fi
17
+
18
+ # Append a trailing slash to the path if it's not already present
19
+ if [ " ${1: -1} " != " /" ]; then
20
+ path=" $1 /"
21
+ else
22
+ path=" $1 "
23
+ fi
24
+
25
+ # Change into the directory and run the command
26
+ cd " $path " || exit 1
27
+ version=$( poetry version)
28
+
29
+ # Get the version number
30
+ version_number=" ${version##* } "
31
+
32
+ # Get the path and version string
33
+ path_version=" $path$version_number "
34
+
35
+ # Handle options
36
+ if [ $# -eq 1 ]; then
37
+ # Default behavior: print just the version number
38
+ echo " $version_number "
39
+ elif [ " $2 " = " -v" ] || [ " $2 " = " --version" ]; then
40
+ # Print just the version number
41
+ echo " $version_number "
42
+ elif [ " $2 " = " -p" ] || [ " $2 " = " --path-version" ]; then
43
+ # Print the concatenation of the path and the version
44
+ echo " $path_version "
45
+ else
46
+ echo " Invalid option: '$2 '"
47
+ exit 1
48
+ fi
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Check all pyproject.toml files that have changed
4
+ for file in $( git diff --name-only HEAD~1..HEAD | grep pyproject.toml) ; do
5
+ # Extract the current version and build the expected tag
6
+ dirpath=$( dirname $file )
7
+ expected_tag=$( scripts/helper.sh $dirpath --path-version)
8
+ version=$( scripts/helper.sh $dirpath )
9
+ # Check if the tag already exists
10
+ if git rev-parse --verify $expected_tag ^{tag} & > /dev/null; then
11
+ echo " Tag '$expected_tag ' already exists."
12
+ else
13
+ echo " Tag '$expected_tag ' does not exist. Creating new tag to trigger release."
14
+ git tag -a $expected_tag -m " Release $version "
15
+ git push origin tag $expected_tag
16
+ fi
17
+ done
You can’t perform that action at this time.
0 commit comments