Skip to content

Commit 63fd898

Browse files
committed
release wip-pg-extension branch node and expo packages to npmjs with the "pg" tag
1 parent ff4966b commit 63fd898

File tree

1 file changed

+241
-0
lines changed

1 file changed

+241
-0
lines changed

.github/workflows/pg-extension.yml

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
name: build node and expo package for sqlite-sync (pg-extension)
2+
on:
3+
push:
4+
branches:
5+
- wip-pg-extension
6+
7+
permissions:
8+
contents: write
9+
pages: write
10+
id-token: write
11+
12+
jobs:
13+
build:
14+
runs-on: ${{ matrix.os }}
15+
container: ${{ matrix.container && matrix.container || '' }}
16+
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build
17+
timeout-minutes: 20
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- os: ubuntu-22.04
23+
arch: x86_64
24+
name: linux
25+
- os: ubuntu-22.04-arm
26+
arch: arm64
27+
name: linux
28+
- os: ubuntu-22.04
29+
arch: x86_64
30+
name: linux-musl
31+
container: alpine:latest
32+
- os: ubuntu-22.04-arm
33+
arch: arm64
34+
name: linux-musl
35+
- os: macos-15
36+
arch: x86_64
37+
name: macos
38+
make: ARCH=x86_64
39+
- os: macos-15
40+
arch: arm64
41+
name: macos
42+
make: ARCH=arm64
43+
- os: windows-2022
44+
arch: x86_64
45+
name: windows
46+
- os: ubuntu-22.04
47+
arch: arm64-v8a
48+
name: android
49+
make: PLATFORM=android ARCH=arm64-v8a
50+
- os: ubuntu-22.04
51+
arch: armeabi-v7a
52+
name: android
53+
make: PLATFORM=android ARCH=armeabi-v7a
54+
- os: ubuntu-22.04
55+
arch: x86_64
56+
name: android
57+
make: PLATFORM=android ARCH=x86_64
58+
- os: macos-15
59+
name: apple-xcframework
60+
make: xcframework
61+
62+
defaults:
63+
run:
64+
shell: ${{ matrix.container && 'sh' || 'bash' }}
65+
66+
steps:
67+
68+
- uses: actions/checkout@v4.2.2
69+
70+
- uses: msys2/setup-msys2@v2.27.0
71+
if: matrix.name == 'windows'
72+
with:
73+
msystem: mingw64
74+
install: mingw-w64-x86_64-cc make
75+
76+
- name: windows install dependencies
77+
if: matrix.name == 'windows'
78+
run: choco install sqlite -y
79+
80+
- name: macos install dependencies
81+
if: matrix.name == 'macos'
82+
run: brew link sqlite --force && brew install lcov
83+
84+
- name: linux-musl x86_64 install dependencies
85+
if: matrix.name == 'linux-musl' && matrix.arch == 'x86_64'
86+
run: apk update && apk add --no-cache gcc make curl sqlite openssl-dev musl-dev linux-headers
87+
88+
- name: linux-musl arm64 setup container
89+
if: matrix.name == 'linux-musl' && matrix.arch == 'arm64'
90+
run: |
91+
docker run -d --name alpine \
92+
--platform linux/arm64 \
93+
-v ${{ github.workspace }}:/workspace \
94+
-w /workspace \
95+
alpine:latest \
96+
tail -f /dev/null
97+
docker exec alpine sh -c "apk update && apk add --no-cache gcc make curl sqlite openssl-dev musl-dev linux-headers"
98+
99+
- name: windows build curl
100+
if: matrix.name == 'windows'
101+
run: make curl/windows/libcurl.a
102+
shell: msys2 {0}
103+
104+
- name: build sqlite-sync
105+
run: ${{ matrix.name == 'linux-musl' && matrix.arch == 'arm64' && 'docker exec alpine' || '' }} make extension ${{ matrix.make && matrix.make || ''}}
106+
107+
- name: create keychain for codesign
108+
if: matrix.os == 'macos-15'
109+
run: |
110+
echo "${{ secrets.APPLE_CERTIFICATE }}" | base64 --decode > certificate.p12
111+
security create-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" build.keychain
112+
security default-keychain -s build.keychain
113+
security unlock-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" build.keychain
114+
security import certificate.p12 -k build.keychain -P "${{ secrets.CERTIFICATE_PASSWORD }}" -T /usr/bin/codesign
115+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${{ secrets.KEYCHAIN_PASSWORD }}" build.keychain
116+
117+
- name: codesign and notarize dylib
118+
if: matrix.os == 'macos-15' && matrix.name != 'apple-xcframework'
119+
run: |
120+
codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime dist/cloudsync.dylib
121+
ditto -c -k dist/cloudsync.dylib dist/cloudsync.zip
122+
xcrun notarytool submit dist/cloudsync.zip --apple-id "${{ secrets.APPLE_ID }}" --password "${{ secrets.APPLE_PASSWORD }}" --team-id "${{ secrets.APPLE_TEAM_ID }}" --wait
123+
rm dist/cloudsync.zip
124+
125+
- name: codesign and notarize xcframework
126+
if: matrix.name == 'apple-xcframework'
127+
run: |
128+
find dist/CloudSync.xcframework -name "*.framework" -exec echo "Signing: {}" \; -exec codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime {} \; # Sign each individual framework FIRST
129+
codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime dist/CloudSync.xcframework # Then sign the xcframework wrapper
130+
ditto -c -k --keepParent dist/CloudSync.xcframework dist/CloudSync.xcframework.zip
131+
xcrun notarytool submit dist/CloudSync.xcframework.zip --apple-id "${{ secrets.APPLE_ID }}" --password "${{ secrets.APPLE_PASSWORD }}" --team-id "${{ secrets.APPLE_TEAM_ID }}" --wait
132+
rm dist/CloudSync.xcframework.zip
133+
134+
- name: cleanup keychain for codesign
135+
if: matrix.os == 'macos-15'
136+
run: |
137+
rm certificate.p12
138+
security delete-keychain build.keychain
139+
140+
- uses: actions/upload-artifact@v4.6.2
141+
if: always()
142+
with:
143+
name: cloudsync-${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
144+
path: dist/${{ matrix.name == 'apple-xcframework' && 'CloudSync.*' || 'cloudsync.*'}}
145+
if-no-files-found: error
146+
147+
release:
148+
runs-on: ubuntu-22.04
149+
name: release
150+
needs: build
151+
152+
env:
153+
GH_TOKEN: ${{ github.token }}
154+
155+
steps:
156+
157+
- uses: actions/checkout@v4.2.2
158+
159+
- uses: actions/download-artifact@v4.2.1
160+
with:
161+
path: artifacts
162+
163+
- name: release tag version from cloudsync.h
164+
id: tag
165+
run: echo "version=$(make version)" >> $GITHUB_OUTPUT
166+
167+
- uses: actions/setup-node@v4
168+
if: steps.tag.outputs.version != ''
169+
with:
170+
node-version: '20'
171+
registry-url: 'https://registry.npmjs.org'
172+
173+
- name: update npm
174+
if: steps.tag.outputs.version != ''
175+
run: npm install -g npm@11.5.1
176+
177+
- name: build and publish npm packages
178+
if: steps.tag.outputs.version != ''
179+
run: |
180+
cd packages/node
181+
182+
# Update version in package.json
183+
echo "Updating versions to ${{ steps.tag.outputs.version }}..."
184+
185+
# Update package.json
186+
jq --arg version "${{ steps.tag.outputs.version }}" \
187+
'.version = $version | .optionalDependencies = (.optionalDependencies | with_entries(.value = $version))' \
188+
package.json > package.tmp.json && mv package.tmp.json package.json
189+
190+
echo "✓ Updated package.json to version ${{ steps.tag.outputs.version }}"
191+
192+
# Generate platform packages
193+
echo "Generating platform packages..."
194+
node generate-platform-packages.js "${{ steps.tag.outputs.version }}" "../../artifacts" "./platform-packages"
195+
echo "✓ Generated 7 platform packages"
196+
ls -la platform-packages/
197+
198+
# Build main package
199+
echo "Building main package..."
200+
npm install
201+
npm run build
202+
npm test
203+
echo "✓ Main package built and tested"
204+
205+
# Publish platform packages
206+
echo "Publishing platform packages to npm..."
207+
cd platform-packages
208+
for platform_dir in */; do
209+
platform_name=$(basename "$platform_dir")
210+
echo " Publishing @sqliteai/sqlite-sync-${platform_name}..."
211+
cd "$platform_dir"
212+
npm publish --provenance --access public --tag pg
213+
cd ..
214+
echo " ✓ Published @sqliteai/sqlite-sync-${platform_name}"
215+
done
216+
cd ..
217+
218+
# Publish main package
219+
echo "Publishing main package to npm..."
220+
npm publish --provenance --access public --tag pg
221+
echo "✓ Published @sqliteai/sqlite-sync@${{ steps.tag.outputs.version }}"
222+
223+
echo ""
224+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
225+
echo "✅ Successfully published 8 packages to npm"
226+
echo " Main: @sqliteai/sqlite-sync@${{ steps.tag.outputs.version }}"
227+
echo " Platform packages: 7"
228+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
229+
230+
- name: build and publish expo package
231+
if: steps.tag.outputs.version != ''
232+
run: |
233+
cd packages/expo
234+
235+
echo "Generating @sqliteai/sqlite-sync-expo package..."
236+
node generate-expo-package.js "${{ steps.tag.outputs.version }}" "../../artifacts" "./expo-package"
237+
238+
echo "Publishing @sqliteai/sqlite-sync-expo to npm..."
239+
cd expo-package
240+
npm publish --provenance --access public --tag pg
241+
echo "✓ Published @sqliteai/sqlite-sync-expo@${{ steps.tag.outputs.version }}"

0 commit comments

Comments
 (0)