Upload To Firebase App Distribution #27
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: Upload To Firebase App Distribution | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| type: choice | |
| description: 'Select the environment' | |
| required: true | |
| default: 'staging' | |
| options: [ 'staging', 'release' ] | |
| release_title: | |
| type: textarea | |
| description: 'Release title' | |
| required: false | |
| release_notes: | |
| type: textarea | |
| description: 'Release notes (optional)' | |
| required: false | |
| create_release: | |
| type: boolean | |
| description: 'Create New Release' | |
| required: false | |
| default: false | |
| prerelease: | |
| type: boolean | |
| description: 'Pre-release' | |
| required: false | |
| default: true | |
| notify_testers: | |
| type: boolean | |
| description: 'Notify testers about this build' | |
| required: false | |
| default: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| # 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@v3 | |
| with: | |
| distribution: 'zulu' # See 'Supported distributions' for available options | |
| java-version: '21' | |
| cache: 'gradle' | |
| - name: Change wrapper permissions | |
| run: chmod +x ./gradlew | |
| - uses: BrycensRanch/read-properties-action@v1 | |
| id: all | |
| with: | |
| file: app/versions.properties | |
| all: true | |
| # Create APK Debug | |
| - name: Build APK | |
| id: build | |
| run: | | |
| if [[ "${{ github.event.inputs.environment }}" == "staging" ]]; then | |
| ./gradlew assembleDebug | |
| elif [[ "${{ github.event.inputs.environment }}" == "release" ]]; then | |
| ./gradlew assembleRelease | |
| else | |
| echo "Invalid environment selected" | |
| exit 1 | |
| fi | |
| - name: Upload artifact to Firebase App Distribution | |
| if: ${{ github.event.inputs.notify_testers == 'true' }} | |
| uses: wzieba/Firebase-Distribution-Github-Action@v1 | |
| with: | |
| appId: ${{ github.event.inputs.environment == 'staging' && secrets.FIREBASE_APP_ID || secrets.FIREBASE_RELEASE_APP_ID }} | |
| serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }} | |
| groups: testers | |
| file: ${{ github.event.inputs.environment == 'staging' && 'app/build/outputs/apk/debug/app-debug.apk' || 'app/build/outputs/apk/release/app-release.apk' }} | |
| - name: Create Release | |
| if: ${{ github.event.inputs.create_release == 'true' }} | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ github.event.inputs.release_title || 'New Release' }} | |
| body: ${{ github.event.inputs.release_notes || 'No release notes provided' }} | |
| prerelease: ${{ github.event.inputs.prerelease }} | |
| tag_name: "v${{ steps.all.outputs.version_major }}.${{ steps.all.outputs.version_minor }}.${{ steps.all.outputs.version_patch }}" | |
| - name: Update workflow run name | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| github.rest.actions.updateWorkflowRunName({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: context.runId, | |
| name: `Build v${process.env.VERSION} (Run #${process.env.GITHUB_RUN_NUMBER})` | |
| }); | |
| env: | |
| VERSION: "${{ steps.all.outputs.version_major }}.${{ steps.all.outputs.version_minor }}.${{ steps.all.outputs.version_patch }}" |