Skip to content

Update Better-SQLite3 Binaries #160

Update Better-SQLite3 Binaries

Update Better-SQLite3 Binaries #160

name: Update Better-SQLite3 Binaries
on:
schedule:
# Run daily at 7 AM UTC
- cron: '0 7 * * *'
workflow_dispatch:
inputs:
force_update:
description: 'Force update even if binaries exist'
required: false
default: 'false'
type: boolean
version:
description: 'Specific version to fetch (e.g., v12.4.1). Leave empty for latest.'
required: false
default: ''
type: string
jobs:
update-binaries:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
actions: write
env:
DBCODE_SUPPORTED_NODE_MAJORS: "20"
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Get latest release info
id: release
run: |
if [ -n "${{ inputs.version }}" ]; then
VERSION="${{ inputs.version }}"
else
VERSION=$(curl -s https://api.github.com/repos/m4heshd/better-sqlite3-multiple-ciphers/releases/latest | jq -r '.tag_name')
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Fetching better-sqlite3-multiple-ciphers $VERSION"
- name: Download and process prebuilds
id: download
run: |
VERSION="${{ steps.release.outputs.version }}"
PACKAGES_DIR="packages/better-sqlite3"
TEMP_DIR="/tmp/prebuilds"
mkdir -p "$TEMP_DIR"
mkdir -p "$PACKAGES_DIR"
# Get all prebuild assets from the release
ASSETS=$(curl -s "https://api.github.com/repos/m4heshd/better-sqlite3-multiple-ciphers/releases/tags/$VERSION" | jq -r '.assets[] | select(.name | endswith(".tar.gz")) | .browser_download_url')
if [ -z "$ASSETS" ]; then
echo "No prebuilds found for $VERSION"
echo "has_updates=false" >> $GITHUB_OUTPUT
exit 0
fi
NEW_ELECTRON=""
NEW_CODESERVER=""
for url in $ASSETS; do
filename=$(basename "$url")
# Check if this is an electron prebuild (keep it)
if [[ "$filename" == *"-electron-"* ]]; then
target_file="$PACKAGES_DIR/$filename"
if [ -f "$target_file" ] && [ "${{ inputs.force_update }}" != "true" ]; then
echo "Already have $filename, skipping"
continue
fi
echo "Downloading $filename..."
curl -sL "$url" -o "$target_file"
NEW_ELECTRON="$NEW_ELECTRON
- $filename"
# Mirror every node prebuild as electron-* so any VS Code server Node
# version (WSL, SSH, dev containers, Codespaces, code-server) is covered.
elif [[ "$filename" == *"-node-v"* ]]; then
electron_filename="${filename/-node-v/-electron-v}"
target_file="$PACKAGES_DIR/$electron_filename"
if [ -f "$target_file" ] && [ "${{ inputs.force_update }}" != "true" ]; then
echo "Already have $electron_filename, skipping"
continue
fi
echo "Downloading $filename -> $electron_filename (for code-server)"
curl -sL "$url" -o "$target_file"
NEW_CODESERVER="$NEW_CODESERVER
- $electron_filename"
fi
done
# Write outputs
if [ -n "$NEW_ELECTRON" ] || [ -n "$NEW_CODESERVER" ]; then
echo "has_updates=true" >> $GITHUB_OUTPUT
else
echo "has_updates=false" >> $GITHUB_OUTPUT
fi
# Use heredoc for multiline output
{
echo "new_electron<<EOF"
echo "$NEW_ELECTRON"
echo "EOF"
} >> $GITHUB_OUTPUT
{
echo "new_codeserver<<EOF"
echo "$NEW_CODESERVER"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Self-build dropped Node ABIs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.release.outputs.version }}"
PACKAGES_DIR="packages/better-sqlite3"
declare -A ABI=( [20]=115 )
PLATFORMS=( "linux-x64" "linux-arm64" "linuxmusl-x64" "linuxmusl-arm64" "darwin-x64" "darwin-arm64" "win32-x64" )
for major in $DBCODE_SUPPORTED_NODE_MAJORS; do
abi="${ABI[$major]:-}"
if [ -z "$abi" ]; then echo "no ABI mapping for Node $major, skipping"; continue; fi
missing=0
for pa in "${PLATFORMS[@]}"; do
f="$PACKAGES_DIR/better-sqlite3-multiple-ciphers-$VERSION-electron-v$abi-$pa.tar.gz"
if [ ! -f "$f" ]; then missing=1; echo "missing $(basename "$f")"; fi
done
if [ "$missing" -eq 1 ]; then
echo "Dispatching self-build for $VERSION node $major"
gh workflow run build-better-sqlite3-node.yml -f version="${VERSION#v}" -f node="$major" || echo "dispatch failed (workflow may not be on default branch yet)"
fi
done
- name: Create Pull Request
if: steps.download.outputs.has_updates == 'true'
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update better-sqlite3-multiple-ciphers to ${{ steps.release.outputs.version }}"
title: "Update better-sqlite3-multiple-ciphers to ${{ steps.release.outputs.version }}"
body: |
This PR updates better-sqlite3-multiple-ciphers prebuilds.
**Version:** ${{ steps.release.outputs.version }}
**Electron prebuilds from upstream:**
${{ steps.download.outputs.new_electron }}
**Node prebuilds renamed for code-server:**
${{ steps.download.outputs.new_codeserver }}
These prebuilds are from [m4heshd/better-sqlite3-multiple-ciphers](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases).
---
*This PR was automatically generated by the update-better-sqlite3 workflow.*
branch: update-better-sqlite3
delete-branch: true
- name: Summary
run: |
echo "## Better-SQLite3 Update Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.release.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.download.outputs.has_updates }}" == "true" ]; then
echo "**Electron prebuilds:**" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.download.outputs.new_electron }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Code-server prebuilds:**" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.download.outputs.new_codeserver }}" >> $GITHUB_STEP_SUMMARY
else
echo "No new binaries were needed." >> $GITHUB_STEP_SUMMARY
fi