From c69083b49d99f28a00a598cf212db91c8723a471 Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Thu, 21 Nov 2024 09:30:32 +0000 Subject: [PATCH 1/2] remove cd extra pipeline --- .github/workflows/cd.yaml | 41 +++++++++++--------------- .github/workflows/release-trigger.yaml | 28 ------------------ scripts/trigger_script.sh | 17 ----------- 3 files changed, 17 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/release-trigger.yaml delete mode 100755 scripts/trigger_script.sh diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 1645a7cc9..882646fb8 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -1,35 +1,28 @@ name: CD Workflow -on: +on: push: - tags: - - "services/[a-zA-Z]+/v[0-9]+.[0-9]+.[0-9]+*" - - "core/v[0-9]+.[0-9]+.[0-9]+*" - workflow_dispatch: + branches: + - main jobs: - main: - name: Build & Publish module - runs-on: "ubuntu-latest" - steps: - - name: Checkout - uses: actions/checkout@v4 + check-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install Python uses: actions/setup-python@v5 with: - python-version: "3.8" - - name: Extract updated module path + python-version: "3.8" + - name: Push tag for each updated package env: - TAG: ${{ github.event.ref }} - run: | - # Remove the `refs/tags` prefix of the git tag - TAG_NO_PREFIX=$(echo "$TAG" | sed 's/^refs\/tags\///') - # Extract the path of the module to publish from the tag - PACKAGE_PATH=$(echo "$TAG_NO_PREFIX" | rev | cut -d'/' -f2- | rev) - # Save the path to the module for use in the build/publish step to only update the module associated with this tag - echo "PACKAGE_PATH=$PACKAGE_PATH" >> $GITHUB_ENV - - name: Build & Publish to PyPi + GH_TOKEN: ${{ secrets.RENOVATE_TOKEN }} run: | + git config --global user.name "SDK Releaser Bot" + git config --global user.email "noreply@stackit.de" + pip install poetry - cd $PACKAGE_PATH - poetry publish --build --username="__token__" --no-interaction --password="${{ secrets.PYPI_TOKEN }}" + scripts/cd.sh + \ No newline at end of file diff --git a/.github/workflows/release-trigger.yaml b/.github/workflows/release-trigger.yaml deleted file mode 100644 index ce42763ef..000000000 --- a/.github/workflows/release-trigger.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Check Version Update - -on: - push: - branches: - - main - -jobs: - check-version: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install Python - uses: actions/setup-python@v5 - with: - python-version: "3.8" - - name: Push tag for each updated package - env: - GH_TOKEN: ${{ secrets.RENOVATE_TOKEN }} - run: | - git config --global user.name "SDK Releaser Bot" - git config --global user.email "noreply@stackit.de" - - pip install poetry - scripts/trigger_script.sh - diff --git a/scripts/trigger_script.sh b/scripts/trigger_script.sh deleted file mode 100755 index d3676a804..000000000 --- a/scripts/trigger_script.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/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 current version and build the expected tag - dirpath=$(dirname $file) - 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." - 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 From 9bf36822e0855431489539bbd06cfa335a75f524 Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Thu, 21 Nov 2024 09:33:25 +0000 Subject: [PATCH 2/2] add renamed file --- scripts/cd.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 scripts/cd.sh diff --git a/scripts/cd.sh b/scripts/cd.sh new file mode 100755 index 000000000..122e51c58 --- /dev/null +++ b/scripts/cd.sh @@ -0,0 +1,19 @@ +#!/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 current version and build the expected tag + dirpath=$(dirname $file) + 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." + else + # Tag doesn't exist. Create tag and build/publish to PyPi + 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 + poetry publish --build --username="__token__" --no-interaction --password="${{ secrets.PYPI_TOKEN }}" + fi +done