-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Update SDK sizes | ||
|
||
on: | ||
pull_request: | ||
|
||
workflow_dispatch: | ||
|
||
env: | ||
MODULES: "stream-chat-android-client stream-chat-android-offline stream-chat-android-ui-components stream-chat-android-compose" | ||
VARIANTS: "debug release" | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
|
||
jobs: | ||
update-sdk-sizes: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- uses: ./.github/actions/setup-java | ||
- uses: ./.github/actions/gradle-cache | ||
with: | ||
key-prefix: gradle-build | ||
|
||
- name: Assemble SDKs | ||
run: | | ||
for module in $MODULES; do | ||
modules+=" :$module:assemble" | ||
done | ||
./gradlew $modules | ||
- name: Update SDK sizes | ||
run: | | ||
echo '{}' > stream-chat-android.json | ||
# Calculate sizes | ||
for module in $MODULES; do | ||
for variant in $VARIANTS; do | ||
file="$module/build/outputs/aar/$module-$variant.aar" | ||
# Ensure file exists | ||
if [ -f "$file" ]; then | ||
size=$(du -k "$file" | awk '{print $1}') | ||
else | ||
echo "Warning: $file not found. Setting size to 0." | ||
size=0 | ||
fi | ||
# Update JSON | ||
jq --arg module "$module" --arg variant "$variant" --argjson size "$size" \ | ||
'."$variant"[$module] = $size' stream-chat-android.json > temp.json && mv temp.json stream-chat-android.json | ||
done | ||
done | ||
- name: Validate Generated JSON | ||
run: jq . stream-chat-android.json | ||
|
||
- name: Commit and Push JSON | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git fetch origin | ||
git checkout $BRANCH_NAME | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
# Add and commit updated JSON file | ||
git add stream-chat-android.json | ||
if git diff-index --quiet HEAD --; then | ||
echo "No changes to commit" | ||
else | ||
git commit -m "Update SDK sizes JSON" | ||
git push origin HEAD:$BRANCH_NAME | ||
fi | ||
- name: Update size badges | ||
run: | | ||
# Update README.md | ||
for module in $MODULES; do | ||
size=$(jq --arg module "$module" '.release.[$module]' stream-chat-android.json) | ||
badgeUrl="https://img.shields.io/badge/${module//-/--}-$size%20KB-lightgreen" | ||
sed -i "s|!\[${module}\]\(.*\)|![${module}](${badgeUrl})|" README.md | ||
done | ||
- name: Commit and Push README | ||
run: | | ||
# Add and commit updated README file | ||
git add README.md | ||
if git diff-index --quiet HEAD --; then | ||
echo "No changes to commit" | ||
else | ||
git commit -m "Update SDK size badges" | ||
git push origin HEAD:$BRANCH_NAME | ||
fi |
This file contains 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