Skip to content

Commit 10a0a6f

Browse files
rzatsdshemetovmelange396
authored
Decouple client release from Delphi release (#1465)
Co-authored-by: Dmitry Shemetov <[email protected]> Co-authored-by: george <[email protected]>
1 parent bb35b47 commit 10a0a6f

File tree

5 files changed

+72
-13
lines changed

5 files changed

+72
-13
lines changed

.bumpversion.cfg

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ tag = False
99

1010
[bumpversion:file:src/client/delphi_epidata.R]
1111

12-
[bumpversion:file:src/client/delphi_epidata.py]
13-
1412
[bumpversion:file:src/client/packaging/npm/package.json]
1513

16-
[bumpversion:file:src/client/packaging/pypi/pyproject.toml]
17-
1814
[bumpversion:file:dev/local/setup.cfg]

.github/workflows/create-release.yml

+36-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
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 }}

.github/workflows/release-helper.yml

+28-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@ jobs:
1313
if: github.repository_owner != 'cmu-delphi'
1414
run: exit 1
1515

16+
client_changed:
17+
needs: correct_repository
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Check out code
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 2
24+
- name: Get Python client file changes
25+
id: changed-py
26+
uses: dorny/paths-filter@v3
27+
with:
28+
# when base and ref are the same, changes are detected against the most recent commit before the push.
29+
# see https://github.com/dorny/paths-filter#usage for details.
30+
base: 'main'
31+
ref: 'main'
32+
filters: |
33+
python_client_changed:
34+
- src/client/delphi_epidata.py
35+
- src/client/packaging/pypi/**
36+
outputs:
37+
python_client_changed: ${{ steps.changed-py.outputs.python_client_changed }}
38+
1639
create_release:
1740
needs: correct_repository
1841
runs-on: ubuntu-latest
@@ -29,8 +52,8 @@ jobs:
2952
id: extract_version
3053
run: |
3154
python -m pip install bump2version
32-
echo -n "::set-output name=version::"
33-
bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,
55+
VERSION=$(bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,)
56+
echo "version=$VERSION" >> $GITHUB_OUTPUT
3457
- name: Create Release
3558
id: create_release
3659
uses: release-drafter/release-drafter@v5
@@ -45,7 +68,8 @@ jobs:
4568
tag_name: ${{ steps.create_release.outputs.tag_name }}
4669

4770
release_python_client:
48-
needs: create_release
71+
needs: [client_changed, create_release]
72+
if: needs.client_changed.outputs.python_client_changed == 'true'
4973
runs-on: ubuntu-latest
5074
steps:
5175
- name: Check out code
@@ -95,7 +119,7 @@ jobs:
95119
uses: actions/checkout@v2
96120
- uses: actions/setup-node@v2
97121
with:
98-
node-version: '16.x'
122+
node-version: "16.x"
99123
- name: Cache Node.js modules
100124
uses: actions/cache@v2
101125
with:

requirements.dev.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
aiohttp==3.9.4
22
black>=20.8b1
3-
bump2version==1.0.1
43
covidcast==0.1.5
54
delphi_utils
65
docker==6.0.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[bumpversion]
2+
current_version = 4.1.23
3+
commit = False
4+
tag = False
5+
6+
[bumpversion:file:../../delphi_epidata.py]
7+
8+
[bumpversion:file:pyproject.toml]

0 commit comments

Comments
 (0)