Skip to content

Commit 13a32fb

Browse files
committed
ci: Bump OTP every two months when possible
Every two months, a scheduler will align the OTP matrix with Debian. A token with workflow permission is needed. GH issue: erlware#179 Link: https://packages.debian.org/search?keywords=erlang Signed-off-by: Ariel Otilibili <[email protected]>
1 parent 11d1c06 commit 13a32fb

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

.github/workflows/otp-bump.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: OTP bump
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
8+
jobs:
9+
otp-bump:
10+
name: Bump OTP versions
11+
runs-on: ubuntu-latest
12+
13+
permissions: write-all
14+
15+
steps:
16+
- uses: actions/checkout@master
17+
with:
18+
submodules: true
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.12
24+
- name: Setup dependencies
25+
run: pip install requests beautifulsoup4
26+
- name: Pull OTP versions from Debian
27+
run: python3 bump-otp-matrix.py
28+
- name: Create Pull Request
29+
uses: peter-evans/create-pull-request@v7
30+
with:
31+
token: ${{ secrets.OTP_BUMP }}
32+
delete-branch: true
33+
commit-message: 'Bump OTP'
34+
branch: 'create-pull-request/otp-bump'
35+
title: 'OTP bump'
36+
body: |
37+
### OTP bump
38+
Aligned versions with [Debian](https://packages.debian.org/search?keywords=erlang).

bump-otp-matrix.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
__author__ = "Ariel Otilibili <[email protected]>"
2+
__copyright__ = "Copyright (c) 2025 Ariel Otilibili"
3+
__license__ = "MIT "
4+
5+
import json
6+
import requests
7+
import re
8+
9+
from bs4 import BeautifulSoup
10+
11+
URL = "https://packages.debian.org/search?keywords=erlang"
12+
WORKFLOW = ".github/workflows/main.yml"
13+
14+
def get_webpage_in_html(url):
15+
response = requests.get(url)
16+
return BeautifulSoup(response.content)
17+
18+
19+
def get_latest_otp_versions(webpage):
20+
# Samples of expected 'li' elements:
21+
#
22+
# <li class="bullseye"><a class="resultlink" href="/bullseye/erlang">bullseye (oldstable)</a> (interpreters):
23+
# Concurrent, real-time, distributed functional language
24+
#
25+
# <br/>1:23.2.6+dfsg-1+deb11u2 [<strong class="pmarker" title="">security</strong>]: all
26+
#
27+
#
28+
# </li>
29+
# <li class="bookworm"><a class="resultlink" href="/bookworm/erlang">bookworm (stable)</a> (interpreters):
30+
# Concurrent, real-time, distributed functional language
31+
#
32+
# <br/>1:25.2.3+dfsg-1+deb12u1: all
33+
#
34+
#
35+
# </li>
36+
HEADER = "Concurrent, real-time, distributed functional language"
37+
OTP_REGEX = r"1:(\d+)"
38+
39+
versions = {
40+
m.group(1)
41+
for p in webpage.find_all("li")
42+
if re.search(HEADER, p.text)
43+
and not re.search("security", p.text)
44+
and (m := re.search(OTP_REGEX, p.text))
45+
}
46+
47+
return sorted(list(versions), reverse=True)
48+
49+
50+
def update_otp_versions(versions, workflow):
51+
otp_versions = ', '.join(f"'{version}'" for version in versions)
52+
53+
with open(workflow) as ci:
54+
conf = ci.read()
55+
56+
conf = re.sub("(otp_version: ).*\n", "\\1" + f"[{otp_versions}]" + "\n", conf)
57+
58+
with open(workflow, "w") as ci:
59+
ci.write(conf)
60+
61+
62+
if __name__ == "__main__":
63+
webpage = get_webpage_in_html(URL)
64+
versions = get_latest_otp_versions(webpage)
65+
update_otp_versions(versions, WORKFLOW)
66+
67+
print(json.dumps({'source': URL, 'versions': versions, 'file-changed': WORKFLOW}))

0 commit comments

Comments
 (0)