diff --git a/.github/actions/check_version/action.yml b/.github/actions/check_version/action.yml index dfcfffe..271f75f 100644 --- a/.github/actions/check_version/action.yml +++ b/.github/actions/check_version/action.yml @@ -51,14 +51,14 @@ runs: changelog_increment_filename: body.md push: ${{ inputs.push }} - name: Find Comment - if: ${{ inputs.pr_number != '' }} + if: ${{ inputs.pr_number != '' && steps.cz.outputs.version != steps.project.outputs.old_version }} uses: peter-evans/find-comment@v3 id: fc with: issue-number: ${{ inputs.pr_number }} - comment-author: "github-actions[bot]" + comment-author: "version-reporter[bot]" - name: Create bump comment - if: ${{ inputs.pr_number != '' }} + if: ${{ inputs.pr_number != '' && steps.cz.outputs.version != steps.project.outputs.old_version }} uses: peter-evans/create-or-update-comment@v4 with: comment-id: ${{ steps.fc.outputs.comment-id }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cdd9f39..6eea214 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -18,37 +18,26 @@ jobs: version: name: Set Name and Version from pyproject.toml to output runs-on: ubuntu-latest + environment: + name: pypi needs: - integration_tests outputs: - name: ${{ steps.project.outputs.NAME }} - old_version: ${{ steps.project.outputs.OLD_VERSION }} - new_version: ${{ steps.cz.outputs.version }} + name: ${{ steps.check_version.outputs.name }} + old_version: ${{ steps.check_version.outputs.old_version }} + new_version: ${{ steps.check_version.outputs.new_version }} + is_changed: ${{ steps.check_version.outputs.is_changed }} steps: - - name: Check out - uses: actions/checkout@v4 - with: - token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" - fetch-depth: 0 - - name: Set Name and Version from pyproject.toml to output - id: project - run: | - name=$(grep "^name" pyproject.toml -m 1 | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3 | tr "-" "_") - version=$(grep "^version" pyproject.toml -m 1 | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3) - echo "NAME=$name" >> $GITHUB_OUTPUT - echo "OLD_VERSION=$version" >> $GITHUB_OUTPUT - echo "Releasing $name version $version" - - name: Create bump and changelog - id: cz - uses: commitizen-tools/commitizen-action@master + - name: Check Version + uses: ./.github/actions/check_version + id: check_version with: - github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - changelog_increment_filename: body.md + github_token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" push: true pypi-publish: name: Upload release to PyPI runs-on: ubuntu-latest - if: ${{ needs.version.outputs.new_version != needs.version.outputs.old_version }} + if: ${{ needs.version.outputs.is_changed }} needs: - integration_tests - version diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index fa6c260..f7f1a98 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -39,34 +39,3 @@ jobs: github_token: ${{ github.token }} push: false pr_number: ${{ github.event.pull_request.number }} - # - name: Set Name and Version from pyproject.toml to output - # id: project - # run: | - # name=$(grep "^name" pyproject.toml -m 1 | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3 | tr "-" "_") - # version=$(grep "^version" pyproject.toml -m 1 | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3) - # echo "NAME=$name" >> $GITHUB_OUTPUT - # echo "VERSION=$version" >> $GITHUB_OUTPUT - # echo "Releasing $name version $version" - # - name: Create bump and changelog - # id: cz - # uses: commitizen-tools/commitizen-action@master - # with: - # github_token: ${{ github.token }} - # changelog_increment_filename: body.md - # dry_run: true - # push: false - # - name: Find Comment - # if: steps.check_version.outputs.is_changed == 'true' - # uses: peter-evans/find-comment@v3 - # id: fc - # with: - # issue-number: ${{ github.event.pull_request.number }} - # comment-author: "github-actions[bot]" - # - name: Create bump comment - # if: steps.check_version.outputs.is_changed == 'true' - # uses: peter-evans/create-or-update-comment@v4 - # with: - # comment-id: ${{ steps.fc.outputs.comment-id }} - # issue-number: ${{ github.event.pull_request.number }} - # body-file: body.md - # edit-mode: replace