Update build.yml #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate APKs for Client and Server Apps | |
| env: | |
| # Module names for your project | |
| server_module: server | |
| client_module: client | |
| # Project name | |
| project_name: KtorConnect | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Set Current Date As Env Variable | |
| - name: Set current date as env variable | |
| run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
| # Set Repository Name As Env Variable | |
| - name: Set repository name as env variable | |
| run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV | |
| - name: Set Up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| cache: 'gradle' | |
| # App Build | |
| - name: Build Server APK | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew assembleDebug | |
| ./gradlew assembleRelease | |
| # Upload Server Debug APK | |
| - name: Upload Server APK Debug | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.date_today }} - ${{ env.project_name }} - Server - Debug APK | |
| path: ${{ env.server_module }}/build/outputs/apk/debug/ | |
| # Upload Server Release APK | |
| - name: Upload Server APK Release | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.date_today }} - ${{ env.project_name }} - Server - Release APK | |
| path: ${{ env.server_module }}/build/outputs/apk/release/ | |
| # Upload Client Debug APK | |
| - name: Upload Client APK Debug | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.date_today }} - ${{ env.project_name }} - Client - Debug APK | |
| path: ${{ env.client_module }}/build/outputs/apk/debug/ | |
| # Upload Client Release APK | |
| - name: Upload Client APK Release | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.date_today }} - ${{ env.project_name }} - Client - Release APK | |
| path: ${{ env.client_module }}/build/outputs/apk/release/ |