Merge pull request #114 from AGiXT/copilot/add-recording-feature-glasses #362
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: Build and Deploy | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| permissions: | |
| contents: write | |
| jobs: | |
| apk-dev: | |
| name: Build APK (dev) | |
| runs-on: ubuntu-latest | |
| container: | |
| image: joshxt/flutterbuilder:main | |
| env: | |
| APP_NAME: AGiXT | |
| AGIXT_SERVER: https://api.agixt.dev | |
| APP_URI: https://agixt.dev | |
| FLAVOR_NAME: dev | |
| outputs: | |
| new_tag: ${{ steps.next_tag_version.outputs.new_tag }} | |
| artifact_id: ${{ steps.upload_artifact.outputs.artifact-id }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Increment tag version | |
| if: github.ref == 'refs/heads/main' | |
| uses: mathieudutour/github-tag-action@v6.2 | |
| id: next_tag_version | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| release_branches: main | |
| create_annotated_tag: true | |
| - name: Set default tag for non-main branches | |
| if: github.ref != 'refs/heads/main' | |
| run: echo "new_tag=dev" >> $GITHUB_OUTPUT | |
| id: default_tag | |
| - name: Setup repositories cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Git Safe Directory | |
| run: | | |
| git config --global --add safe.directory /usr/local/flutter && \ | |
| git config --global --add safe.directory /app | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Run tests | |
| run: flutter test | |
| - name: Build Android release | |
| run: | | |
| flutter build apk --release | |
| - name: Upload APK artifact | |
| uses: actions/upload-artifact@v4 | |
| id: upload_artifact | |
| with: | |
| name: dev.apk | |
| path: build/app/outputs/flutter-apk/app-release.apk | |
| - name: Send APK to Discord | |
| if: always() | |
| continue-on-error: true | |
| run: | | |
| GITHUB_USERNAME="${{ github.actor }}" | |
| if [ "$GITHUB_USERNAME" = "Josh-XT" ]; then | |
| DISCORD_NAME="<@381837595522367488>" | |
| elif [ "$GITHUB_USERNAME" = "waiscodes" ]; then | |
| DISCORD_NAME="<@670762167037067304>" | |
| elif [ "$GITHUB_USERNAME" = "birdup000" ]; then | |
| DISCORD_NAME="<@856308374567256074>" | |
| elif [ "$GITHUB_USERNAME" = "Nick-XT" ]; then | |
| DISCORD_NAME="<@381908912951001088>" | |
| elif [ "$GITHUB_USERNAME" = "rm4453" ]; then | |
| DISCORD_NAME="<@1104215954356969512>" | |
| elif [ "$GITHUB_USERNAME" = "Luke-XT" ]; then | |
| DISCORD_NAME="<@334703813967740938>" | |
| else | |
| DISCORD_NAME="**$GITHUB_USERNAME**" | |
| fi | |
| BRANCH_NAME=$(echo ${{ github.ref }} | awk -F'/' '{print $NF}') | |
| VERSION="${{ github.ref == 'refs/heads/main' && steps.next_tag_version.outputs.new_tag || 'dev' }}" | |
| ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.upload_artifact.outputs.artifact-id }}" | |
| JOB_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| COMMIT_MESSAGE=$(echo "${{ github.event.head_commit.message }}" | tr '\n' ' ' | sed 's/"/\\"/g') | |
| FILE_PATH="build/app/outputs/flutter-apk/app-release.apk" | |
| if [ -f "$FILE_PATH" ]; then | |
| FILE_SIZE=$(stat -c%s "$FILE_PATH") | |
| if [ $FILE_SIZE -gt 0 ]; then | |
| MESSAGE="✅ Build successful for **${{ github.repository }}** (dev.apk) on branch **$BRANCH_NAME** at commit ${{ github.sha }}\n**$COMMIT_MESSAGE** by ${DISCORD_NAME} \nDownload the APK here: $ARTIFACT_URL" | |
| else | |
| MESSAGE="❌ Build failed for **${{ github.repository }}** (dev.apk) on branch **$BRANCH_NAME** at commit ${{ github.sha }}\n**$COMMIT_MESSAGE** by ${DISCORD_NAME} \nView the build logs here: $JOB_URL" | |
| fi | |
| else | |
| MESSAGE="❌ Build failed for **${{ github.repository }}** (dev.apk) on branch **$BRANCH_NAME** at commit ${{ github.sha }}\n**$COMMIT_MESSAGE** by ${DISCORD_NAME} \nView the build logs here: $JOB_URL" | |
| fi | |
| curl -H "Content-Type:application/json" -d "{\"content\":\"$MESSAGE\"}" "${{ secrets.DISCORD_WEBHOOK }}" | |
| apk-main-flavors: | |
| name: Build APK (${{ matrix.flavor.name }}) | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| container: | |
| image: joshxt/flutterbuilder:main | |
| needs: [apk-dev] | |
| strategy: | |
| matrix: | |
| flavor: | |
| - name: agixt | |
| env: | |
| APP_NAME: AGiXT | |
| AGIXT_SERVER: https://api.agixt.com | |
| APP_URI: https://agixt.com | |
| - name: nursext | |
| env: | |
| APP_NAME: NurseXT | |
| AGIXT_SERVER: https://api.nursext.com | |
| APP_URI: https://nursext.com | |
| - name: xtsystems | |
| env: | |
| APP_NAME: XT Systems | |
| AGIXT_SERVER: https://api.xt.systems | |
| APP_URI: https://xt.systems | |
| - name: ultraestimate | |
| env: | |
| APP_NAME: UltraEstimate | |
| AGIXT_SERVER: https://api.ultraestimate.com | |
| APP_URI: https://ultraestimate.com | |
| - name: joshxt | |
| env: | |
| APP_NAME: JoshXT AGiXT | |
| AGIXT_SERVER: https://api.josh.devxt.com | |
| APP_URI: https://josh.devxt.com | |
| - name: nickxt | |
| env: | |
| APP_NAME: NickXT AGiXT | |
| AGIXT_SERVER: https://api.nick.devxt.com | |
| APP_URI: https://nick.devxt.com | |
| env: | |
| APP_NAME: ${{ matrix.flavor.env.APP_NAME }} | |
| AGIXT_SERVER: ${{ matrix.flavor.env.AGIXT_SERVER }} | |
| APP_URI: ${{ matrix.flavor.env.APP_URI }} | |
| outputs: | |
| artifact_ids: ${{ steps.upload_artifact.outputs.artifact-id }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup repositories cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Git Safe Directory | |
| run: | | |
| git config --global --add safe.directory /usr/local/flutter && \ | |
| git config --global --add safe.directory /app | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Build Android release | |
| run: | | |
| flutter build apk --release | |
| - name: Upload APK artifact | |
| uses: actions/upload-artifact@v4 | |
| id: upload_artifact | |
| with: | |
| name: ${{ matrix.flavor.name }}.apk | |
| path: build/app/outputs/flutter-apk/app-release.apk | |
| - name: Send APK to Discord | |
| if: always() | |
| continue-on-error: true | |
| run: | | |
| GITHUB_USERNAME="${{ github.actor }}" | |
| if [ "$GITHUB_USERNAME" = "Josh-XT" ]; then | |
| DISCORD_NAME="<@381837595522367488>" | |
| elif [ "$GITHUB_USERNAME" = "waiscodes" ]; then | |
| DISCORD_NAME="<@670762167037067304>" | |
| elif [ "$GITHUB_USERNAME" = "birdup000" ]; then | |
| DISCORD_NAME="<@856308374567256074>" | |
| elif [ "$GITHUB_USERNAME" = "Nick-XT" ]; then | |
| DISCORD_NAME="<@381908912951001088>" | |
| elif [ "$GITHUB_USERNAME" = "rm4453" ]; then | |
| DISCORD_NAME="<@1104215954356969512>" | |
| elif [ "$GITHUB_USERNAME" = "Luke-XT" ]; then | |
| DISCORD_NAME="<@334703813967740938>" | |
| else | |
| DISCORD_NAME="**$GITHUB_USERNAME**" | |
| fi | |
| BRANCH_NAME=$(echo ${{ github.ref }} | awk -F'/' '{print $NF}') | |
| VERSION="${{ needs.apk-dev.outputs.new_tag }}" | |
| ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.upload_artifact.outputs.artifact-id }}" | |
| JOB_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| COMMIT_MESSAGE=$(echo "${{ github.event.head_commit.message }}" | tr '\n' ' ' | sed 's/"/\\"/g') | |
| FILE_PATH="build/app/outputs/flutter-apk/app-release.apk" | |
| if [ -f "$FILE_PATH" ]; then | |
| FILE_SIZE=$(stat -c%s "$FILE_PATH") | |
| if [ $FILE_SIZE -gt 0 ]; then | |
| MESSAGE="✅ Build successful for **${{ github.repository }}** (${{ matrix.flavor.name }}.apk) on branch **$BRANCH_NAME** at commit ${{ github.sha }}\n**$COMMIT_MESSAGE** by ${DISCORD_NAME} \nDownload the APK here: $ARTIFACT_URL" | |
| else | |
| MESSAGE="❌ Build failed for **${{ github.repository }}** (${{ matrix.flavor.name }}.apk) on branch **$BRANCH_NAME** at commit ${{ github.sha }}\n**$COMMIT_MESSAGE** by ${DISCORD_NAME} \nView the build logs here: $JOB_URL" | |
| fi | |
| else | |
| MESSAGE="❌ Build failed for **${{ github.repository }}** (${{ matrix.flavor.name }}.apk) on branch **$BRANCH_NAME** at commit ${{ github.sha }}\n**$COMMIT_MESSAGE** by ${DISCORD_NAME} \nView the build logs here: $JOB_URL" | |
| fi | |
| curl -H "Content-Type:application/json" -d "{\"content\":\"$MESSAGE\"}" "${{ secrets.DISCORD_WEBHOOK }}" | |
| release: | |
| name: Create Release and Upload APKs | |
| needs: [apk-dev, apk-main-flavors] | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.apk-dev.outputs.new_tag }} | |
| name: ${{ needs.apk-dev.outputs.new_tag }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download all APKs from build | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: apks | |
| - name: Upload all APKs to release | |
| run: | | |
| # Upload each flavor APK (skip dev.apk and joshxt.apk) | |
| for flavor_dir in apks/*/; do | |
| flavor_name=$(basename "$flavor_dir") | |
| # Skip dev.apk and joshxt.apk - they're only for Discord/artifacts | |
| if [ "$flavor_name" = "dev.apk" ] || [ "$flavor_name" = "joshxt.apk" ] || [ "$flavor_name" = "nickxt.apk" ]; then | |
| echo "Skipping $flavor_name (dev build)" | |
| continue | |
| fi | |
| apk_file="$flavor_dir/app-release.apk" | |
| if [ -f "$apk_file" ]; then | |
| # Rename the file to the flavor name before uploading | |
| cp "$apk_file" "/tmp/$flavor_name" | |
| echo "Uploading /tmp/$flavor_name to release..." | |
| gh release upload "${{ needs.apk-dev.outputs.new_tag }}" "/tmp/$flavor_name" --clobber --repo ${{ github.repository }} | |
| fi | |
| done | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |