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,10 +27,28 @@ 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
+ allowed_pattern="^(major|minor|patch|[0-9]+\.[0-9]+\.[0-9]+)$"
35
+
36
+ if [[ ! ${{ github.event.inputs.versionName }} =~ $allowed_pattern ]]; then
37
+ echo "\nInvalid version name: ${{ github.event.inputs.versionName }}"
38
+ exit 1
39
+ fi
40
+
41
+ if [[ ${{ github.event.inputs.versionName }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
42
+ # use given version number
43
+ NEXT_TAG="${{ github.event.inputs.versionName }}"
44
+ else
45
+ # calculate new version number based on given tag
46
+ NEXT_TAG=$(bump2version --dry-run --list ${{ github.event.inputs.versionName }} | grep ^new_version | sed -r s,"^.*=",,)
47
+ fi
48
+ # apply given or calculated version number
49
+ bump2version --new-version $NEXT_TAG _ignored_arg_
50
+ # save version number for later
51
+ echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
34
52
- name : Get main branch SHA
35
53
id : base-sha
36
54
run : echo "sha=$(git rev-parse origin/main)" >> $GITHUB_OUTPUT
44
62
src/client/packaging/pypi/**
45
63
- name : Bump Python versions if client files changed
46
64
if : steps.changed-py.outputs.any_changed == 'true'
65
+ # _ignored_arg_ below is required because of tool quirk
66
+ # https://github.com/c4urself/bump2version/issues/22
47
67
run : |
48
68
cd src/client/packaging/pypi
49
- bump2version --allow-dirty --new-version ${{ steps.version.outputs.next_tag }} ignore_part
69
+ bump2version --allow-dirty --new-version ${{ steps.version.outputs.next_tag }} _ignored_arg_
50
70
- name : Create pull request into prod
51
71
uses : peter-evans/create-pull-request@v3
52
72
with :
0 commit comments