Skip to content

Commit c025b85

Browse files
committed
ci(bump): implement automatic PR creation
1 parent c5679f7 commit c025b85

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

latex/bump-apk-versions.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ if [ -f /.dockerenv ]; then
1414
u=$(\apk -u list | \tr '\n' '|')
1515

1616
\sed -e :a -e '/\\$/N; s/\\\n//; ta' Dockerfile | \grep -o -e 'apk[^\&\;]*add[^\&\;]*' | \grep -o -e '[^ ]*=[^ ]*' | while IFS= \read -r l; do
17+
\rm -f .bump.csv.bak
1718
p="${l%=*}"
1819
v1="${l#*=}"
1920
v="$(\echo "|${u}" | \grep -o -e "\|${p}-[^\|]*upgradable from: ${p}-${v1}" || true)"
@@ -24,12 +25,14 @@ if [ -f /.dockerenv ]; then
2425
v2="$(\echo "${v}" | \cut -d ' ' -f 1 | \cut -c ${n}-)"
2526
if [ -n "${v2}" ] && [ "${v2}" != "${v1}" ]; then
2627
\echo "${p} ${v1} -> ${v2}"
27-
\perl -i -p -e "s|\Q${l}\E|${p}=${v2}|g" Dockerfile
28+
\echo "${p},${v1},${v2},${p}=${v1},${p}=${v2}" >>.bump.csv.bak
2829
fi
2930
done
3031

3132
else
3233

33-
\docker run --pull always --rm -t --user root -v "$(pwd):/opt/bump" "leplusorg/${PWD##*/}:alpine" /opt/bump/"$(\basename "${0}")"
34+
\docker run --pull always --rm -t --user root -v "$(pwd):/opt/bump" "leplusorg/${PWD##*/}:main" /opt/bump/"$(\basename "${0}")"
35+
36+
./create-prs.sh
3437

3538
fi

latex/create-prs.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
cd "$(\dirname "${0}")"
6+
7+
if [ -f .bump.csv.bak ]; then
8+
if [ "$(\git status --porcelain=1 | wc -l)" -ne 0 ]; then
9+
>&2 echo "error: git repo contains uncommitted changes"
10+
exit 1
11+
fi
12+
csv="$(\cat .bump.csv.bak)"
13+
\rm -f .bump.csv.bak
14+
while IFS="," read -r p v1 v2 l1 l2; do
15+
b="${p}-${v2}"
16+
\git switch --create "${b}"
17+
\perl -i -p -e "s|\Q${l1}\E|${l2}|g" Dockerfile
18+
\git add Dockerfile
19+
\git commit -S -m "build(deps): bump ${p} from ${v1} to ${v2}"
20+
read -n 1 -s -r -p "Please review and push commit in branch \"${b}\". Press enter to continue..."
21+
\gh pr create -f -l build -l dependencies -B alpine
22+
\git checkout -
23+
done <<<"${csv}"
24+
else
25+
>&2 echo "error: nothing to do"
26+
exit 1
27+
fi

0 commit comments

Comments
 (0)