diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index 566e7d59..0cf55f63 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -1,8 +1,5 @@ -name: Dependabot auto-merge -on: - workflow_run: - workflows: [ "Dependabot auto-approve" ] - types: [ completed ] +name: Dependabot auto-approve +on: pull_request permissions: contents: write @@ -19,6 +16,19 @@ jobs: with: github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Check Snapshot + if: contains(steps.metadata.outputs.new-version, 'snap') + run: | + echo "::error::Snapshot versions are not allowed – workflow stopped." + exit 1 + + - name: Approve the PR + if: steps.metadata.outputs.update-type == 'version-update:semver-patch' + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Enable auto-merge for Dependabot PRs if: steps.metadata.outputs.update-type == 'version-update:semver-patch' run: gh pr merge --auto --merge "$PR_URL" diff --git a/.github/workflows/dependabot-review.yml b/.github/workflows/dependabot-review.yml deleted file mode 100644 index 97e72b1e..00000000 --- a/.github/workflows/dependabot-review.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Dependabot auto-approve -on: pull_request - -permissions: - pull-requests: write - -jobs: - dependabot: - runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'ie3-institute/PowerSystemUtils' - steps: - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - name: Check Snapshot - if: contains(steps.metadata.outputs.new-version, 'snap') - run: | - echo "::error::Snapshot versions are not allowed – workflow stopped." - exit 1 - - - name: Approve the PR - if: steps.metadata.outputs.update-type == 'version-update:semver-patch' - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/CHANGELOG.md b/CHANGELOG.md index 835155f2..251f9070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed missing scala sources in releases [#549](https://github.com/ie3-institute/PowerSystemUtils/issues/549) - Fixed missing if-block in Version-Check [#557](https://github.com/ie3-institute/PowerSystemUtils/issues/557) +- Improved the fix of Version Check [#559](https://github.com/ie3-institute/PowerSystemUtils/issues/559) ## [3.0.0] diff --git a/scripts/version_check.sh b/scripts/version_check.sh index d7447d76..031fca14 100755 --- a/scripts/version_check.sh +++ b/scripts/version_check.sh @@ -39,12 +39,9 @@ semver_gt() { # Version Checking Logic if [ "$BASE_BRANCH" = "main" ]; then echo "'$BRANCH_TYPE' branch into main => applying '$BRANCH_TYPE' rules" - if [ "$PR_VERSION" = "$MAIN_VERSION" ] && [ "$BRANCH_TYPE" = "feature" ]; then + if [[ "$PR_VERSION" == "$MAIN_VERSION" && ( "$BRANCH_TYPE" == "feature" || "$BRANCH_TYPE" == "dependabot" ) ]]; then echo "OK: PR Version ($PR_VERSION) is identical with the current Main version ($MAIN_VERSION)." exit 0 - elif [ "$BRANCH_TYPE" = "dependabot" ]; then - echo "OK: dependabot-PR – skipping version Check." - exit 0 elif semver_gt "$PR_VERSION" "$MAIN_VERSION" && [ "$BRANCH_TYPE" = "release" ]; then echo "OK: PR Version ($PR_VERSION) is higher than Main version ($MAIN_VERSION)." exit 0