-
Notifications
You must be signed in to change notification settings - Fork 79
197 lines (179 loc) · 7.12 KB
/
Copy pathrelease.yaml
File metadata and controls
197 lines (179 loc) · 7.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Release automation for datafusion-table-providers.
#
# Required repository secrets:
# RELEASE_TOKEN - Admin-capable PAT that can push to protected main and create releases
#
# Required crates.io trusted publishing config for EACH published crate
# (configure under each crate's settings → trusted publishing on crates.io):
# Repository: datafusion-contrib/datafusion-table-providers
# Workflow file: release.yaml
# Environment: crates-io
#
# Crates published by this workflow:
# datafusion-table-providers-common
# datafusion-table-providers-odbc
# datafusion-table-providers-clickhouse
# datafusion-table-providers-flightsql
# datafusion-table-providers-mongodb
# datafusion-table-providers-mysql
# datafusion-table-providers-sqlite
# datafusion-table-providers-postgres
# datafusion-table-providers-duckdb
# datafusion-table-providers-adbc
# datafusion-table-providers (facade)
#
# Also create a GitHub Environment named "crates-io" (Settings → Environments).
#
# Trigger via Actions → Release → Run workflow, providing the new version (e.g. 0.13.0 or v0.13.0).
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. 0.13.0 or v0.13.0)'
required: true
type: string
permissions:
contents: write
id-token: write
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
name: Release
runs-on: ubuntu-latest
environment: crates-io
steps:
- name: Normalize and validate version
id: version
run: |
raw="${{ inputs.version }}"
version="${raw#v}"
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid version: '$raw' (expected X.Y.Z or vX.Y.Z)"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=v${version}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v7
with:
ref: main
token: ${{ secrets.RELEASE_TOKEN }}
fetch-depth: 0
- name: Bump workspace version
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
python3 <<'PY'
import pathlib
import re
import os
version = os.environ["VERSION"]
cargo_toml = pathlib.Path("Cargo.toml")
text = cargo_toml.read_text()
def bump_workspace_package_version(contents: str, new_version: str) -> str:
lines = contents.splitlines(keepends=True)
in_workspace_package = False
replaced = False
out = []
for line in lines:
if line.startswith("[") and line.strip().endswith("]"):
in_workspace_package = line.strip() == "[workspace.package]"
if in_workspace_package and re.match(r'^version\s*=\s*"', line):
out.append(f'version = "{new_version}"\n')
replaced = True
in_workspace_package = False
continue
out.append(line)
if not replaced:
raise SystemExit("Failed to find [workspace.package] version in Cargo.toml")
return "".join(out)
cargo_toml.write_text(bump_workspace_package_version(text, version))
# Keep path+version workspace deps in sync for crates.io publish.
workspace_crate_names = (
"datafusion-table-providers",
"datafusion-table-providers-common",
"datafusion-table-providers-odbc",
"datafusion-table-providers-clickhouse",
"datafusion-table-providers-flightsql",
"datafusion-table-providers-mongodb",
"datafusion-table-providers-mysql",
"datafusion-table-providers-sqlite",
"datafusion-table-providers-postgres",
"datafusion-table-providers-duckdb",
"datafusion-table-providers-adbc",
)
cargo_text = cargo_toml.read_text()
for name in workspace_crate_names:
pattern = (
rf'(?m)^({re.escape(name)}\s*=\s*\{{\s*version\s*=\s*")[^"]+(")'
)
cargo_text, count = re.subn(pattern, rf"\g<1>{version}\g<2>", cargo_text, count=1)
if count != 1:
raise SystemExit(
f"Failed to update workspace.dependencies version for {name} in Cargo.toml"
)
cargo_toml.write_text(cargo_text)
lock = pathlib.Path("Cargo.lock")
lock_text = lock.read_text()
for name in (
*workspace_crate_names,
"datafusion-table-providers-python",
):
pattern = (
rf'(?m)(^\[\[package\]\]\nname = "{re.escape(name)}"\nversion = ")[^"]+(")'
)
lock_text, count = re.subn(pattern, rf"\g<1>{version}\g<2>", lock_text, count=1)
if count != 1:
raise SystemExit(f"Failed to update version for {name} in Cargo.lock")
lock.write_text(lock_text)
PY
- name: Commit and push version bump
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Cargo.toml Cargo.lock
if git diff --staged --quiet; then
echo "No version changes to commit (already at ${TAG}?)"
exit 1
fi
git commit -m "${TAG}"
git push origin HEAD:main
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
TAG: ${{ steps.version.outputs.tag }}
run: |
gh release create "${TAG}" \
--target main \
--title "${TAG}" \
--generate-notes
- uses: dtolnay/rust-toolchain@stable
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Authenticate with crates.io
id: crates-io-auth
uses: rust-lang/crates-io-auth-action@v1
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
run: |
# Publish in dependency order: common → leaves → facade
cargo publish -p datafusion-table-providers-common
cargo publish -p datafusion-table-providers-odbc
cargo publish -p datafusion-table-providers-clickhouse
cargo publish -p datafusion-table-providers-flightsql
cargo publish -p datafusion-table-providers-mongodb
cargo publish -p datafusion-table-providers-mysql
cargo publish -p datafusion-table-providers-sqlite
cargo publish -p datafusion-table-providers-postgres
cargo publish -p datafusion-table-providers-duckdb
cargo publish -p datafusion-table-providers-adbc
cargo publish -p datafusion-table-providers