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/cd.sh similarity index 80% rename from scripts/trigger_script.sh rename to scripts/cd.sh index d3676a804..122e51c58 100755 --- a/scripts/trigger_script.sh +++ b/scripts/cd.sh @@ -10,8 +10,10 @@ for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do 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