-
-
Notifications
You must be signed in to change notification settings - Fork 4
67 lines (55 loc) · 2.59 KB
/
update-sqlcipher.yml
File metadata and controls
67 lines (55 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Update SQLCipher
on:
schedule:
- cron: '0 17 * * *'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
update-sqlcipher:
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- name: Check latest SQLCipher version
id: check
run: |
# Get the latest tag from the SQLCipher repository
SQLCIPHER_REPO="https://github.com/sqlcipher/sqlcipher"
LATEST_VERSION=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' ${SQLCIPHER_REPO} | tail -n 1 | cut -d '/' -f 3 | cut -f 1 -d '^' | cut -f 2 -d 'v')
echo "latest_version=${LATEST_VERSION}" >> "$GITHUB_OUTPUT"
# Get the current SQLCipher version from CIPHER_VERSION_NUMBER in sqlite3.c
CURRENT_SQLCIPHER_VERSION=$(grep '#define CIPHER_VERSION_NUMBER ' Sources/SQLCipher/sqlite/sqlite3.c | head -1 | awk '{print $3}')
echo "current_version=${CURRENT_SQLCIPHER_VERSION}" >> "$GITHUB_OUTPUT"
if [ "${LATEST_VERSION}" != "${CURRENT_SQLCIPHER_VERSION}" ]; then
echo "updated=true" >> "$GITHUB_OUTPUT"
echo "New SQLCipher version available: ${LATEST_VERSION} (current: ${CURRENT_SQLCIPHER_VERSION})"
else
echo "updated=false" >> "$GITHUB_OUTPUT"
echo "SQLCipher is up to date: ${CURRENT_SQLCIPHER_VERSION}"
fi
- name: Run build_sqlcipher.sh
if: steps.check.outputs.updated == 'true'
run: |
brew install libtomcrypt
scripts/build_sqlcipher.sh
- name: Create pull request
if: steps.check.outputs.updated == 'true'
run: |
VERSION="${{ steps.check.outputs.latest_version }}"
BRANCH="automated/sqlcipher-${VERSION}"
# Get the new SQLite version from the updated header
SQLITE_VERSION=$(grep '^#define SQLITE_VERSION ' Sources/SQLCipher/sqlite/sqlite3.h | head -1 | sed 's/.*"\(.*\)".*/\1/')
git config user.name "swift-ci"
git config user.email "swift-ci@users.noreply.github.com"
git checkout -b "${BRANCH}"
git add -A
git commit -m "Update to SQLCipher ${VERSION} (SQLite ${SQLITE_VERSION})"
git push origin "${BRANCH}"
gh pr create \
--title "Update to SQLCipher ${VERSION}" \
--body "Updates SQLCipher from ${{ steps.check.outputs.current_version }} to ${VERSION} (SQLite ${SQLITE_VERSION}).
Release notes: https://github.com/sqlcipher/sqlcipher/releases/tag/v${VERSION}" \
--draft
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}