Skip to content

Commit 5b42a38

Browse files
authored
chore: use version from tag for release (#49)
1 parent a7fae21 commit 5b42a38

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

.github/workflows/cd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ jobs:
3131
- name: Build & Publish to PyPi
3232
run: |
3333
pip install poetry
34-
cd $PACKAGE_PATH
35-
poetry publish --build --username="__token__" --no-interaction --password="${{ secrets.PYPI_TOKEN }}"
34+
cd $PACKAGE_PATH
35+
poetry publish --build --username="__token__" --no-interaction --password="${{ secrets.PYPI_TOKEN }}"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Check Version Update
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check-version:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Push tag for each updated package
14+
run: |
15+
git config --global user.name "SDK Releaser Bot"
16+
git config --global user.email "[email protected]"
17+
18+
for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do
19+
# Extract the change regarding the version from the pyproject.toml file
20+
version_changes=$(git diff HEAD~1..HEAD $file | grep "version =")
21+
# Check if the extracted change is not empty
22+
if [ -n "$version_changes" ]; then
23+
# Split all found version changes, so we can compare the old and new version.
24+
splitted_version_changes=($(echo "$version_changes" | grep -oP '(?<=version = )[^ ]*'))
25+
# Only create a tag if there has been an actual change in the version, not just a format change.
26+
if [ $(echo "${splitted_version_changes[@]}" | tr ' ' '\n' | sort -u | wc -l) -ne 1 ]; then
27+
dirpath=$(dirname $file)
28+
# Extract just the version number
29+
current_version=$(grep -o "version = .*" ${file} | cut -d '=' -f 2-)
30+
dirpath=$(dirname $file)
31+
cleaned_version=$(echo "$current_version" | tr -d '" ')
32+
# Create the tag based on the updated service and the new version
33+
tag=$(echo "${dirpath}/${cleaned_version}")
34+
git tag -a $tag -m "Release $cleaned_version"
35+
git push origin tag $tag
36+
fi
37+
fi
38+
done

core/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "stackit-core"
3-
version = "0.0.1a1"
3+
version = "0.0.1a"
44
authors = [
55
"STACKIT Developer Tools <[email protected]>",
66
]

services/dns/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ per-file-ignores = """
102102
# E501: long descriptions/string values might lead to lines that are too long
103103
# B028: stacklevel for deprecation warning is irrelevant
104104
./src/stackit/*/api/default_api.py: F841,B028,E501
105-
"""
105+
"""

0 commit comments

Comments
 (0)