Skip to content

Commit 0e9500f

Browse files
committed
Single commit
1 parent 30c6206 commit 0e9500f

File tree

5 files changed

+68
-104
lines changed

5 files changed

+68
-104
lines changed

.bumpversion.cfg

Lines changed: 0 additions & 4 deletions
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

Lines changed: 36 additions & 7 deletions
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,19 +27,48 @@ 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 }}
3870
commit-message: 'chore: release delphi-epidata ${{ steps.version.outputs.next_tag }}'
3971
base: main
4072
title: Release Delphi Epidata ${{ steps.version.outputs.next_tag }}
41-
labels: chore
42-
reviewers: melange396
43-
assignees: melange396
4473
body: |
4574
Releasing Delphi Epidata ${{ steps.version.outputs.next_tag }}.

.github/workflows/release-helper.yml

Lines changed: 24 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -10,79 +10,46 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: fail on fork
13-
if: github.repository_owner != 'cmu-delphi'
13+
if: github.repository_owner == 'cmu-delphi'
1414
run: exit 1
1515

16-
create_release:
16+
client_changed:
1717
needs: correct_repository
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Check out code
2121
uses: actions/checkout@v2
2222
with:
23-
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
24-
- name: Set up Python 3.8
25-
uses: actions/setup-python@v2
26-
with:
27-
python-version: 3.8
28-
- name: Extract version
29-
id: extract_version
30-
run: |
31-
python -m pip install bump2version
32-
echo -n "::set-output name=version::"
33-
bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,
34-
- name: Create Release
35-
id: create_release
36-
uses: release-drafter/release-drafter@v5
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
fetch-depth: 2
24+
- name: Get Python client file changes
25+
id: changed-py
26+
uses: dorny/paths-filter@v3
3927
with:
40-
version: ${{ steps.extract_version.outputs.version }}
41-
publish: true
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/**
4236
outputs:
43-
version: ${{ steps.extract_version.outputs.version }}
44-
upload_url: ${{ steps.create_release.outputs.upload_url }}
45-
tag_name: ${{ steps.create_release.outputs.tag_name }}
37+
python_client_changed: ${{ steps.changed-py.outputs.python_client_changed }}
38+
39+
create_release:
40+
needs: correct_repository
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Check out code
44+
uses: actions/checkout@v2
4645

4746
release_python_client:
48-
needs: create_release
47+
needs: [client_changed, create_release]
48+
if: needs.client_changed.outputs.python_client_changed == 'true'
4949
runs-on: ubuntu-latest
5050
steps:
5151
- name: Check out code
5252
uses: actions/checkout@v2
53-
- name: Set up Python 3.8
54-
uses: actions/setup-python@v2
55-
with:
56-
python-version: 3.8
57-
- name: Install build dependencies
58-
run: |
59-
python -m pip install --upgrade pip
60-
pip install build wheel twine
61-
- name: Prepare package
62-
run: |
63-
cp src/client/*.py src/client/packaging/pypi/delphi_epidata/
64-
- name: Create release
65-
working-directory: src/client/packaging/pypi
66-
run: |
67-
python -m build --sdist --wheel
68-
- uses: actions/upload-artifact@v2
69-
with:
70-
name: delphi_epidata_py
71-
path: src/client/packaging/pypi/dist/*.tar.gz
72-
- name: Upload Release Asset
73-
uses: AButler/[email protected]
74-
with:
75-
files: "src/client/packaging/pypi/dist/*.tar.gz"
76-
repo-token: ${{ secrets.GITHUB_TOKEN }}
77-
release-tag: ${{ needs.create_release.outputs.tag_name }}
78-
- name: Publish a Python distribution to PyPI
79-
uses: pypa/gh-action-pypi-publish@release/v1
80-
with:
81-
user: __token__
82-
password: ${{ secrets.DELPHI_PYPI_PROD_TOKEN }}
83-
packages-dir: src/client/packaging/pypi/dist/
84-
skip-existing: true
85-
# repository_url: https://test.pypi.org/legacy/
8653

8754
release_js_client:
8855
needs: create_release
@@ -93,38 +60,6 @@ jobs:
9360
steps:
9461
- name: Check out code
9562
uses: actions/checkout@v2
96-
- uses: actions/setup-node@v2
97-
with:
98-
node-version: '16.x'
99-
- name: Cache Node.js modules
100-
uses: actions/cache@v2
101-
with:
102-
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
103-
key: ${{ runner.OS }}-node2-${{ hashFiles('**/package-lock.json') }}
104-
restore-keys: |
105-
${{ runner.OS }}-node2-
106-
- run: npm ci
107-
- run: npm test
108-
- run: npm pack
109-
- name: Rename to a different name
110-
run: for f in *.tgz; do mv "$f" "$(echo "$f" | sed s/delphi_epidata-/delphi_epidata_js-/)"; done
111-
- uses: actions/upload-artifact@v2
112-
with:
113-
name: delphi_epidata_js
114-
path: src/client/packaging/npm/*.tgz
115-
- name: Upload Release Asset
116-
uses: AButler/[email protected]
117-
with:
118-
files: "src/client/packaging/npm/*.tgz"
119-
repo-token: ${{ secrets.GITHUB_TOKEN }}
120-
release-tag: ${{ needs.create_release.outputs.tag_name }}
121-
- name: Publish to NPM
122-
uses: JS-DevTools/npm-publish@v1
123-
with:
124-
token: ${{ secrets.DELPHI_NPM_TOKEN }}
125-
package: src/client/packaging/npm/package.json
126-
access: public
127-
check-version: true
12863

12964
sync_dev:
13065
needs: correct_repository
@@ -146,8 +81,5 @@ jobs:
14681
commit-message: "chore: sync main-dev"
14782
base: dev
14883
title: "chore: sync main->dev"
149-
labels: chore
150-
reviewers: melange396
151-
assignees: melange396
15284
body: |
15385
Syncing Main->Dev.

requirements.dev.txt

Lines changed: 0 additions & 1 deletion
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
Lines changed: 8 additions & 0 deletions
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)