Skip to content

Merge branch 'wip-pg-extension' into wip-pg-extension-schema_v2 #624

Merge branch 'wip-pg-extension' into wip-pg-extension-schema_v2

Merge branch 'wip-pg-extension' into wip-pg-extension-schema_v2 #624

Workflow file for this run

## DELETE before merge to main branch
name: build node and expo package for sqlite-sync (pg-extension)
on:
push:
branches:
- wip-pg-extension
permissions:
contents: write
pages: write
id-token: write
jobs:
build:
runs-on: ${{ matrix.os }}
container: ${{ matrix.container && matrix.container || '' }}
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
arch: x86_64
name: linux
- os: ubuntu-22.04-arm
arch: arm64
name: linux
- os: ubuntu-22.04
arch: x86_64
name: linux-musl
container: alpine:latest
- os: ubuntu-22.04-arm
arch: arm64
name: linux-musl
- os: macos-15
arch: x86_64
name: macos
make: ARCH=x86_64
- os: macos-15
arch: arm64
name: macos
make: ARCH=arm64
- os: windows-2022
arch: x86_64
name: windows
- os: ubuntu-22.04
arch: arm64-v8a
name: android
make: PLATFORM=android ARCH=arm64-v8a
- os: ubuntu-22.04
arch: armeabi-v7a
name: android
make: PLATFORM=android ARCH=armeabi-v7a
- os: ubuntu-22.04
arch: x86_64
name: android
make: PLATFORM=android ARCH=x86_64
- os: macos-15
name: apple-xcframework
make: xcframework
defaults:
run:
shell: ${{ matrix.container && 'sh' || 'bash' }}
steps:
- uses: actions/checkout@v4.2.2
- uses: msys2/setup-msys2@v2.27.0
if: matrix.name == 'windows'
with:
msystem: mingw64
install: mingw-w64-x86_64-cc make
- name: windows install dependencies
if: matrix.name == 'windows'
run: choco install sqlite -y
- name: macos install dependencies
if: matrix.name == 'macos'
run: brew link sqlite --force && brew install lcov
- name: linux-musl x86_64 install dependencies
if: matrix.name == 'linux-musl' && matrix.arch == 'x86_64'
run: apk update && apk add --no-cache gcc make curl sqlite openssl-dev musl-dev linux-headers
- name: linux-musl arm64 setup container
if: matrix.name == 'linux-musl' && matrix.arch == 'arm64'
run: |
docker run -d --name alpine \
--platform linux/arm64 \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
alpine:latest \
tail -f /dev/null
docker exec alpine sh -c "apk update && apk add --no-cache gcc make curl sqlite openssl-dev musl-dev linux-headers"
- name: windows build curl
if: matrix.name == 'windows'
run: make curl/windows/libcurl.a
shell: msys2 {0}
- name: build sqlite-sync
run: ${{ matrix.name == 'linux-musl' && matrix.arch == 'arm64' && 'docker exec alpine' || '' }} make extension ${{ matrix.make && matrix.make || ''}}
- name: create keychain for codesign
if: matrix.os == 'macos-15'
run: |
echo "${{ secrets.APPLE_CERTIFICATE }}" | base64 --decode > certificate.p12
security create-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" build.keychain
security import certificate.p12 -k build.keychain -P "${{ secrets.CERTIFICATE_PASSWORD }}" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${{ secrets.KEYCHAIN_PASSWORD }}" build.keychain
- name: codesign and notarize dylib
if: matrix.os == 'macos-15' && matrix.name != 'apple-xcframework'
run: |
codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime dist/cloudsync.dylib
ditto -c -k dist/cloudsync.dylib dist/cloudsync.zip
xcrun notarytool submit dist/cloudsync.zip --apple-id "${{ secrets.APPLE_ID }}" --password "${{ secrets.APPLE_PASSWORD }}" --team-id "${{ secrets.APPLE_TEAM_ID }}" --wait
rm dist/cloudsync.zip
- name: codesign and notarize xcframework
if: matrix.name == 'apple-xcframework'
run: |
find dist/CloudSync.xcframework -name "*.framework" -exec echo "Signing: {}" \; -exec codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime {} \; # Sign each individual framework FIRST
codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime dist/CloudSync.xcframework # Then sign the xcframework wrapper
ditto -c -k --keepParent dist/CloudSync.xcframework dist/CloudSync.xcframework.zip
xcrun notarytool submit dist/CloudSync.xcframework.zip --apple-id "${{ secrets.APPLE_ID }}" --password "${{ secrets.APPLE_PASSWORD }}" --team-id "${{ secrets.APPLE_TEAM_ID }}" --wait
rm dist/CloudSync.xcframework.zip
- name: cleanup keychain for codesign
if: matrix.os == 'macos-15'
run: |
rm certificate.p12
security delete-keychain build.keychain
- uses: actions/upload-artifact@v4.6.2
if: always()
with:
name: cloudsync-${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
path: dist/${{ matrix.name == 'apple-xcframework' && 'CloudSync.*' || 'cloudsync.*'}}
if-no-files-found: error
release:
runs-on: ubuntu-22.04
name: release
needs: build
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/download-artifact@v4.2.1
with:
path: artifacts
- name: release tag version from cloudsync.h
id: tag
run: echo "version=$(make version)" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v4
if: steps.tag.outputs.version != ''
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: update npm
if: steps.tag.outputs.version != ''
run: npm install -g npm@11.5.1
- name: build and publish npm packages
if: steps.tag.outputs.version != ''
run: |
cd packages/node
# Update version in package.json
echo "Updating versions to ${{ steps.tag.outputs.version }}..."
# Update package.json
jq --arg version "${{ steps.tag.outputs.version }}" --arg versionpg "pg" \
'.version = $version | .optionalDependencies = (.optionalDependencies | with_entries(.value = $versionpg))' \
package.json > package.tmp.json && mv package.tmp.json package.json
echo "✓ Updated package.json to version ${{ steps.tag.outputs.version }}"
# Generate platform packages
echo "Generating platform packages..."
node generate-platform-packages.js "${{ steps.tag.outputs.version }}" "../../artifacts" "./platform-packages"
echo "✓ Generated 7 platform packages"
ls -la platform-packages/
# Build main package
echo "Building main package..."
npm install
npm run build
npm test
echo "✓ Main package built and tested"
# Publish platform packages
echo "Publishing platform packages to npm..."
cd platform-packages
for platform_dir in */; do
platform_name=$(basename "$platform_dir")
echo " Publishing @sqliteai/sqlite-sync-${platform_name}..."
cd "$platform_dir"
npm publish --provenance --access public --tag pg
cd ..
echo " ✓ Published @sqliteai/sqlite-sync-${platform_name}"
done
cd ..
# Publish main package
echo "Publishing main package to npm..."
npm publish --provenance --access public --tag pg
echo "✓ Published @sqliteai/sqlite-sync@${{ steps.tag.outputs.version }}"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ Successfully published 8 packages to npm"
echo " Main: @sqliteai/sqlite-sync@${{ steps.tag.outputs.version }}"
echo " Platform packages: 7"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
- name: build and publish expo package
if: steps.tag.outputs.version != ''
run: |
cd packages/expo
echo "Generating @sqliteai/sqlite-sync-expo package..."
node generate-expo-package.js "${{ steps.tag.outputs.version }}" "../../artifacts" "./expo-package"
echo "Publishing @sqliteai/sqlite-sync-expo to npm..."
cd expo-package
npm publish --provenance --access public --tag pg
echo "✓ Published @sqliteai/sqlite-sync-expo@${{ steps.tag.outputs.version }}"