Skip to content

Commit

Permalink
ci: fail task if one build fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 committed Nov 8, 2024
1 parent 7eeab1c commit 97b8334
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build-sample-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:
uses: customerio/customerio-android/.github/actions/setup-android@main

- name: Build and upload Android app via Fastlane
id: android_build
uses: maierj/[email protected]
with:
subdirectory: apps/${{ matrix.sample-app }}
Expand All @@ -157,6 +158,7 @@ jobs:
run: pod install --project-directory=ios

- name: Build and upload iOS app via Fastlane
id: ios_build
uses: maierj/[email protected]
with:
subdirectory: apps/${{ matrix.sample-app }}
Expand All @@ -165,6 +167,13 @@ jobs:
GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64: ${{ secrets.GOOGLE_CLOUD_MATCH_READONLY_SERVICE_ACCOUNT_B64 }}
FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64: ${{ secrets.FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT_CREDS_B64 }}

- name: Check build statuses and mark failure
run: |
if [ "${{ steps.android_build.outcome }}" != "success" ] || [ "${{ steps.ios_build.outcome }}" != "success" ]; then
echo "One or more builds failed."
exit 1
fi
- name: Update sample builds PR comment with build information
if: ${{ github.event_name == 'pull_request' }}
uses: peter-evans/create-or-update-comment@v4
Expand Down
22 changes: 19 additions & 3 deletions apps/fastlane/helpers/version_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,30 @@

# Replace '/' with '-' to avoid issues with unsupported characters in version name
branch_name = branch_name.gsub('/', '-')
timestamp = current_time.strftime("%Y%m%d.%H%M%S")
# Extract ticket number from branch name
ticket_number_in_branch_name = branch_name.scan(/\d+/).join
# If no ticket number found, set it to 0
ticket_number_in_branch_name = ticket_number_in_branch_name.empty? ? "0" : ticket_number_in_branch_name

sdk_version_name = "#{timestamp}.0-#{branch_name}"
# Format the components individually and remove leading zeros
year = current_time.year.to_s
month = current_time.month.to_s
day = current_time.day.to_s
hour = current_time.hour.to_s
minute = current_time.min.to_s
second = current_time.sec.to_s

# Combine them into the desired format
major = "#{year}#{month}#{day}"
minor = "#{hour}#{minute}#{second}"
patch = ticket_number_in_branch_name.to_s

sdk_version_name = "#{major}.#{minor}.#{patch}"

if github.is_pull_request
app_version_name = "#{github.pr_number}.#{github.pr_commits}.0"
else
app_version_name = sdk_version_name
app_version_name = "#{sdk_version_name}-#{branch_name}"
end
app_version_code = (current_time.to_f / 60).to_i

Expand Down

0 comments on commit 97b8334

Please sign in to comment.