diff --git a/.github/publish_to_firebase.sh b/.github/publish_to_firebase.sh new file mode 100644 index 000000000..72e11b9b9 --- /dev/null +++ b/.github/publish_to_firebase.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +set -o pipefail + +# Required since https://github.blog/2022-04-12-git-security-vulnerability-announced +git config --global --add safe.directory $GITHUB_WORKSPACE + +RELEASE_NOTES="" +RELEASE_NOTES_FILE="" + +TOKEN_DEPRECATED_WARNING_MESSAGE="⚠ This action will stop working with the next future major version of firebase-tools! Migrate to Service Account. See more: https://github.com/wzieba/Firebase-Distribution-Github-Action/wiki/FIREBASE_TOKEN-migration" + +if [[ -z ${INPUT_RELEASENOTES} ]]; then + RELEASE_NOTES="$(git log -1 --pretty=short)" +else + RELEASE_NOTES=${INPUT_RELEASENOTES} +fi + +if [[ ${INPUT_RELEASENOTESFILE} ]]; then + RELEASE_NOTES="" + RELEASE_NOTES_FILE=${INPUT_RELEASENOTESFILE} +fi + +if [ -n "${INPUT_SERVICECREDENTIALSFILE}" ] ; then + export GOOGLE_APPLICATION_CREDENTIALS="${INPUT_SERVICECREDENTIALSFILE}" +fi + +if [ -n "${INPUT_SERVICECREDENTIALSFILECONTENT}" ] ; then + cat <<< "${INPUT_SERVICECREDENTIALSFILECONTENT}" > service_credentials_content.json + export GOOGLE_APPLICATION_CREDENTIALS="service_credentials_content.json" +fi + +if [ -n "${INPUT_TOKEN}" ] ; then + echo ${TOKEN_DEPRECATED_WARNING_MESSAGE} + export FIREBASE_TOKEN="${INPUT_TOKEN}" +fi + +firebase \ + appdistribution:distribute \ + "$INPUT_FILE" \ + --app "$INPUT_APPID" \ + --groups "$INPUT_GROUPS" \ + --testers "$INPUT_TESTERS" \ + ${RELEASE_NOTES:+ --release-notes "${RELEASE_NOTES}"} \ + ${INPUT_RELEASENOTESFILE:+ --release-notes-file "${RELEASE_NOTES_FILE}"} \ + $( (( $INPUT_DEBUG )) && printf %s '--debug' ) | +{ + while read -r line; do + echo $line + + if [[ $line == *"View this release in the Firebase console"* ]]; then + CONSOLE_URI=$(echo "$line" | sed -e 's/.*: //' -e 's/^ *//;s/ *$//') + echo "FIREBASE_CONSOLE_URI=$CONSOLE_URI" >>"$GITHUB_OUTPUT" + elif [[ $line == *"Share this release with testers who have access"* ]]; then + TESTING_URI=$(echo "$line" | sed -e 's/.*: //' -e 's/^ *//;s/ *$//') + echo "TESTING_URI=$TESTING_URI" >>"$GITHUB_OUTPUT" + elif [[ $line == *"Download the release binary"* ]]; then + BINARY_URI=$(echo "$line" | sed -e 's/.*: //' -e 's/^ *//;s/ *$//') + echo "BINARY_DOWNLOAD_URI=$BINARY_URI" >>"$GITHUB_OUTPUT" + fi + done +} \ No newline at end of file diff --git a/.github/workflows/bank-sdk.publish.example.app.firebase.yml b/.github/workflows/bank-sdk.publish.example.app.firebase.yml index 1f9db1586..ba420fb97 100644 --- a/.github/workflows/bank-sdk.publish.example.app.firebase.yml +++ b/.github/workflows/bank-sdk.publish.example.app.firebase.yml @@ -116,13 +116,47 @@ jobs: files: "*.ipa" fail: true + - name: Install Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20 + + - run: npm install -g firebase-tools@13.17.0 + shell: bash + - name: Distribute bank-sdk example ipa to Firebase App Distribution - uses: emertozd/Firebase-Distribution-Github-Action@v2 + id: distribute + run: | + chmod +x .github/publish_to_firebase.sh + .github/publish_to_firebase.sh + shell: bash + env: + INPUT_APPID: ${{ secrets.GINI_BANK_SDK_EXAMPLE_APP_FIREBASE_ID }} + INPUT_SERVICECREDENTIALSFILECONTENT: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} + INPUT_FILE: GiniBankSDKExample.ipa + INPUT_GROUPS: testers + INPUT_RELEASENOTES: | + ${{ format('{{ {0} {1} }}', github.ref, github.sha) }} + ${{ github.event.head_commit.message }} + + - name: Extract Jira ticket + id: extract_jira_ticket + run: | + commit_message=$(git log -1 --pretty=%B) + jira_ticket=$(echo "$commit_message" | sed -n '2p') + echo "JIRA_TICKET_NAME=${jira_ticket}" >> $GITHUB_ENV + + - name: Login to jira + if: ${{ env.JIRA_TICKET_NAME != null }} + uses: justin-jhg/gajira-login@v1 + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_KEY }} + + - name: Comment on issue + if: ${{ env.JIRA_TICKET_NAME != null }} + uses: atlassian/gajira-comment@v3 with: - appId: ${{ secrets.GINI_BANK_SDK_EXAMPLE_APP_FIREBASE_ID }} - serviceCredentialsFileContent: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} - groups: testers - file: GiniBankSDKExample.ipa - releaseNotes: | - ${{ format('{{ {0} {1} }}', github.ref, github.sha) }} - ${{ github.event.head_commit.message }} + issue: ${{ env.JIRA_TICKET_NAME }} + comment: Build bank example app ${{ steps.distribute.outputs.FIREBASE_CONSOLE_URI }} \ No newline at end of file diff --git a/.github/workflows/health-sdk.publish.example.apps.firebase.yml b/.github/workflows/health-sdk.publish.example.apps.firebase.yml index fb60242b1..7a9cf9df7 100644 --- a/.github/workflows/health-sdk.publish.example.apps.firebase.yml +++ b/.github/workflows/health-sdk.publish.example.apps.firebase.yml @@ -107,14 +107,48 @@ jobs: with: files: "*.ipa" fail: true - + + - name: Install Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20 + + - run: npm install -g firebase-tools@13.17.0 + shell: bash + - name: Distribute health-sdk example ipa to Firebase App Distribution - uses: emertozd/Firebase-Distribution-Github-Action@v2 + id: distribute + run: | + chmod +x .github/publish_to_firebase.sh + .github/publish_to_firebase.sh + shell: bash + env: + INPUT_APPID: ${{ secrets.GINI_HEALTH_SDK_EXAMPLE_APP_FIREBASE_ID }} + INPUT_SERVICECREDENTIALSFILECONTENT: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} + INPUT_FILE: GiniHealthSDKExample.ipa + INPUT_GROUPS: testers + INPUT_RELEASENOTES: | + ${{ format('{{ {0} {1} }}', github.ref, github.sha) }} + ${{ github.event.head_commit.message }} + + - name: Extract Jira ticket + id: extract_jira_ticket + run: | + commit_message=$(git log -1 --pretty=%B) + jira_ticket=$(echo "$commit_message" | sed -n '2p') + echo "JIRA_TICKET_NAME=${jira_ticket}" >> $GITHUB_ENV + + - name: Login to jira + if: ${{ env.JIRA_TICKET_NAME != null }} + uses: justin-jhg/gajira-login@v1 + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_KEY }} + + - name: Comment on issue + if: ${{ env.JIRA_TICKET_NAME != null }} + uses: atlassian/gajira-comment@v3 with: - appId: ${{ secrets.GINI_HEALTH_SDK_EXAMPLE_APP_FIREBASE_ID }} - serviceCredentialsFileContent: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} - groups: testers - file: GiniHealthSDKExample.ipa - releaseNotes: | - ${{ format('{{ {0} {1} }}', github.ref, github.sha) }} - ${{ github.event.head_commit.message }} \ No newline at end of file + issue: ${{ env.JIRA_TICKET_NAME }} + comment: Build health example app ${{ steps.distribute.outputs.FIREBASE_CONSOLE_URI }} diff --git a/.github/workflows/merchant-sdk.publish.example.apps.firebase.yml b/.github/workflows/merchant-sdk.publish.example.apps.firebase.yml index 6d694371d..d17eb665d 100644 --- a/.github/workflows/merchant-sdk.publish.example.apps.firebase.yml +++ b/.github/workflows/merchant-sdk.publish.example.apps.firebase.yml @@ -110,16 +110,51 @@ jobs: files: "*.ipa" fail: true - - name: Distribute merchant-sdk example ipa to Firebase App Distribution - uses: emertozd/Firebase-Distribution-Github-Action@v2 + - name: Install Node.js 20.x + uses: actions/setup-node@v4 with: - appId: ${{ secrets.GINI_MERCHANT_SDK_EXAMPLE_APP_FIREBASE_ID }} - serviceCredentialsFileContent: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} - groups: testers - file: GiniMerchantSDKExample.ipa - releaseNotes: | - ${{ format('{{ {0} {1} }}', github.ref, github.sha) }} - ${{ github.event.head_commit.message }} + node-version: 20 + + - run: npm install -g firebase-tools@13.17.0 + shell: bash + + - name: Distribute Merchant sdk example apk to Firebase App Distribution + id: distribute + run: | + chmod +x .github/publish_to_firebase.sh + .github/publish_to_firebase.sh + shell: bash + env: + INPUT_APPID: ${{ secrets.GINI_MERCHANT_SDK_EXAMPLE_APP_FIREBASE_ID }} + INPUT_SERVICECREDENTIALSFILECONTENT: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} + INPUT_FILE: GiniMerchantSDKExample.ipa + INPUT_GROUPS: testers + INPUT_RELEASENOTES: | + ${{ format('{{ {0} {1} }}', github.ref, github.sha) }} + ${{ github.event.head_commit.message }} + + - name: Extract Jira ticket + id: extract_jira_ticket + run: | + commit_message=$(git log -1 --pretty=%B) + jira_ticket=$(echo "$commit_message" | sed -n '2p') + echo "JIRA_TICKET_NAME=${jira_ticket}" >> $GITHUB_ENV + + - name: Login to jira + if: ${{ env.JIRA_TICKET_NAME != null }} + uses: justin-jhg/gajira-login@v1 + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_KEY }} + + - name: Comment on issue + if: ${{ env.JIRA_TICKET_NAME != null }} + uses: atlassian/gajira-comment@v3 + with: + issue: ${{ env.JIRA_TICKET_NAME }} + comment: Build merchant example app ${{ steps.distribute.outputs.FIREBASE_CONSOLE_URI }} +