Skip to content

Commit 990d321

Browse files
committed
chore: update ci
1 parent a5bb686 commit 990d321

File tree

5 files changed

+672
-116
lines changed

5 files changed

+672
-116
lines changed

.changeset/README.md

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,84 @@ Hello and welcome! This folder has been automatically generated by `@changesets/
44
with multi-package repos, or single-package repos to help you version and publish your code. You can
55
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
66

7-
We have a quick list of common questions to get you started engaging with this project in
8-
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
7+
We have a quick guide available to get you up and running with changesets [here](https://github.com/changesets/changesets/blob/main/docs/intro-to-using-changesets.md)
8+
9+
## How to use changesets
10+
11+
### Adding a changeset
12+
13+
When you're going to make changes to this package, you should run:
14+
15+
```bash
16+
pnpm changeset
17+
```
18+
19+
to add a changeset. This command will ask you a few questions, and then add a changeset file.
20+
21+
### Releasing
22+
23+
When you want to release, you should run:
24+
25+
```bash
26+
pnpm changeset version
27+
```
28+
29+
to version your packages, and then run:
30+
31+
```bash
32+
pnpm changeset publish
33+
```
34+
35+
to publish the packages.
36+
37+
### Release Process
38+
39+
This project uses automated releases through GitHub Actions. The release process works as follows:
40+
41+
1. **Create a changeset**: When you make changes, run `pnpm changeset` to document your changes
42+
2. **Automatic versioning**: When changesets are merged to main, a PR is automatically created to bump versions
43+
3. **Automatic release**: When the version PR is merged, the release workflow automatically:
44+
- Builds for all platforms (Windows, macOS, Linux, Android)
45+
- Creates a GitHub release with detailed notes
46+
- Publishes artifacts
47+
- Creates a release branch for hotfixes
48+
49+
### Manual Release
50+
51+
If you need to force a release, you can:
52+
53+
1. Go to the Actions tab in GitHub
54+
2. Run the "Main Release" workflow manually
55+
3. Choose your release type and options
56+
57+
### Hotfix Process
58+
59+
For urgent fixes:
60+
61+
1. Go to the Actions tab in GitHub
62+
2. Run the "Hotfix Release" workflow
63+
3. Specify the base version and hotfix description
64+
4. A hotfix branch will be created automatically
65+
66+
## Release Types
67+
68+
- **patch**: Bug fixes and minor improvements
69+
- **minor**: New features (backward compatible)
70+
- **major**: Breaking changes
71+
72+
## Best Practices
73+
74+
1. **Always create changesets** for any changes that affect users
75+
2. **Use clear, descriptive messages** in your changesets
76+
3. **Mark breaking changes** with `!` or `BREAKING CHANGE:`
77+
4. **Test thoroughly** before creating a changeset
78+
5. **Review changeset PRs** carefully before merging
79+
80+
## Troubleshooting
81+
82+
If you encounter issues:
83+
84+
1. Check the GitHub Actions logs for detailed error messages
85+
2. Ensure all secrets are properly configured
86+
3. Verify that the changeset format is correct
87+
4. Check that version numbers are valid semantic versions

.changeset/config.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
{
2-
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3-
"changelog": "@changesets/cli/changelog",
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{
6+
"repo": "DavidAmunga/mpesa2csv"
7+
}
8+
],
49
"commit": false,
510
"fixed": [],
611
"linked": [],
7-
"access": "restricted",
12+
"access": "public",
813
"baseBranch": "main",
914
"updateInternalDependencies": "patch",
10-
"ignore": []
15+
"ignore": [],
16+
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
17+
"onlyUpdatePeerDependentsWhenOutOfRange": true
18+
}
1119
}

.github/workflows/android-release.yml

Lines changed: 191 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ jobs:
159159
~/.cargo/git
160160
src-tauri/target
161161
key: ${{ runner.os }}-android-cargo-${{ hashFiles('**/Cargo.lock') }}
162+
restore-keys: |
163+
${{ runner.os }}-android-cargo-
164+
${{ runner.os }}-cargo-
162165
163166
- name: Cache Gradle dependencies
164167
uses: actions/cache@v4
@@ -168,12 +171,71 @@ jobs:
168171
~/.gradle/wrapper
169172
src-tauri/gen/android/.gradle
170173
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
174+
restore-keys: |
175+
${{ runner.os }}-gradle-
176+
177+
- name: Cache Node dependencies
178+
uses: actions/cache@v4
179+
with:
180+
path: |
181+
node_modules
182+
~/.pnpm-store
183+
key: ${{ runner.os }}-android-node-${{ hashFiles('**/pnpm-lock.yaml') }}
184+
restore-keys: |
185+
${{ runner.os }}-android-node-
186+
${{ runner.os }}-node-
187+
188+
- name: Cache Android build artifacts
189+
uses: actions/cache@v4
190+
with:
191+
path: |
192+
dist
193+
src-tauri/gen/android/app/build
194+
key: ${{ runner.os }}-android-build-${{ hashFiles('**/package.json', '**/Cargo.toml') }}
195+
restore-keys: |
196+
${{ runner.os }}-android-build-
171197
172198
- name: Install frontend dependencies
173199
run: pnpm install --frozen-lockfile
174200

175201
- name: Build frontend
176-
run: pnpm build
202+
run: |
203+
echo "🔨 Building frontend for Android..."
204+
pnpm build
205+
206+
# Validate build output
207+
if [[ ! -d "dist" ]] || [[ ! -f "dist/index.html" ]]; then
208+
echo "❌ Frontend build failed - dist directory or index.html missing"
209+
exit 1
210+
fi
211+
212+
BUILD_SIZE=$(du -sm dist | cut -f1)
213+
echo "✅ Frontend build completed (${BUILD_SIZE}MB)"
214+
215+
- name: Validate Android build prerequisites
216+
run: |
217+
echo "🔍 Validating Android build prerequisites..."
218+
219+
# Check Java version
220+
java -version
221+
222+
# Check Android SDK
223+
echo "ANDROID_SDK_ROOT: $ANDROID_SDK_ROOT"
224+
echo "ANDROID_NDK_HOME: $ANDROID_NDK_HOME"
225+
226+
# Validate Android project structure
227+
if [[ ! -d "src-tauri/gen/android" ]]; then
228+
echo "❌ Android project directory missing"
229+
exit 1
230+
fi
231+
232+
# Check if Android targets are installed
233+
if ! rustup target list --installed | grep -q "aarch64-linux-android"; then
234+
echo "📦 Installing Android targets..."
235+
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
236+
fi
237+
238+
echo "✅ Android build prerequisites validated"
177239
178240
- name: Install Tauri CLI
179241
run: cargo install tauri-cli --version "^2.0" --locked
@@ -202,31 +264,93 @@ jobs:
202264
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
203265

204266
- name: Build Android Release
267+
id: android_build
268+
continue-on-error: true
205269
run: |
270+
echo "🔨 Building Android release for aarch64..."
271+
206272
cd src-tauri
273+
274+
# Set build environment
275+
export ANDROID_NDK_HOME="$ANDROID_NDK_HOME"
276+
export NDK_HOME="$NDK_HOME"
277+
207278
if [[ -n "$ANDROID_KEYSTORE_BASE64" ]]; then
208-
echo "🔨 Building signed release APK and AAB..."
279+
echo "🔐 Building signed release APK and AAB..."
209280
else
210281
echo "⚠️ No signing keys provided - building unsigned release"
211282
fi
212283
284+
# Attempt build with retry logic
285+
set +e
213286
cargo tauri android build --target aarch64 --verbose
287+
BUILD_EXIT_CODE=$?
288+
set -e
289+
290+
if [[ $BUILD_EXIT_CODE -ne 0 ]]; then
291+
echo "❌ First build attempt failed (exit code: $BUILD_EXIT_CODE)"
292+
echo "🔄 Attempting clean build..."
293+
294+
# Clean and retry
295+
cargo clean
296+
cargo tauri android build --target aarch64 --verbose
297+
BUILD_EXIT_CODE=$?
298+
299+
if [[ $BUILD_EXIT_CODE -ne 0 ]]; then
300+
echo "❌ Build failed after retry (exit code: $BUILD_EXIT_CODE)"
301+
echo "build_success=false" >> $GITHUB_OUTPUT
302+
exit 1
303+
fi
304+
fi
305+
306+
echo "✅ Android build completed successfully"
307+
echo "build_success=true" >> $GITHUB_OUTPUT
308+
309+
- name: Handle Android Build Failure
310+
if: steps.android_build.outcome == 'failure'
311+
run: |
312+
echo "❌ Android build failed"
313+
echo "📊 Build diagnostics:"
314+
echo "Rust version: $(rustc --version)"
315+
echo "Cargo version: $(cargo --version)"
316+
echo "Java version: $(java -version 2>&1)"
317+
echo "Android SDK: $ANDROID_SDK_ROOT"
318+
echo "Android NDK: $ANDROID_NDK_HOME"
319+
320+
# List available targets
321+
echo "Available Rust targets:"
322+
rustup target list --installed
323+
324+
# Check Android project structure
325+
if [[ -d "src-tauri/gen/android" ]]; then
326+
echo "Android project structure:"
327+
ls -la src-tauri/gen/android/
328+
fi
329+
330+
echo "⚠️ Android build failed - continuing with desktop builds only"
331+
332+
- name: Process Android Artifacts
333+
if: steps.android_build.outcome == 'success'
334+
run: |
335+
echo "📱 Processing Android build artifacts..."
214336
215337
# Rename build files using script
216338
cd ..
217-
chmod +x rename-android-builds.sh
218-
./rename-android-builds.sh
219-
220-
# List created files and move them to the correct location for artifact upload
221-
echo "📱 Created files:"
222-
if ls *.apk *.aab 1> /dev/null 2>&1; then
223-
echo "✅ Build files found in app directory:"
224-
ls -la *.apk *.aab
339+
if [[ -f "rename-android-builds.sh" ]]; then
340+
chmod +x rename-android-builds.sh
341+
./rename-android-builds.sh
225342
else
226-
echo "ℹ️ No build files found in app directory, checking if they were created..."
227-
# The script might have created them elsewhere, let's find them
228-
find . -name "*.apk" -o -name "*.aab" | head -10
343+
echo "⚠️ rename-android-builds.sh not found, using default naming"
229344
fi
345+
346+
# List created files
347+
echo "📱 Created files:"
348+
find . -name "*.apk" -o -name "*.aab" | while read file; do
349+
if [[ -f "$file" ]]; then
350+
SIZE=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file" 2>/dev/null)
351+
echo "✅ $file ($SIZE bytes)"
352+
fi
353+
done
230354
env:
231355
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
232356
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
@@ -237,26 +361,69 @@ jobs:
237361
id: timestamp
238362
run: echo "build_time=$(date -u +"%Y-%m-%d %H:%M UTC")" >> $GITHUB_OUTPUT
239363

240-
- name: Set build info outputs
364+
- name: Validate and organize build artifacts
241365
id: build_info
242366
run: |
243-
# Set output paths for the built files
244-
APK_PATH="mpesa2csv-v${{ needs.check-android-release.outputs.version }}-universal-release.apk"
245-
AAB_PATH="mpesa2csv-v${{ needs.check-android-release.outputs.version }}-universal-release.aab"
367+
echo "📱 Validating and organizing Android build artifacts..."
368+
369+
# Find actual build files
370+
APK_FILES=$(find . -name "*.apk" -type f)
371+
AAB_FILES=$(find . -name "*.aab" -type f)
372+
373+
echo "Found APK files: $APK_FILES"
374+
echo "Found AAB files: $AAB_FILES"
375+
376+
# Validate artifacts exist and are not empty
377+
if [[ -z "$APK_FILES" ]] && [[ -z "$AAB_FILES" ]]; then
378+
echo "❌ No Android artifacts found"
379+
exit 1
380+
fi
246381
247-
echo "apk_path=$APK_PATH" >> $GITHUB_OUTPUT
248-
echo "aab_path=$AAB_PATH" >> $GITHUB_OUTPUT
382+
# Create standardized names and move to root directory
383+
VERSION="${{ needs.check-android-release.outputs.version }}"
384+
APK_NAME="mpesa2csv-v${VERSION}-universal-release.apk"
385+
AAB_NAME="mpesa2csv-v${VERSION}-universal-release.aab"
386+
387+
# Copy APK if found
388+
if [[ -n "$APK_FILES" ]]; then
389+
APK_FILE=$(echo "$APK_FILES" | head -1)
390+
cp "$APK_FILE" "./$APK_NAME"
391+
echo "✅ APK copied: $APK_NAME"
392+
echo "apk_path=$APK_NAME" >> $GITHUB_OUTPUT
393+
else
394+
echo "⚠️ No APK file found"
395+
echo "apk_path=" >> $GITHUB_OUTPUT
396+
fi
397+
398+
# Copy AAB if found
399+
if [[ -n "$AAB_FILES" ]]; then
400+
AAB_FILE=$(echo "$AAB_FILES" | head -1)
401+
cp "$AAB_FILE" "./$AAB_NAME"
402+
echo "✅ AAB copied: $AAB_NAME"
403+
echo "aab_path=$AAB_NAME" >> $GITHUB_OUTPUT
404+
else
405+
echo "⚠️ No AAB file found"
406+
echo "aab_path=" >> $GITHUB_OUTPUT
407+
fi
249408
250-
echo "📱 Build outputs set:"
251-
echo " APK: $APK_PATH"
252-
echo " AAB: $AAB_PATH"
409+
# Validate file sizes
410+
for file in *.apk *.aab; do
411+
if [[ -f "$file" ]]; then
412+
SIZE=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file" 2>/dev/null)
413+
if [[ $SIZE -lt 1000000 ]]; then # Less than 1MB is suspicious
414+
echo "⚠️ Artifact $file is suspiciously small ($SIZE bytes)"
415+
else
416+
echo "✅ $file ($SIZE bytes)"
417+
fi
418+
fi
419+
done
253420
254421
- name: Upload Android artifacts
255422
uses: actions/upload-artifact@v4
256423
with:
257424
name: mpesa2csv-v${{ needs.check-android-release.outputs.version }}
258425
path: |
259-
src-tauri/*.apk
260-
src-tauri/*.aab
426+
*.apk
427+
*.aab
261428
retention-days: 30
262429
if-no-files-found: warn

0 commit comments

Comments
 (0)