Merge pull request #1 from mattintech/main
Updateing develop from CICD pipline changes.
This commit is contained in:
159
.github/workflows/android-release.yml
vendored
Normal file
159
.github/workflows/android-release.yml
vendored
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
# 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:
|
||||||
|
# - SIGNING_KEY : 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.SIGNING_KEY }}
|
||||||
|
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: Get the tag name for artifact naming
|
||||||
|
- name: Get tag name
|
||||||
|
id: tag
|
||||||
|
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
# Step 7: Upload APK as artifact with versioned name
|
||||||
|
- name: Upload APK
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: localchat-${{ steps.tag.outputs.tag }}
|
||||||
|
path: app/build/outputs/apk/release/localchat-*-release.apk
|
||||||
|
|
||||||
|
# Step 8: Clean up keystore
|
||||||
|
- name: Clean up keystore
|
||||||
|
if: always()
|
||||||
|
run: rm -f ${{ github.workspace }}/keystore.jks
|
||||||
|
|
||||||
|
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: Get the tag name
|
||||||
|
- name: Get tag name
|
||||||
|
id: tag
|
||||||
|
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
# Step 3: Download APK artifact
|
||||||
|
- name: Download APK
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: localchat-${{ steps.tag.outputs.tag }}
|
||||||
|
path: ./artifacts
|
||||||
|
|
||||||
|
# Step 4: Rename APK file
|
||||||
|
- name: Rename APK
|
||||||
|
run: |
|
||||||
|
# Find the APK file (should be localchat-*-release.apk)
|
||||||
|
APK_FILE=$(find ./artifacts -name "localchat-*-release.apk" | head -n 1)
|
||||||
|
if [ -z "$APK_FILE" ]; then
|
||||||
|
echo "Error: No APK file found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Rename to include tag version
|
||||||
|
mv "$APK_FILE" "./artifacts/localchat-${{ steps.tag.outputs.tag }}.apk"
|
||||||
|
|
||||||
|
# Step 5: 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: |
|
||||||
|
## LocalChat 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/localchat-${{ steps.tag.outputs.tag }}.apk
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
# Step 6: 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. SIGNING_KEY
|
||||||
|
# - 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)
|
||||||
@@ -31,6 +31,16 @@ android {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applicationVariants.all {
|
||||||
|
val variant = this
|
||||||
|
variant.outputs
|
||||||
|
.map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
|
||||||
|
.forEach { output ->
|
||||||
|
val outputFileName = "localchat-${variant.versionName}-${variant.name}.apk"
|
||||||
|
output.outputFileName = outputFileName
|
||||||
|
}
|
||||||
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
|||||||
Reference in New Issue
Block a user