Update Better-SQLite3 Binaries #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - 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="" | |
| # Node ABIs to rename for code-server (Node 20 = 115, Node 22 = 127) | |
| CODESERVER_ABIS="115 127" | |
| 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" | |
| # Check if this is a node prebuild we need for code-server | |
| elif [[ "$filename" == *"-node-"* ]]; then | |
| for abi in $CODESERVER_ABIS; do | |
| if [[ "$filename" == *"-node-v${abi}-"* ]]; then | |
| # Rename node -> electron for code-server | |
| electron_filename="${filename/node-v${abi}/electron-v${abi}}" | |
| 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" | |
| break | |
| fi | |
| done | |
| 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: Create Pull Request | |
| if: steps.download.outputs.has_updates == 'true' | |
| uses: peter-evans/create-pull-request@v8 | |
| 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 |