From ac68590a19d277906c5d3dffee3fb44d81f14f11 Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Fri, 15 Nov 2024 08:29:05 +0000 Subject: [PATCH 1/9] change logic for tag creation --- .github/workflows/release-trigger.yaml | 25 +++---------------------- core/poetry.lock | 15 ++++++++++++++- core/pyproject.toml | 2 +- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release-trigger.yaml b/.github/workflows/release-trigger.yaml index 7533a0e43..fa623b33b 100644 --- a/.github/workflows/release-trigger.yaml +++ b/.github/workflows/release-trigger.yaml @@ -16,25 +16,6 @@ jobs: run: | git config --global user.name "SDK Releaser Bot" git config --global user.email "noreply@stackit.de" - - for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do - # Extract the change regarding the version from the pyproject.toml file - version_changes=$(git diff HEAD~1..HEAD $file | grep "version =") - # Check if the extracted change is not empty - if [ -n "$version_changes" ]; then - # Split all found version changes, so we can compare the old and new version. - splitted_version_changes=($(echo "$version_changes" | grep -oP '(?<=version = )[^ ]*')) - # Only create a tag if there has been an actual change in the version, not just a format change. - if [ $(echo "${splitted_version_changes[@]}" | tr ' ' '\n' | sort -u | wc -l) -ne 1 ]; then - dirpath=$(dirname $file) - # Extract just the version number - current_version=$(grep -o "version = .*" ${file} | cut -d '=' -f 2-) - dirpath=$(dirname $file) - cleaned_version=$(echo "$current_version" | tr -d '" ') - # Create the tag based on the updated service and the new version - tag=$(echo "${dirpath}/${cleaned_version}") - git tag -a $tag -m "Release $cleaned_version" - git push origin tag $tag - fi - fi - done + + .github/trigger_script.sh + \ No newline at end of file diff --git a/core/poetry.lock b/core/poetry.lock index 54c4d844c..40ed3a22d 100644 --- a/core/poetry.lock +++ b/core/poetry.lock @@ -639,6 +639,19 @@ files = [ [package.extras] colors = ["colorama (>=0.4.6)"] +[[package]] +name = "jwt" +version = "1.3.1" +description = "JSON Web Token library for Python 3." +optional = false +python-versions = ">= 3.6" +files = [ + {file = "jwt-1.3.1-py3-none-any.whl", hash = "sha256:61c9170f92e736b530655e75374681d4fcca9cfa8763ab42be57353b2b203494"}, +] + +[package.dependencies] +cryptography = ">=3.1,<3.4.0 || >3.4.0" + [[package]] name = "maison" version = "1.4.3" @@ -1232,4 +1245,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.8,<4.0" -content-hash = "8cdfa63ea82eab3046ba43668109d2a14ce562c81af32c229004b6e39b391b0c" +content-hash = "17c3daad08453804b15b086391f14fc2aeed0c6467446eb8c73068a66db64773" diff --git a/core/pyproject.toml b/core/pyproject.toml index 9a54ae227..18d47cc9c 100644 --- a/core/pyproject.toml +++ b/core/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "stackit-core" -version = "v0.0.1a3" +version = "v0.0.1a7" authors = ["STACKIT Developer Tools "] description = "Core functionality for the STACKIT SDK for Python" readme = "README.md" From c98a778a00d9de0f77e0719a028d5401651fab35 Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Fri, 15 Nov 2024 08:29:54 +0000 Subject: [PATCH 2/9] Revert "change logic for tag creation" This reverts commit ac68590a19d277906c5d3dffee3fb44d81f14f11. --- .github/workflows/release-trigger.yaml | 25 ++++++++++++++++++++++--- core/poetry.lock | 15 +-------------- core/pyproject.toml | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release-trigger.yaml b/.github/workflows/release-trigger.yaml index fa623b33b..7533a0e43 100644 --- a/.github/workflows/release-trigger.yaml +++ b/.github/workflows/release-trigger.yaml @@ -16,6 +16,25 @@ jobs: run: | git config --global user.name "SDK Releaser Bot" git config --global user.email "noreply@stackit.de" - - .github/trigger_script.sh - \ No newline at end of file + + for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do + # Extract the change regarding the version from the pyproject.toml file + version_changes=$(git diff HEAD~1..HEAD $file | grep "version =") + # Check if the extracted change is not empty + if [ -n "$version_changes" ]; then + # Split all found version changes, so we can compare the old and new version. + splitted_version_changes=($(echo "$version_changes" | grep -oP '(?<=version = )[^ ]*')) + # Only create a tag if there has been an actual change in the version, not just a format change. + if [ $(echo "${splitted_version_changes[@]}" | tr ' ' '\n' | sort -u | wc -l) -ne 1 ]; then + dirpath=$(dirname $file) + # Extract just the version number + current_version=$(grep -o "version = .*" ${file} | cut -d '=' -f 2-) + dirpath=$(dirname $file) + cleaned_version=$(echo "$current_version" | tr -d '" ') + # Create the tag based on the updated service and the new version + tag=$(echo "${dirpath}/${cleaned_version}") + git tag -a $tag -m "Release $cleaned_version" + git push origin tag $tag + fi + fi + done diff --git a/core/poetry.lock b/core/poetry.lock index 40ed3a22d..54c4d844c 100644 --- a/core/poetry.lock +++ b/core/poetry.lock @@ -639,19 +639,6 @@ files = [ [package.extras] colors = ["colorama (>=0.4.6)"] -[[package]] -name = "jwt" -version = "1.3.1" -description = "JSON Web Token library for Python 3." -optional = false -python-versions = ">= 3.6" -files = [ - {file = "jwt-1.3.1-py3-none-any.whl", hash = "sha256:61c9170f92e736b530655e75374681d4fcca9cfa8763ab42be57353b2b203494"}, -] - -[package.dependencies] -cryptography = ">=3.1,<3.4.0 || >3.4.0" - [[package]] name = "maison" version = "1.4.3" @@ -1245,4 +1232,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.8,<4.0" -content-hash = "17c3daad08453804b15b086391f14fc2aeed0c6467446eb8c73068a66db64773" +content-hash = "8cdfa63ea82eab3046ba43668109d2a14ce562c81af32c229004b6e39b391b0c" diff --git a/core/pyproject.toml b/core/pyproject.toml index 18d47cc9c..9a54ae227 100644 --- a/core/pyproject.toml +++ b/core/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "stackit-core" -version = "v0.0.1a7" +version = "v0.0.1a3" authors = ["STACKIT Developer Tools "] description = "Core functionality for the STACKIT SDK for Python" readme = "README.md" From ea3047220b3897557624b93f2c9352208004b99f Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Fri, 15 Nov 2024 08:30:40 +0000 Subject: [PATCH 3/9] change release trigger logic --- .github/helper.sh | 48 ++++++++++++++++++++++++++ .github/trigger_script.sh | 17 +++++++++ .github/workflows/release-trigger.yaml | 25 ++------------ 3 files changed, 68 insertions(+), 22 deletions(-) create mode 100755 .github/helper.sh create mode 100755 .github/trigger_script.sh diff --git a/.github/helper.sh b/.github/helper.sh new file mode 100755 index 000000000..77972dcb5 --- /dev/null +++ b/.github/helper.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Check if the directory is provided as an argument +if [ $# -lt 1 ] || [ $# -gt 2 ]; then + echo "Usage: $0 [option]" + echo "Options:" + echo " -v | --version Print just the version number" + echo " -p | --path-version Print the concatenation of the path and the version" + exit 1 +fi + +# Check if the directory exists +if [ ! -d "$1" ]; then + echo "Directory '$1' does not exist" + exit 1 +fi + +# Append a trailing slash to the path if it's not already present +if [ "${1: -1}" != "/" ]; then + path="$1/" +else + path="$1" +fi + +# Change into the directory and run the command +cd "$path" || exit 1 +version=$(poetry version) + +# Get the version number +version_number="${version##* }" + +# Get the path and version string +path_version="$path$version_number" + +# Handle options +if [ $# -eq 1 ]; then + # Default behavior: print just the version number + echo "$version_number" +elif [ "$2" = "-v" ] || [ "$2" = "--version" ]; then + # Print just the version number + echo "$version_number" +elif [ "$2" = "-p" ] || [ "$2" = "--path-version" ]; then + # Print the concatenation of the path and the version + echo "$path_version" +else + echo "Invalid option: '$2'" + exit 1 +fi \ No newline at end of file diff --git a/.github/trigger_script.sh b/.github/trigger_script.sh new file mode 100755 index 000000000..1bc94cd0a --- /dev/null +++ b/.github/trigger_script.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Check all pyproject.toml files that have changed +for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do + # Extract the change regarding the version from the pyproject.toml file + dirpath=$(dirname $file) + expected_tag=$(.github/helper.sh $dirpath --path-version) + version=$(.github/helper.sh $dirpath) + # Check if the tag already exists + if git rev-parse --verify $expected_tag^{tag} &> /dev/null; then + echo "Tag '$expected_tag' already exists." + else + echo "Tag '$expected_tag' does not exist. Creating new tag to trigger release." + git tag -a $expected_tag -m "Release $version" + #git push origin tag $expected_tag + fi +done diff --git a/.github/workflows/release-trigger.yaml b/.github/workflows/release-trigger.yaml index 7533a0e43..fa623b33b 100644 --- a/.github/workflows/release-trigger.yaml +++ b/.github/workflows/release-trigger.yaml @@ -16,25 +16,6 @@ jobs: run: | git config --global user.name "SDK Releaser Bot" git config --global user.email "noreply@stackit.de" - - for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do - # Extract the change regarding the version from the pyproject.toml file - version_changes=$(git diff HEAD~1..HEAD $file | grep "version =") - # Check if the extracted change is not empty - if [ -n "$version_changes" ]; then - # Split all found version changes, so we can compare the old and new version. - splitted_version_changes=($(echo "$version_changes" | grep -oP '(?<=version = )[^ ]*')) - # Only create a tag if there has been an actual change in the version, not just a format change. - if [ $(echo "${splitted_version_changes[@]}" | tr ' ' '\n' | sort -u | wc -l) -ne 1 ]; then - dirpath=$(dirname $file) - # Extract just the version number - current_version=$(grep -o "version = .*" ${file} | cut -d '=' -f 2-) - dirpath=$(dirname $file) - cleaned_version=$(echo "$current_version" | tr -d '" ') - # Create the tag based on the updated service and the new version - tag=$(echo "${dirpath}/${cleaned_version}") - git tag -a $tag -m "Release $cleaned_version" - git push origin tag $tag - fi - fi - done + + .github/trigger_script.sh + \ No newline at end of file From 09d22639da4cb0e62e3a5093605ad2875fee67a3 Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Fri, 15 Nov 2024 08:35:46 +0000 Subject: [PATCH 4/9] comment improvmeent --- .github/trigger_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/trigger_script.sh b/.github/trigger_script.sh index 1bc94cd0a..73c819985 100755 --- a/.github/trigger_script.sh +++ b/.github/trigger_script.sh @@ -2,7 +2,7 @@ # Check all pyproject.toml files that have changed for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do - # Extract the change regarding the version from the pyproject.toml file + # Extract the current version and buikd the expected tag dirpath=$(dirname $file) expected_tag=$(.github/helper.sh $dirpath --path-version) version=$(.github/helper.sh $dirpath) From 110fda0b3871589fc8c802604d6adf86dedb328f Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Fri, 15 Nov 2024 08:37:34 +0000 Subject: [PATCH 5/9] fix --- .github/trigger_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/trigger_script.sh b/.github/trigger_script.sh index 73c819985..14f849379 100755 --- a/.github/trigger_script.sh +++ b/.github/trigger_script.sh @@ -12,6 +12,6 @@ for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do else echo "Tag '$expected_tag' does not exist. Creating new tag to trigger release." git tag -a $expected_tag -m "Release $version" - #git push origin tag $expected_tag + git push origin tag $expected_tag fi done From 5f28dd2cf8e78d5d621d336ad4b480609b6f97ae Mon Sep 17 00:00:00 2001 From: Melvin <70433111+MelvinKl@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:22:05 +0100 Subject: [PATCH 6/9] Update .github/trigger_script.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Diogo Ferrão --- .github/trigger_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/trigger_script.sh b/.github/trigger_script.sh index 14f849379..f6b81eb8f 100755 --- a/.github/trigger_script.sh +++ b/.github/trigger_script.sh @@ -2,7 +2,7 @@ # Check all pyproject.toml files that have changed for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do - # Extract the current version and buikd the expected tag + # Extract the current version and build the expected tag dirpath=$(dirname $file) expected_tag=$(.github/helper.sh $dirpath --path-version) version=$(.github/helper.sh $dirpath) From dcc18a24bee72ac666f67563aee9233e93ec8343 Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Fri, 15 Nov 2024 12:30:57 +0000 Subject: [PATCH 7/9] test --- core/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/pyproject.toml b/core/pyproject.toml index 9a54ae227..e5f8866f1 100644 --- a/core/pyproject.toml +++ b/core/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "stackit-core" -version = "v0.0.1a3" +version = "v0.0.1a8" authors = ["STACKIT Developer Tools "] description = "Core functionality for the STACKIT SDK for Python" readme = "README.md" From 18c2ae57bed8195d8f6bab9f061b4a8c2ba2ad41 Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Fri, 15 Nov 2024 12:31:22 +0000 Subject: [PATCH 8/9] Revert "test" This reverts commit dcc18a24bee72ac666f67563aee9233e93ec8343. --- core/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/pyproject.toml b/core/pyproject.toml index e5f8866f1..9a54ae227 100644 --- a/core/pyproject.toml +++ b/core/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "stackit-core" -version = "v0.0.1a8" +version = "v0.0.1a3" authors = ["STACKIT Developer Tools "] description = "Core functionality for the STACKIT SDK for Python" readme = "README.md" From 105947001ac74f2f6d5f60477aa99dacc2e494a0 Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Fri, 15 Nov 2024 12:34:36 +0000 Subject: [PATCH 9/9] move scripts to script folder --- .github/workflows/release-trigger.yaml | 2 +- {.github => scripts}/helper.sh | 0 {.github => scripts}/trigger_script.sh | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) rename {.github => scripts}/helper.sh (100%) rename {.github => scripts}/trigger_script.sh (85%) diff --git a/.github/workflows/release-trigger.yaml b/.github/workflows/release-trigger.yaml index fa623b33b..489200cf4 100644 --- a/.github/workflows/release-trigger.yaml +++ b/.github/workflows/release-trigger.yaml @@ -17,5 +17,5 @@ jobs: git config --global user.name "SDK Releaser Bot" git config --global user.email "noreply@stackit.de" - .github/trigger_script.sh + scripts/trigger_script.sh \ No newline at end of file diff --git a/.github/helper.sh b/scripts/helper.sh similarity index 100% rename from .github/helper.sh rename to scripts/helper.sh diff --git a/.github/trigger_script.sh b/scripts/trigger_script.sh similarity index 85% rename from .github/trigger_script.sh rename to scripts/trigger_script.sh index 14f849379..ea22bd33e 100755 --- a/.github/trigger_script.sh +++ b/scripts/trigger_script.sh @@ -4,8 +4,8 @@ for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do # Extract the current version and buikd the expected tag dirpath=$(dirname $file) - expected_tag=$(.github/helper.sh $dirpath --path-version) - version=$(.github/helper.sh $dirpath) + expected_tag=$(scripts/helper.sh $dirpath --path-version) + version=$(scripts/helper.sh $dirpath) # Check if the tag already exists if git rev-parse --verify $expected_tag^{tag} &> /dev/null; then echo "Tag '$expected_tag' already exists."