-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from ai-cfia/141-add-optional-checks-in-pytho…
…n-lint-if-the-version-in-pyprojecttoml-file-has-been-bumped-fails-pipeline-if-not-bumped Issue #141: adds jobs for validating version bump
- Loading branch information
Showing
3 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Reusable version bump check validation workflow for Python projects | ||
|
||
- **Purpose:** Validate the version bump in a Python project. | ||
- **Usage:** Call this workflow in your Python projects. | ||
|
||
```yaml | ||
lint-test: | ||
uses: | ||
ai-cfia/github-workflows/.github/workflows/workflow-version-bump-python.yml@main | ||
secrets: inherit | ||
with: | ||
pyproject-path: 'pyproject.toml' | ||
package-name: 'my-package' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Reusable version bump check validation workflow for Python projects | ||
|
||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
pyproject-path: | ||
required: false | ||
type: string | ||
package-name: | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
version-bump-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Parse new version from pyproject.toml | ||
id: parse_new_version | ||
run: | | ||
new_version=$(grep -Po '(?<=^version = ")[^"]*' ${{ inputs.pyproject-path }}) | ||
echo "new_version=$new_version" >> $GITHUB_ENV | ||
- name: Get latest version | ||
id: get_latest_version | ||
run: | | ||
package_name="${{ inputs.package-name }}" | ||
latest_tag=$(git tag --list "v*-*${package_name}" --sort=-creatordate | head -n 1) | ||
latest_version=$(echo $latest_tag | grep -oP '(?<=v)[0-9]+\.[0-9]+\.[0-9]+') | ||
echo "latest_version=$latest_version" >> $GITHUB_ENV | ||
- name: Check version bump | ||
run: | | ||
if [ "${{ env.new_version }}" == "${{ env.latest_version }}" ]; then | ||
echo "Version has not been bumped!" | ||
exit 1 | ||
else | ||
echo "Version has been bumped." | ||
fi |