|
| 1 | +name: Android CI |
| 2 | +env: |
| 3 | + # Module names for your project |
| 4 | + app_module: app |
| 5 | + # Project name |
| 6 | + project_name: KtorConnect |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - 'main' |
| 11 | + # Allows you to run this workflow manually from the Actions tab |
| 12 | + workflow_dispatch: |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + # Set Current Date As Env Variable |
| 20 | + - name: Set current date as env variable |
| 21 | + run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV |
| 22 | + |
| 23 | + # Set Repository Name As Env Variable |
| 24 | + - name: Set repository name as env variable |
| 25 | + run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV |
| 26 | + |
| 27 | + # Extract version from build.gradle.kts |
| 28 | + - name: Extract version information |
| 29 | + run: | |
| 30 | + # SmsGateway version |
| 31 | + APP_VERSION=$(grep -o 'versionName = "[^"]*"' ${{ env.app_module }}/build.gradle.kts | cut -d'"' -f2) |
| 32 | + echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV |
| 33 | + |
| 34 | + # Use server version for the release tag (you can modify this as needed) |
| 35 | + echo "RELEASE_VERSION=$APP_VERSION" >> $GITHUB_ENV |
| 36 | + |
| 37 | + - name: Set Up JDK |
| 38 | + uses: actions/setup-java@v4 |
| 39 | + with: |
| 40 | + distribution: 'temurin' |
| 41 | + java-version: '17' |
| 42 | + cache: 'gradle' |
| 43 | + |
| 44 | + # App Build |
| 45 | + - name: Build SmsGateway APK |
| 46 | + run: | |
| 47 | + chmod +x ./gradlew |
| 48 | + ./gradlew assembleDebug |
| 49 | + ./gradlew assembleRelease |
| 50 | + |
| 51 | + # Upload SmsGateway Debug APK as artifact |
| 52 | + - name: Upload SmsGateway APK Debug |
| 53 | + uses: actions/upload-artifact@v4 |
| 54 | + with: |
| 55 | + name: ${{ env.date_today }} - ${{ env.project_name }} - SmsGateway - Debug APK |
| 56 | + path: ${{ env.app_module }}/build/outputs/apk/debug/ |
| 57 | + |
| 58 | + # Upload SmsGateway Release APK as artifact |
| 59 | + - name: Upload SmsGateway APK Release |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: ${{ env.date_today }} - ${{ env.project_name }} - SmsGateway - Release APK |
| 63 | + path: ${{ env.app_module }}/build/outputs/apk/release/ |
| 64 | + |
| 65 | + # Rename APKs for easier identification |
| 66 | + - name: Rename APKs |
| 67 | + run: | |
| 68 | + mkdir -p release_files |
| 69 | + cp ${{ env.app_module }}/build/outputs/apk/debug/*.apk release_files/SmsGateway-App-${{ env.APP_VERSION }}-debug.apk |
| 70 | + cp ${{ env.app_module }}/build/outputs/apk/release/*.apk release_files/SmsGateway-App-${{ env.APP_VERSION }}-release.apk |
| 71 | + |
| 72 | + # Create GitHub Release |
| 73 | + - name: Create Release |
| 74 | + id: create_release |
| 75 | + uses: softprops/action-gh-release@v1 |
| 76 | + with: |
| 77 | + tag_name: v${{ env.RELEASE_VERSION }} |
| 78 | + name: Release v${{ env.RELEASE_VERSION }} |
| 79 | + body: | |
| 80 | + KtorConnect Release v${{ env.RELEASE_VERSION }} (${{ env.date_today }}) |
| 81 | + |
| 82 | + This release contains: |
| 83 | + - SmsGateway APK v${{ env.APP_VERSION }} (Debug & Release) |
| 84 | + |
| 85 | + Built automatically using GitHub Actions. |
| 86 | + draft: false |
| 87 | + prerelease: false |
| 88 | + files: | |
| 89 | + release_files/SmsGateway-App-${{ env.APP_VERSION }}-debug.apk |
| 90 | + release_files/SmsGateway-App-${{ env.APP_VERSION }}-release.apk |
| 91 | + env: |
| 92 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments