forked from CherryHQ/cherry-studio-app
-
Notifications
You must be signed in to change notification settings - Fork 0
217 lines (188 loc) Β· 9.05 KB
/
android-release.yml
File metadata and controls
217 lines (188 loc) Β· 9.05 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
name: Android Release
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g. v1.0.0)'
required: true
default: 'v1.0.0'
push:
tags:
- 'v*.*.*'
jobs:
build-android:
name: Build Android and Create Release
runs-on: ubuntu-latest
steps:
# Step 1: Checkout code
- name: Checkout repository
uses: actions/checkout@v5
# Step 2: Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
# Step 3: Enable Corepack for Yarn 4
- name: Enable Corepack
run: |
corepack enable
corepack prepare yarn@4.10.3 --activate
# Step 4: Setup Expo and EAS
- name: Setup Expo and EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
packager: npm
# Step 5: Install dependencies
- name: Install dependencies
run: yarn install --immutable
# Step 6: Get version tag
- name: Get version tag
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
# Step 7: Update package.json version (DISABLED - using manual version from package.json)
# - name: Update package.json version
# run: |
# VERSION="${{ steps.version.outputs.tag }}"
# # Remove 'v' prefix if present (e.g., v1.0.0 -> 1.0.0)
# VERSION_NUMBER="${VERSION#v}"
# echo "Updating package.json version to $VERSION_NUMBER"
#
# # Update package.json using Node.js
# node -e "
# const fs = require('fs');
# const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
# pkg.version = '$VERSION_NUMBER';
# fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
# "
#
# echo "β
package.json updated to version $VERSION_NUMBER"
# cat package.json | grep '"version"'
# Step 8: Set APP_VERSION environment variable (DISABLED - using manual version from package.json)
# - name: Export APP_VERSION for EAS Build
# run: |
# VERSION="${{ steps.version.outputs.tag }}"
# VERSION_NUMBER="${VERSION#v}"
# echo "APP_VERSION=$VERSION_NUMBER" >> $GITHUB_ENV
# echo "β
APP_VERSION set to $VERSION_NUMBER"
# Step 9: Build Android on EAS
- name: Build Android on EAS
id: build_android
run: |
echo "Building Android APK on EAS (version from package.json)..."
eas build --platform android --profile production --non-interactive --no-wait --json > android_build.json
BUILD_ID=$(cat android_build.json | jq -r '.[0].id')
echo "build_id=$BUILD_ID" >> $GITHUB_OUTPUT
echo "π€ Android Build ID: $BUILD_ID"
echo "π View Android build: https://expo.dev/accounts/[your-account]/projects/cherry-studio/builds/$BUILD_ID"
# Step 10: Wait for Android build to complete
- name: Wait for Android build
run: |
echo "Waiting for Android build to complete..."
BUILD_ID="${{ steps.build_android.outputs.build_id }}"
# Poll build status until complete
while true; do
# Get build status and convert to lowercase for comparison
STATUS=$(eas build:view $BUILD_ID --json | jq -r '.status')
STATUS_LOWER=$(echo "$STATUS" | tr '[:upper:]' '[:lower:]')
echo "Current status: $STATUS"
if [ "$STATUS_LOWER" == "finished" ]; then
echo "β
Build completed successfully!"
break
elif [ "$STATUS_LOWER" == "errored" ] || [ "$STATUS_LOWER" == "canceled" ]; then
echo "β Build failed with status: $STATUS"
echo "View build details at: https://expo.dev/accounts/[your-account]/projects/cherry-studio/builds/$BUILD_ID"
exit 1
elif [ -z "$STATUS" ]; then
echo "β οΈ Failed to get build status, retrying..."
sleep 10
continue
fi
echo "β³ Build still in progress, waiting 60 seconds..."
sleep 60
done
# Step 11: Download Android APK
- name: Download Android APK
run: |
BUILD_ID="${{ steps.build_android.outputs.build_id }}"
echo "Downloading APK from build: $BUILD_ID"
# Get artifact URL
ARTIFACT_URL=$(eas build:view $BUILD_ID --json | jq -r '.artifacts.buildUrl')
echo "Artifact URL: $ARTIFACT_URL"
# Download APK
curl -L -o Cherry-Studio-${{ steps.version.outputs.tag }}.apk "$ARTIFACT_URL"
# Verify file exists and size
echo "β
APK downloaded successfully!"
ls -lh Cherry-Studio-${{ steps.version.outputs.tag }}.apk
# Step 12: Create GitHub Release
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Cherry Studio ${{ steps.version.outputs.tag }}
body: |
## Cherry Studio ${{ steps.version.outputs.tag }} - Android
### π€ Android
- Built with EAS Build (production profile)
- APK available for download below
- **Build ID**: `${{ steps.build_android.outputs.build_id }}`
- [View Build Details on Expo](https://expo.dev/accounts/[your-account]/projects/cherry-studio/builds/${{ steps.build_android.outputs.build_id }})
---
π **Note**: This is a draft release. Review the build and publish when ready.
π€ Automatically generated by GitHub Actions
files: |
Cherry-Studio-${{ steps.version.outputs.tag }}.apk
draft: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Step 13: Build Summary
- name: Build Summary
if: success()
run: |
echo "## Build Complete! π" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### π€ Android" >> $GITHUB_STEP_SUMMARY
echo "- **Build ID**: \`${{ steps.build_android.outputs.build_id }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Status**: β
APK uploaded to GitHub Release" >> $GITHUB_STEP_SUMMARY
echo "- **Build Details**: [View on Expo](https://expo.dev/accounts/[your-account]/projects/cherry-studio/builds/${{ steps.build_android.outputs.build_id }})" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### π¦ Release" >> $GITHUB_STEP_SUMMARY
echo "- **Tag**: \`${{ steps.version.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Status**: π Draft (not published yet)" >> $GITHUB_STEP_SUMMARY
echo "- **GitHub Release**: ${{ steps.create_release.outputs.url }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### β
Next Steps" >> $GITHUB_STEP_SUMMARY
echo "1. Review the draft release on GitHub" >> $GITHUB_STEP_SUMMARY
echo "2. Test the APK if needed" >> $GITHUB_STEP_SUMMARY
echo "3. Edit the release notes if necessary" >> $GITHUB_STEP_SUMMARY
echo "4. Click **Publish release** when ready" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
echo "_Note: Replace [your-account] with your Expo account name in the links above_" >> $GITHUB_STEP_SUMMARY
# Step 14: Build Failure Summary
- name: Build Failure Summary
if: failure()
run: |
echo "## Build Failed β" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The Android build process encountered an error. Please check the logs above for details." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -n "${{ steps.build_android.outputs.build_id }}" ]; then
echo "### π€ Android Build" >> $GITHUB_STEP_SUMMARY
echo "- **Build ID**: \`${{ steps.build_android.outputs.build_id }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **View Details**: [Expo Dashboard](https://expo.dev/accounts/[your-account]/projects/cherry-studio/builds/${{ steps.build_android.outputs.build_id }})" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
echo "### π Troubleshooting" >> $GITHUB_STEP_SUMMARY
echo "- Check the [EAS Build documentation](https://docs.expo.dev/build/introduction/)" >> $GITHUB_STEP_SUMMARY
echo "- Review the build logs on Expo dashboard for detailed error messages" >> $GITHUB_STEP_SUMMARY
echo "- Ensure all credentials and secrets are properly configured" >> $GITHUB_STEP_SUMMARY
echo "- Verify that all dependencies are correctly installed" >> $GITHUB_STEP_SUMMARY