4
4
workflow_dispatch :
5
5
inputs :
6
6
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)'
8
8
required : true
9
9
default : patch
10
10
@@ -27,11 +27,43 @@ jobs:
27
27
python-version : 3.8
28
28
- name : Change version number
29
29
id : version
30
+ # See this issue for explanation and testing:
31
+ # https://github.com/cmu-delphi/delphi-epidata/pull/1473
30
32
run : |
31
33
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
35
67
uses : peter-evans/create-pull-request@v3
36
68
with :
37
69
branch : release/delphi-epidata-${{ steps.version.outputs.next_tag }}
0 commit comments