Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/actions/sqliteversion/.action.yml.swp
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions .github/actions/sqliteversion/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM python:alpine-3.9
COPY entrypoint.py /entrypoint.py
ENTRYPOINT [ "entrypoint.py" ]
10 changes: 10 additions & 0 deletions .github/actions/sqliteversion/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Get SQLite version"
description: "Get latest SQLite version information"
outputs:
version:
description: "SQLite version"
date:
description: "Release date"
runs:
using: "docker"
image: "Dockerfile"
67 changes: 67 additions & 0 deletions .github/actions/sqliteversion/entrypoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python3.9

import itertools
import urllib.request
from html.parser import HTMLParser

URL = "https://sqlite.org/chronology.html"
row_counter = itertools.count()
rows = {}


def get_chronology_page():
"""Fetch history of SQLite releases"""
with urllib.request.urlopen(URL) as f:
return f.read().decode()


class ParseVersionTable(HTMLParser):
def _add_row(self):
self.current_row = next(row_counter)
self.column_counter = itertools.count()
rows[self.current_row] = {}

def _add_column(self, attrs):
self.current_column = next(self.column_counter)
rows[self.current_row][self.current_column] = self._get_version_attr(attrs)

def _add_data(self, data):
try:
if not rows[self.current_row][self.current_column]:
rows[self.current_row][self.current_column] = data
except AttributeError:
pass

def _get_version_attr(self, attrs):
VERSION_ATTR = "data-sortkey"
for attr in attrs:
if attr[0] == VERSION_ATTR:
return attr[1]

def _verify_row(self):
row = rows[self.current_row]
assert len(row) == 2

def handle_starttag(self, tag, attrs):
if tag == "tr":
self._add_row()
elif tag == "td":
self._add_column(attrs)

def handle_endtag(self, tag):
if tag == "tr":
self._verify_row()

def handle_data(self, data):
self._add_data(data)


if __name__ == "__main__":
parser = ParseVersionTable()
parser.feed(get_chronology_page())

rows = [(v[1], v[0]) for k, v in rows.items() if v]
latest = rows[0]

print(f"::set-output name=version::{latest[0]}")
print(f"::set-output name=date::{latest[1]}")
52 changes: 52 additions & 0 deletions .github/workflows/sqlitebot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Auto-update SQLite sources"

on:
schedule:
- cron: "*/5 * * * *"

jobs:
upgrade:
name: "Upgrade SQLite sources"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
ref: sqlite

- name: "Get latest version"
id: version
uses: .github/actions/sqliteversion

- name: "Get URL"
id: url
env:
DATE: ${{ steps.version.outputs.date }}
VERSION: ${{ steps.version.outputs.version }}
run: |
YEAR=$(echo $DATE | cut -d '-' -f 1)
URL="https://sqlite.org/$YEAR/sqlite-amalgamation-${VERSION}.zip"
echo "::set-output name=url::$URL"

- name: "Download and extract SQLite amalgamation sources"
env:
URL: ${{ steps.url.outputs.url }}
run: |
curl -sO $URL

ARCHIVE=$(basename $URL)
unzip -o $ARCHIVE

DIR=$(basename $ARCHIVE .zip)
for _F in *.[ch]; do
cp -vf $DIR/$_F $_F
done

rm -rf $DIR

- name: "Create Pull Request"
uses: peter-evans/create-pull-request@v3
with:
commit-message: "Add SQLite $VERSION sources"
title: "Add SQLite $VERSION sources"
branch: sqlite-$VERSION