Skip to content

Commit 2444eaa

Browse files
committed
try with py
1 parent 8f6fdeb commit 2444eaa

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,43 @@ jobs:
9191
new_version="${{ inputs.new_version }}" # Or use ${{ env.NEW_VERSION }} if you set it as an env variable
9292
9393
# Replace the version of spmgraph in the spmgraph config package template
94-
sed -i.bak -E \
95-
's|(url: "https://github.com/getyourguide/spmgraph.git",[[:space:]]*exact: ")[^"]*"|\1'"$new_version"'"|g' \
96-
"$file"
94+
python3 - <<PY
95+
import io,sys,re
96+
97+
with open(file_path, "r", encoding="utf-8") as f:
98+
lines = f.readlines()
99+
100+
in_block = False
101+
changed = False
102+
out = []
103+
url_marker = 'https://github.com/getyourguide/spmgraph.git'
104+
105+
for i, line in enumerate(lines):
106+
out.append(line)
107+
if url_marker in line:
108+
in_block = True
109+
continue
110+
if in_block:
111+
# end of block when we hit a line that is just ')' or '),'
112+
if re.match(r'^\s*\),?\s*, line):
113+
in_block = False
114+
continue
115+
m = re.search(r'(exact:\s*)"([^"]*)"', line)
116+
if m:
117+
prefix = m.group(1)
118+
indent = line[:line.index(prefix)]
119+
new_line = indent + prefix + '"' + new_version + '"' + '\n'
120+
out[-1] = new_line
121+
changed = True
122+
in_block = False # stop after replacing first exact in the block
123+
124+
if changed:
125+
with open(file_path, "w", encoding="utf-8") as f:
126+
f.writelines(out)
127+
print("changed=true")
128+
else:
129+
print("changed=false")
130+
PY
97131
98132
# (Debug) cat the file
99133
cat "$file"

0 commit comments

Comments
 (0)