diff --git a/.github/workflows/workflow-lint-test-python.yml b/.github/workflows/workflow-lint-test-python.yml index 64bbd401..5e86595a 100644 --- a/.github/workflows/workflow-lint-test-python.yml +++ b/.github/workflows/workflow-lint-test-python.yml @@ -3,6 +3,13 @@ name: Reusable lint and test workflow for Python projects on: workflow_call: + inputs: + pyproject-path: + required: false + type: string + package-name: + required: false + type: string permissions: actions: read @@ -49,3 +56,35 @@ jobs: - name: Run tests with coverage (coverage must be at least 80% to pass) run: | pytest --cov=. --cov-fail-under=80 tests/ # default value, coverage must be at least 80% + + version-bump-check: + runs-on: ubuntu-latest + if: inputs.pyproject-path != '' + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Parse version from pyproject.toml + id: parse_version + run: | + version=$(grep -Po '(?<=^version = ")[^"]*' ${{ inputs.pyproject-path }}) + echo "version=$version" >> $GITHUB_ENV + + - name: Get latest tag + id: get_latest_tag + run: | + latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1)) + echo "latest_tag=$latest_tag" >> $GITHUB_ENV + + - name: Check version bump + run: | + if [ "$version" == "$latest_tag" ]; then + echo "Version has not been bumped!" + exit 1 + else + echo "Version has been bumped." + fi