Update DB2 Binaries #76
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 DB2 Binaries | |
| on: | |
| schedule: | |
| # Run daily at 6 AM UTC | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| force_update: | |
| description: 'Force update even if binaries exist' | |
| required: false | |
| default: 'false' | |
| type: boolean | |
| jobs: | |
| update-binaries: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Get VS Code Electron version | |
| id: vscode_electron | |
| run: | | |
| # Fetch VS Code's package.json to get the Electron version | |
| ELECTRON_VERSION=$(curl -s https://raw.githubusercontent.com/microsoft/vscode/main/package.json | jq -r '.devDependencies.electron' | cut -d. -f1) | |
| echo "version=$ELECTRON_VERSION" >> $GITHUB_OUTPUT | |
| echo "VS Code is using Electron $ELECTRON_VERSION" | |
| - name: Download IBM DB2 binaries | |
| run: | | |
| echo "Downloading IBM DB2 node-ibm_db master.zip..." | |
| curl -sL https://github.com/ibmdb/node-ibm_db/archive/refs/heads/master.zip -o /tmp/ibm_db_master.zip | |
| echo "Extracting build.zip..." | |
| unzip -q /tmp/ibm_db_master.zip "node-ibm_db-master/build.zip" -d /tmp | |
| unzip -q /tmp/node-ibm_db-master/build.zip -d /tmp/build_extracted | |
| echo "Available binaries in upstream:" | |
| ls -la /tmp/build_extracted/build/Release/ | grep odbc_bindings | |
| - name: Check and package new binaries | |
| id: package | |
| run: | | |
| PACKAGES_DIR="packages/node-ibm_db" | |
| BUILD_DIR="/tmp/build_extracted/build/Release" | |
| NEW_BINARIES="" | |
| # Platform mappings (upstream name -> our name) | |
| declare -A PLATFORMS=( | |
| ["linux"]="linux" | |
| ["mac"]="mac" | |
| ["macarm"]="macarm" | |
| ["win"]="win" | |
| ) | |
| for platform in "${!PLATFORMS[@]}"; do | |
| our_name="${PLATFORMS[$platform]}" | |
| # Find all electron version binaries for this platform | |
| for binary in "$BUILD_DIR"/odbc_bindings_${platform}_*.node; do | |
| if [ ! -f "$binary" ]; then | |
| continue | |
| fi | |
| # Extract version number from filename | |
| filename=$(basename "$binary") | |
| version=$(echo "$filename" | sed -E 's/odbc_bindings_[^_]+_([0-9]+)\.node/\1/') | |
| target_file="$PACKAGES_DIR/odbc_bindings_${our_name}_${version}.node.tar.gz" | |
| # Check if we already have this version | |
| if [ -f "$target_file" ] && [ "${{ inputs.force_update }}" != "true" ]; then | |
| echo "Already have $target_file, skipping" | |
| continue | |
| fi | |
| echo "Packaging $filename as odbc_bindings_${our_name}_${version}.node.tar.gz" | |
| # Create temp dir for packaging | |
| TEMP_DIR=$(mktemp -d) | |
| cp "$binary" "$TEMP_DIR/odbc_bindings.node" | |
| # Create tar.gz with just the renamed file | |
| tar -czf "$target_file" -C "$TEMP_DIR" odbc_bindings.node | |
| rm -rf "$TEMP_DIR" | |
| NEW_BINARIES="$NEW_BINARIES odbc_bindings_${our_name}_${version}.node.tar.gz" | |
| done | |
| done | |
| if [ -z "$NEW_BINARIES" ]; then | |
| echo "No new binaries to add" | |
| echo "has_updates=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "New binaries added:$NEW_BINARIES" | |
| echo "has_updates=true" >> $GITHUB_OUTPUT | |
| echo "new_binaries=$NEW_BINARIES" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| if: steps.package.outputs.has_updates == 'true' | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "Add new DB2 ODBC binaries" | |
| title: "Update DB2 ODBC binaries" | |
| body: | | |
| This PR adds new DB2 ODBC binaries for Electron versions that were missing. | |
| **New binaries added:** | |
| ${{ steps.package.outputs.new_binaries }} | |
| **VS Code Electron version:** ${{ steps.vscode_electron.outputs.version }} | |
| These binaries are extracted from [ibmdb/node-ibm_db](https://github.com/ibmdb/node-ibm_db) build.zip. | |
| --- | |
| *This PR was automatically generated by the update-db2-binaries workflow.* | |
| branch: update-db2-binaries | |
| delete-branch: true | |
| - name: Summary | |
| run: | | |
| echo "## DB2 Binaries Update Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**VS Code Electron Version:** ${{ steps.vscode_electron.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ steps.package.outputs.has_updates }}" == "true" ]; then | |
| echo "**New binaries added:**" >> $GITHUB_STEP_SUMMARY | |
| echo "${{ steps.package.outputs.new_binaries }}" | tr ' ' '\n' | sed 's/^/- /' >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "No new binaries were needed." >> $GITHUB_STEP_SUMMARY | |
| fi |