Skip to content

Commit 6cff2a5

Browse files
authored
Merge pull request #192 from ariel-anieli/otp-bump-workflow
ci: Bump OTP every two months
2 parents 11d1c06 + 8bf857c commit 6cff2a5

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-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+
schedule:
8+
- cron: "0 0 1 */2 *" # Every two months
9+
10+
jobs:
11+
otp-bump:
12+
name: Bump OTP versions
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@11bd719 # v4
17+
with:
18+
submodules: true
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@a26af69 # 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@271a8d0 # v7.0.8
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: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
15+
def get_webpage_in_html(url):
16+
response = requests.get(url)
17+
return BeautifulSoup(response.content)
18+
19+
20+
def get_latest_otp_versions(webpage):
21+
# Samples of expected 'li' elements:
22+
#
23+
# <li class="bullseye"><a class="resultlink" href="/bullseye/erlang">bullseye (oldstable)</a> (interpreters):
24+
# Concurrent, real-time, distributed functional language
25+
#
26+
# <br/>1:23.2.6+dfsg-1+deb11u2 [<strong class="pmarker" title="">security</strong>]: all
27+
#
28+
#
29+
# </li>
30+
# <li class="bookworm"><a class="resultlink" href="/bookworm/erlang">bookworm (stable)</a> (interpreters):
31+
# Concurrent, real-time, distributed functional language
32+
#
33+
# <br/>1:25.2.3+dfsg-1+deb12u1: all
34+
#
35+
#
36+
# </li>
37+
HEADER = "Concurrent, real-time, distributed functional language"
38+
OTP_REGEX = r"1:(\d+)"
39+
40+
versions = {
41+
m.group(1)
42+
for p in webpage.find_all("li")
43+
if re.search(HEADER, p.text)
44+
and not re.search("security", p.text)
45+
and (m := re.search(OTP_REGEX, p.text))
46+
}
47+
48+
return sorted(list(versions), reverse=True)
49+
50+
51+
def update_otp_versions(versions, workflow):
52+
otp_versions = ", ".join(f"'{version}'" for version in versions)
53+
54+
with open(workflow) as ci:
55+
conf = ci.read()
56+
57+
conf = re.sub("(otp_version: ).*\n", "\\1" + f"[{otp_versions}]" + "\n", conf)
58+
59+
with open(workflow, "w") as ci:
60+
ci.write(conf)
61+
62+
63+
if __name__ == "__main__":
64+
webpage = get_webpage_in_html(URL)
65+
versions = get_latest_otp_versions(webpage)
66+
update_otp_versions(versions, WORKFLOW)
67+
68+
print(json.dumps({"source": URL, "versions": versions, "file-changed": WORKFLOW}))

0 commit comments

Comments
 (0)