44 workflow_dispatch :
55 inputs :
66 versionName :
7- description : ' Semantic Version Number (i.e., 5.5.0 or patch, minor, major, prepatch, preminor, premajor, prerelease )'
7+ description : ' Semantic Version Number (i.e., 5.5.0 or patch, minor, major)'
88 required : true
99 default : patch
1010
@@ -27,11 +27,43 @@ jobs:
2727 python-version : 3.8
2828 - name : Change version number
2929 id : version
30+ # See this issue for explanation and testing:
31+ # https://github.com/cmu-delphi/delphi-epidata/pull/1473
3032 run : |
3133 python -m pip install bump2version
32- echo -n "::set-output name=next_tag::"
33- bump2version --list ${{ github.event.inputs.versionName }} | grep new_version | sed -r s,"^.*=",,
34- - name : Create pull request into prod
34+ if [[ ${{ github.event.inputs.versionName }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
35+ # use given version number
36+ NEXT_TAG="${{ github.event.inputs.versionName }}"
37+ elif [[ ${{ github.event.inputs.versionName }} =~ ^(major|minor|patch)$ ]]; then
38+ # calculate new version number based on given tag
39+ NEXT_TAG=$(bump2version --dry-run --list ${{ github.event.inputs.versionName }} | grep ^new_version | sed -r s,"^.*=",,)
40+ else
41+ echo "\nInvalid version name: ${{ github.event.inputs.versionName }}"
42+ exit 1
43+ fi
44+ # apply given or calculated version number
45+ bump2version --new-version $NEXT_TAG _ignored_arg_
46+ # save version number for later
47+ echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
48+ - name : Get Python client file changes
49+ id : changed-py
50+ uses : dorny/paths-filter@v3
51+ with :
52+ base : " main"
53+ ref : " dev"
54+ filters : |
55+ python_client_changed:
56+ - src/client/delphi_epidata.py
57+ - src/client/packaging/pypi/**
58+ - name : Bump Python versions if client files changed
59+ if : steps.changed-py.outputs.python_client_changed == 'true'
60+ # _ignored_arg_ below is required because of tool quirk
61+ # https://github.com/c4urself/bump2version/issues/22
62+ run : |
63+ cd src/client/packaging/pypi
64+ # this is using the new literal version number (steps.version.outputs.next_tag) output from the bump2version step above, not the workflow input (github.event.inputs.versionName) which can be relative
65+ bump2version --allow-dirty --new-version ${{ steps.version.outputs.next_tag }} _ignored_arg_
66+ - name : Create pull request into main
3567 uses : peter-evans/create-pull-request@v3
3668 with :
3769 branch : release/delphi-epidata-${{ steps.version.outputs.next_tag }}
0 commit comments