-
Notifications
You must be signed in to change notification settings - Fork 14
242 lines (205 loc) · 9.15 KB
/
main.yml
File metadata and controls
242 lines (205 loc) · 9.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
## 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 }}"