Skip to content

Commit

Permalink
ci: add reusable action for checking version
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Peder Meldgaard <[email protected]>
  • Loading branch information
JenspederM committed Jan 3, 2025
1 parent 76b165e commit d6e62cd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 56 deletions.
6 changes: 3 additions & 3 deletions .github/actions/check_version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
33 changes: 11 additions & 22 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d6e62cd

Please sign in to comment.