1212 build :
1313 runs-on : ${{ matrix.os }}
1414 container : ${{ matrix.container && matrix.container || '' }}
15- name : ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'apple-xcframework' && ' + test' || ''}}
15+ name : ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'apple-xcframework' && matrix.name != 'android-aar' && ' + test' || ''}}
1616 timeout-minutes : 20
1717 strategy :
1818 fail-fast : false
5555 - os : macos-15
5656 name : apple-xcframework
5757 make : xcframework
58+ - os : ubuntu-22.04
59+ name : android-aar
60+ make : aar
5861
5962 defaults :
6063 run :
6972
70737174
75+ - name : android setup java
76+ if : matrix.name == 'android-aar'
77+ uses : actions/setup-java@v4
78+ with :
79+ distribution : ' temurin'
80+ java-version : ' 17'
81+
72827383 if : matrix.name == 'windows'
7484 with :
@@ -224,12 +234,67 @@ jobs:
224234 - name : deploy coverage to GitHub Pages
225235226236
237+ - name : zip artifacts
238+ run : |
239+ VERSION=$(make version)
240+ for folder in "artifacts"/*; do
241+ if [ -d "$folder" ]; then
242+ name=$(basename "$folder")
243+ if [[ "$name" != "github-pages" ]]; then
244+ if [[ "$name" != "cloudsync-apple-xcframework" && "$name" != "cloudsync-android-aar" ]]; then
245+ tar -czf "${name}-${VERSION}.tar.gz" -C "$folder" .
246+ fi
247+ if [[ "$name" != "cloudsync-android-aar" ]]; then
248+ (cd "$folder" && zip -rq "../../${name}-${VERSION}.zip" .)
249+ else
250+ cp "$folder"/*.aar "${name}-${VERSION}.aar"
251+ fi
252+ fi
253+ fi
254+ done
255+
227256 - name : release tag version from cloudsync.h
228257 id : tag
229258 run : |
230259 VERSION=$(make version)
231260 if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
232- LATEST=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.name')
261+ LATEST_RELEASE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest)
262+ LATEST=$(echo "$LATEST_RELEASE" | jq -r '.name')
263+ # Check artifact sizes against previous release
264+ if [ -n "$LATEST" ] && [ "$LATEST" != "null" ]; then
265+ echo "Checking artifact sizes against previous release: $LATEST"
266+ FAILED=0
267+ for artifact in cloudsync-*-${VERSION}.*; do
268+ if [ ! -f "$artifact" ]; then
269+ continue
270+ fi
271+ # Get current artifact size
272+ NEW_SIZE=$(stat -c%s "$artifact" 2>/dev/null || stat -f%z "$artifact")
273+ # Get artifact name for previous release
274+ ARTIFACT_NAME=$(echo "$artifact" | sed "s/${VERSION}/${LATEST}/")
275+ # Get previous artifact size from GitHub API
276+ OLD_SIZE=$(echo "$LATEST_RELEASE" | jq -r ".assets[] | select(.name == \"$(basename "$ARTIFACT_NAME")\") | .size")
277+ if [ -z "$OLD_SIZE" ] || [ "$OLD_SIZE" = "null" ]; then
278+ echo "⚠️ Previous artifact not found: $(basename "$ARTIFACT_NAME"), skipping comparison"
279+ continue
280+ fi
281+ # Calculate percentage increase
282+ INCREASE=$(awk "BEGIN {printf \"%.2f\", (($NEW_SIZE - $OLD_SIZE) / $OLD_SIZE) * 100}")
283+ echo "📦 $artifact: $OLD_SIZE → $NEW_SIZE bytes (${INCREASE}% change)"
284+ # Check if increase is more than 5%
285+ if (( $(echo "$INCREASE > 5" | bc -l) )); then
286+ echo "❌ ERROR: $artifact size increased by ${INCREASE}% (limit: 5%)"
287+ FAILED=1
288+ fi
289+ done
290+ if [ $FAILED -eq 1 ]; then
291+ echo ""
292+ echo "❌ One or more artifacts exceeded the 5% size increase limit"
293+ exit 1
294+ fi
295+ echo "✅ All artifacts within 5% size increase limit"
296+ fi
297+
233298 if [[ "$VERSION" != "$LATEST" || "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
234299 echo "version=$VERSION" >> $GITHUB_OUTPUT
235300 else
@@ -261,29 +326,22 @@ jobs:
261326 git commit -m "Bump sqlite-sync version to ${{ steps.tag.outputs.version }}"
262327 git push origin main
263328
264- - name : zip artifacts
329+ - uses : actions/setup-java@v4
265330 if : steps.tag.outputs.version != ''
266- run : |
267- for folder in "artifacts"/*; do
268- if [ -d "$folder" ]; then
269- name=$(basename "$folder")
270- if [[ "$name" != "github-pages" ]]; then
271- if [[ "$name" != "cloudsync-apple-xcframework" ]]; then
272- tar -czf "${name}-${{ steps.tag.outputs.version }}.tar.gz" -C "$folder" .
273- fi
274- (cd "$folder" && zip -rq "../../${name}-${{ steps.tag.outputs.version }}.zip" .)
275- fi
276- fi
277- done
331+ with :
332+ distribution : ' temurin'
333+ java-version : ' 17'
334+
335+ - name : release android aar to maven central
336+ if : steps.tag.outputs.version != ''
337+ run : make aar && cd packages/android && ./gradlew publishAggregationToCentralPortal -PSIGNING_KEY="${{ secrets.SIGNING_KEY }}" -PSIGNING_PASSWORD="${{ secrets.SIGNING_PASSWORD }}" -PSONATYPE_USERNAME="${{ secrets.MAVEN_CENTRAL_USERNAME }}" -PSONATYPE_PASSWORD="${{ secrets.MAVEN_CENTRAL_TOKEN }}" -PVERSION="${{ steps.tag.outputs.version }}"
278338
279339 -
uses :
softprops/[email protected] 280340 if : steps.tag.outputs.version != ''
281341 with :
282342 generate_release_notes : true
283343 tag_name : ${{ steps.tag.outputs.version }}
284344 files : |
285- cloudsync-*-${{ steps.tag.outputs.version }}.zip
286- cloudsync-*-${{ steps.tag.outputs.version }}.tar.gz
287- CloudSync-*-${{ steps.tag.outputs.version }}.zip
288- CloudSync-*-${{ steps.tag.outputs.version }}.tar.gz
345+ cloudsync-*-${{ steps.tag.outputs.version }}.*
346+ CloudSync-*-${{ steps.tag.outputs.version }}.*
289347 make_latest : true
0 commit comments