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