mirror of
https://github.com/mattintech/AndroidTestApp.git
synced 2026-07-11 13:11:53 +00:00
updating CICD pipeline
This commit is contained in:
49
.github/workflows/android-ci.yml
vendored
Normal file
49
.github/workflows/android-ci.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# GitHub Actions workflow for continuous integration
|
||||||
|
# This workflow runs on pull requests to validate code quality
|
||||||
|
|
||||||
|
name: Android CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ main, develop ]
|
||||||
|
push:
|
||||||
|
branches: [ develop ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Run Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '17'
|
||||||
|
distribution: 'temurin'
|
||||||
|
cache: gradle
|
||||||
|
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
|
||||||
|
- name: Run unit tests
|
||||||
|
run: ./gradlew test
|
||||||
|
|
||||||
|
- name: Run lint
|
||||||
|
run: ./gradlew lint
|
||||||
|
|
||||||
|
- name: Upload test results
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: test-results
|
||||||
|
path: app/build/test-results/
|
||||||
|
|
||||||
|
- name: Upload lint results
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: lint-results
|
||||||
|
path: app/build/reports/lint-results-*.html
|
||||||
154
.github/workflows/android-release.yml
vendored
Normal file
154
.github/workflows/android-release.yml
vendored
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
# GitHub Actions workflow for building and releasing Android APK
|
||||||
|
# This workflow builds a release APK and creates a GitHub release with the APK attached
|
||||||
|
|
||||||
|
name: Android Release Build
|
||||||
|
|
||||||
|
# Trigger the workflow only on version tags (e.g., v1.0.0, v2.1.3)
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build Release APK
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Step 1: Checkout the repository code
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Step 2: Set up JDK 17 (required for Android Gradle Plugin 8.x)
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '17'
|
||||||
|
distribution: 'temurin'
|
||||||
|
cache: gradle
|
||||||
|
|
||||||
|
# Step 3: Grant execute permission for gradlew
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
|
||||||
|
# Step 4: Decode and prepare the keystore
|
||||||
|
# IMPORTANT: You need to configure the following secrets in your GitHub repository:
|
||||||
|
# - ANDROID_KEYSTORE: Base64 encoded keystore file
|
||||||
|
# - KEYSTORE_PASSWORD: Password for the keystore
|
||||||
|
# - KEY_ALIAS: Alias of the key in the keystore
|
||||||
|
# - KEY_PASSWORD: Password for the key
|
||||||
|
- name: Decode Keystore
|
||||||
|
env:
|
||||||
|
ANDROID_KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }}
|
||||||
|
run: |
|
||||||
|
echo "$ANDROID_KEYSTORE" | base64 --decode > ${{ github.workspace }}/keystore.jks
|
||||||
|
|
||||||
|
# Step 5: Build Release APK with signing
|
||||||
|
- name: Build Release APK
|
||||||
|
env:
|
||||||
|
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||||
|
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
||||||
|
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
./gradlew assembleRelease \
|
||||||
|
-Pandroid.injected.signing.store.file=${{ github.workspace }}/keystore.jks \
|
||||||
|
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \
|
||||||
|
-Pandroid.injected.signing.key.alias=$KEY_ALIAS \
|
||||||
|
-Pandroid.injected.signing.key.password=$KEY_PASSWORD
|
||||||
|
|
||||||
|
# Step 6: Upload APK as artifact
|
||||||
|
- name: Upload APK
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: app-release
|
||||||
|
path: app/build/outputs/apk/release/app-release.apk
|
||||||
|
|
||||||
|
# Step 7: Clean up keystore
|
||||||
|
- name: Clean up keystore
|
||||||
|
if: always()
|
||||||
|
run: rm -f ${{ github.workspace }}/keystore.jks
|
||||||
|
|
||||||
|
# Step 8: Run tests (optional but recommended)
|
||||||
|
- name: Run Unit Tests
|
||||||
|
run: ./gradlew test
|
||||||
|
|
||||||
|
# Step 9: Upload test results
|
||||||
|
- name: Upload Test Results
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: test-results
|
||||||
|
path: app/build/test-results/
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: Create GitHub Release
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Step 1: Checkout code for changelog generation
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
# Step 2: Download APK artifact
|
||||||
|
- name: Download APK
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: app-release
|
||||||
|
path: ./artifacts
|
||||||
|
|
||||||
|
# Step 3: Get the tag name
|
||||||
|
- name: Get tag name
|
||||||
|
id: tag
|
||||||
|
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
# Step 4: Create GitHub Release
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.tag.outputs.tag }}
|
||||||
|
name: Release ${{ steps.tag.outputs.tag }}
|
||||||
|
body: |
|
||||||
|
## AndroidTestApp Release
|
||||||
|
|
||||||
|
### What's New
|
||||||
|
- Built from commit: ${{ github.sha }}
|
||||||
|
- Build number: ${{ github.run_number }}
|
||||||
|
|
||||||
|
### Download
|
||||||
|
Download the APK file attached below.
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
1. Enable "Install from Unknown Sources" in your Android settings
|
||||||
|
2. Download the APK file
|
||||||
|
3. Open the downloaded file to install
|
||||||
|
|
||||||
|
---
|
||||||
|
*This release was automatically generated by GitHub Actions*
|
||||||
|
files: ./artifacts/app-release.apk
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
# Step 5: Clean up artifacts
|
||||||
|
- name: Clean up artifacts
|
||||||
|
if: always()
|
||||||
|
run: rm -rf ./artifacts
|
||||||
|
|
||||||
|
# Required Secrets Configuration:
|
||||||
|
# Go to Settings > Secrets and variables > Actions in your GitHub repository and add:
|
||||||
|
#
|
||||||
|
# 1. ANDROID_KEYSTORE
|
||||||
|
# - Generate a keystore: keytool -genkey -v -keystore release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias your-alias
|
||||||
|
# - Convert to base64: base64 -i release-key.jks | pbcopy (on macOS) or base64 release-key.jks | xclip (on Linux)
|
||||||
|
# - Paste the base64 string as the secret value
|
||||||
|
#
|
||||||
|
# 2. KEYSTORE_PASSWORD
|
||||||
|
# - The password you used when creating the keystore
|
||||||
|
#
|
||||||
|
# 3. KEY_ALIAS
|
||||||
|
# - The alias you specified when creating the keystore (e.g., "your-alias")
|
||||||
|
#
|
||||||
|
# 4. KEY_PASSWORD
|
||||||
|
# - The password for the specific key (often the same as keystore password)
|
||||||
15
.gitignore
vendored
15
.gitignore
vendored
@@ -1,20 +1,7 @@
|
|||||||
*.iml
|
*.iml
|
||||||
.gradle
|
.gradle
|
||||||
/local.properties
|
/local.properties
|
||||||
/.idea/caches
|
/.idea/
|
||||||
/.idea/libraries
|
|
||||||
/.idea/modules.xml
|
|
||||||
/.idea/workspace.xml
|
|
||||||
/.idea/navEditor.xml
|
|
||||||
/.idea/assetWizardSettings.xml
|
|
||||||
/.idea/vcs.xml
|
|
||||||
/.idea/misc.xml
|
|
||||||
/.idea/compiler.xml
|
|
||||||
/.idea/gradle.xml
|
|
||||||
/.idea/kotlinc.xml
|
|
||||||
/.idea/deploymentTargetSelector.xml
|
|
||||||
/.idea/migrations.xml
|
|
||||||
/.idea/inspectionProfiles/
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
|
|||||||
Reference in New Issue
Block a user