Skip to content

Commit 5ff688b

Browse files
committed
dev: Allow new release version to be automatically updated
1 parent 95a1961 commit 5ff688b

2 files changed

Lines changed: 14 additions & 78 deletions

File tree

‎dev/release/README.md‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,19 @@ git push -u apache branch-50 # push branch to apache remote
9090

9191
### 2. Prepare PR to Update the Release Version
9292

93-
Manually update the DataFusion version in the root `Cargo.toml` to
94-
reflect the new release version. Ensure `Cargo.lock` is updated accordingly by
95-
running:
93+
Update the DataFusion version using the following Python script:
9694

9795
```shell
98-
cargo check -p datafusion
96+
# replace NEW_VERSION before executing (e.g., 50.0.0)
97+
python3 dev/update_datafusion_versions.py NEW_VERSION
9998
```
10099

101-
Within the user documentation there are references to the current version number.
102-
Update these to the current version. At the time of this writing we need to manually
103-
update the following files
100+
This updates the DataFusion version across all files, including documentation. The only extra step required is to update the `Cargo.lock` file, using the following command:
101+
104102

105-
- `docs/source/download.md`
106-
- `docs/source/user-guide/configs.md`
107-
- `docs/source/user-guide/crate-configuration.md`
108-
- `docs/source/user-guide/example-usage.md`
103+
```shell
104+
cargo check -p datafusion
105+
```
109106

110107
Then commit the changes and create a PR targeting the release branch `branch-N`.
111108

‎dev/update_datafusion_versions.py‎

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,6 @@
2626
from pathlib import Path
2727
import tomlkit
2828

29-
crates = {
30-
'datafusion-common': 'datafusion/common/Cargo.toml',
31-
'datafusion-common-runtime': 'datafusion/common-runtime/Cargo.toml',
32-
'datafusion': 'datafusion/core/Cargo.toml',
33-
'datafusion-execution': 'datafusion/execution/Cargo.toml',
34-
'datafusion-expr': 'datafusion/expr/Cargo.toml',
35-
'datafusion-ffi': 'datafusion/ffi/Cargo.toml',
36-
'datafusion-functions': 'datafusion/functions/Cargo.toml',
37-
'datafusion-functions-aggregate': 'datafusion/functions-aggregate/Cargo.toml',
38-
'datafusion-functions-nested': 'datafusion/functions-nested/Cargo.toml',
39-
'datafusion-optimizer': 'datafusion/optimizer/Cargo.toml',
40-
'datafusion-physical-expr': 'datafusion/physical-expr/Cargo.toml',
41-
'datafusion-physical-expr-common': 'datafusion/physical-expr-common/Cargo.toml',
42-
'datafusion-physical-plan': 'datafusion/physical-plan/Cargo.toml',
43-
'datafusion-proto': 'datafusion/proto/Cargo.toml',
44-
'datafusion-sql': 'datafusion/sql/Cargo.toml',
45-
'datafusion-sqllogictest': 'datafusion/sqllogictest/Cargo.toml',
46-
'datafusion-substrait': 'datafusion/substrait/Cargo.toml',
47-
'datafusion-wasmtest': 'datafusion/wasmtest/Cargo.toml',
48-
'datafusion-benchmarks': 'benchmarks/Cargo.toml',
49-
'datafusion-cli': 'datafusion-cli/Cargo.toml',
50-
'datafusion-examples': 'datafusion-examples/Cargo.toml',
51-
}
5229

5330
def update_workspace_version(new_version: str):
5431
cargo_toml = 'Cargo.toml'
@@ -64,47 +41,15 @@ def update_workspace_version(new_version: str):
6441

6542
doc = tomlkit.parse(data)
6643

67-
for crate in crates.keys():
68-
df_dep = doc.get('workspace').get('dependencies', {}).get(crate)
44+
for crate, df_dep in doc['workspace']['dependencies'].items():
45+
if not crate.startswith('datafusion'):
46+
continue
6947
# skip crates that pin datafusion using git hash
7048
if df_dep is not None and df_dep.get('version') is not None:
7149
print(f'updating {crate} dependency in {cargo_toml}')
7250
df_dep['version'] = new_version
7351

74-
with open(cargo_toml, 'w') as f:
75-
f.write(tomlkit.dumps(doc))
76-
77-
78-
def update_datafusion_version(cargo_toml: str, new_version: str):
79-
print(f'updating {cargo_toml}')
80-
with open(cargo_toml) as f:
81-
data = f.read()
82-
83-
doc = tomlkit.parse(data)
84-
pkg = doc.get('package')
85-
if 'workspace' not in pkg['version']:
86-
pkg['version'] = new_version
87-
88-
with open(cargo_toml, 'w') as f:
89-
f.write(tomlkit.dumps(doc))
90-
91-
def update_downstream_versions(cargo_toml: str, new_version: str):
92-
with open(cargo_toml) as f:
93-
data = f.read()
94-
95-
doc = tomlkit.parse(data)
96-
97-
for crate in crates.keys():
98-
df_dep = doc.get('dependencies', {}).get(crate)
99-
# skip crates that pin datafusion using git hash
100-
if df_dep is not None and df_dep.get('version') is not None:
101-
print(f'updating {crate} dependency in {cargo_toml}')
102-
df_dep['version'] = new_version
103-
104-
df_dep = doc.get('dev-dependencies', {}).get(crate)
105-
if df_dep is not None and df_dep.get('version') is not None:
106-
print(f'updating {crate} dev-dependency in {cargo_toml}')
107-
df_dep['version'] = new_version
52+
doc['workspace']['package']['version'] = new_version
10853

10954
with open(cargo_toml, 'w') as f:
11055
f.write(tomlkit.dumps(doc))
@@ -117,6 +62,7 @@ def update_docs(path: str, new_version: str):
11762
fd.seek(0)
11863
content = re.sub(r'datafusion\s*=\s*"(.+?)"', f'datafusion = "{new_version}"', content)
11964
content = re.sub(r'datafusion\s*=\s*\{\s*version\s*=\s*"(.+?)"', f'datafusion = {{ version = "{new_version}"', content)
65+
content = re.sub(r'datafusion version \d+\.\d+\.\d+', f'datafusion version {new_version}', content)
12066
fd.truncate()
12167
fd.write(content)
12268

@@ -151,18 +97,11 @@ def main():
15197
print(f'Updating workspace in {repo_root} to {new_version}')
15298
update_workspace_version(new_version)
15399

154-
print(f'Updating datafusion crate versions in {repo_root} to {new_version}')
155-
for cargo_toml in crates.values():
156-
update_datafusion_version(cargo_toml, new_version)
157-
158-
print(f'Updating datafusion dependency versions in {repo_root} to {new_version}')
159-
for cargo_toml in crates.values():
160-
update_downstream_versions(cargo_toml, new_version)
161-
162100
update_docs("README.md", new_version)
163101
update_docs("docs/source/download.md", new_version)
164102
update_docs("docs/source/user-guide/example-usage.md", new_version)
165103
update_docs("docs/source/user-guide/crate-configuration.md", new_version)
104+
update_docs("docs/source/user-guide/configs.md", new_version)
166105

167106
update_ci(new_version)
168107

0 commit comments

Comments
 (0)