From f2a99eac4cef5bdd0fcadf9008eb675c716b599a Mon Sep 17 00:00:00 2001 From: justSmK <28645140+justSmK@users.noreply.github.com> Date: Thu, 11 Jul 2024 22:28:55 +0300 Subject: [PATCH 1/6] MBX-0000: Remove Slack messages --- .github/workflows/prepare_release_branch.yml | 45 -------------------- .github/workflows/publish.yml | 20 --------- 2 files changed, 65 deletions(-) diff --git a/.github/workflows/prepare_release_branch.yml b/.github/workflows/prepare_release_branch.yml index 4a6adaab..fe0c904c 100644 --- a/.github/workflows/prepare_release_branch.yml +++ b/.github/workflows/prepare_release_branch.yml @@ -41,48 +41,3 @@ jobs: echo "PR_URL=$PR_URL" >> $GITHUB_ENV env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - - name: Post to a Slack channel - id: slack - uses: slackapi/slack-github-action@v1.26.0 - with: - channel-id: 'C06RXV161RA' - payload: | - { - "text": "iOS Release Branch Notification", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "🚀 iOS Release Branch Created" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Branch Name:* *`release/${{ env.VERSION }}`*\n*Status:* Success :white_check_mark:" - } - }, - { - "type": "divider" - }, - { - "type": "actions", - "elements": [ - { - "type": "button", - "text": { - "type": "plain_text", - "text": "Pull Request" - }, - "url": "${{ env.PR_URL }}" - } - ] - } - ] - } - env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_MOBILE_NOTIFIER_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fe032308..983bebe6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -42,26 +42,6 @@ jobs: pod trunk push MindboxLogger.podspec --allow-warnings env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TOKEN }} - - name: Post to a Slack channel - id: slack - uses: slackapi/slack-github-action@v1.26.0 - with: - channel-id: 'C06RXV161RA' - payload: | - { - "text": "iOS - release", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "🚀 MindboxLogger has been successfuly released." - } - } - ] - } - env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_MOBILE_NOTIFIER_TOKEN }} publish: needs: [logger-publish] From 1e9b08910bf70c70a5e9267e3711b8a6156975d0 Mon Sep 17 00:00:00 2001 From: Akylbek Utekeshev Date: Mon, 15 Jul 2024 12:41:21 +0500 Subject: [PATCH 2/6] MBX-0000 Added Loop Message --- .github/workflows/prepare_release_branch.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/prepare_release_branch.yml b/.github/workflows/prepare_release_branch.yml index fe0c904c..d7ac8815 100644 --- a/.github/workflows/prepare_release_branch.yml +++ b/.github/workflows/prepare_release_branch.yml @@ -41,3 +41,17 @@ jobs: echo "PR_URL=$PR_URL" >> $GITHUB_ENV env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Send message to LOOP + env: + LOOP_NOTIFICATION_WEBHOOK_URL: ${{ secrets.LOOP_NOTIFICATION_WEBHOOK_URL }} + VERSION: ${{ github.ref_name }} + run: | + MESSAGE=$(cat < Date: Mon, 22 Jul 2024 15:59:58 +0300 Subject: [PATCH 3/6] MBX-3455: Release scripts (#424) * MBX-3455: Update publish script * MBX-3455: Add margins --- .github/git-release-branch-create.sh | 5 - .github/workflows/publish.yml | 188 +++++++++++++++++++-------- 2 files changed, 131 insertions(+), 62 deletions(-) diff --git a/.github/git-release-branch-create.sh b/.github/git-release-branch-create.sh index 41c8bccc..d0e39739 100755 --- a/.github/git-release-branch-create.sh +++ b/.github/git-release-branch-create.sh @@ -115,8 +115,3 @@ if ! git push origin $current_branch; then echo "Failed to push changes to the origin $current_branch" exit 1 fi - -git tag $version -git push origin $version - -echo "Changes have been committed and tagged as $version on branch $current_branch." diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 983bebe6..2b7925de 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,7 +9,7 @@ on: - '**' jobs: - unit: + unit-tests: runs-on: macos-latest steps: - uses: actions/checkout@v4 @@ -20,18 +20,29 @@ jobs: run: gem install bundler - name: Install bundler dependencies run: bundle install - - name: Install yeetd - run: | - wget https://github.com/biscuitehh/yeetd/releases/download/1.0/yeetd-normal.pkg - sudo installer -pkg yeetd-normal.pkg -target / - yeetd & - name: Run unit tests run: bundle exec fastlane unitTestLane + set-tag: + needs: [unit-tests] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Extract SDK version + run: | + SDK_VERSION=$(sed -n 's/^.*sdkVersion = "\(.*\)"/\1/p' SDKVersionProvider/SDKVersionProvider.swift) + echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_ENV + echo "Extracted SDK version: $SDK_VERSION" + - name: Create tag + run: | + git tag ${{ env.SDK_VERSION }} + git push origin ${{ env.SDK_VERSION }} + logger-publish: + needs: [set-tag] runs-on: macos-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - name: Update bundler run: gem install bundler - name: Install bundler dependencies @@ -42,63 +53,126 @@ jobs: pod trunk push MindboxLogger.podspec --allow-warnings env: COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TOKEN }} + + delay: + needs: [logger-publish] + runs-on: ubuntu-latest + steps: + - name: Delay for 20 minutes + run: sleep 1200 + + check-podspecs-with-retry: + needs: [delay] + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Update bundler + run: gem install bundler + - name: Install bundler dependencies + run: bundle install + - uses: nick-fields/retry@v3 + with: + timeout_minutes: 5 + max_attempts: 20 + command: | + pod repo update + pod lib lint --allow-warnings + retry_on: error + retry_wait_seconds: 120 publish: - needs: [logger-publish] + needs: [check-podspecs-with-retry] runs-on: macos-latest steps: - - name: Delay for 5 minutes - run: sleep 300 - - uses: actions/checkout@v4 - - uses: actions/checkout@v4 - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest-stable - - - name: Release generation - run: ./.github/git-release.sh - env: - GH_TOKEN: ${{ github.token }} - - - name: Update bundler - run: gem install bundler - - name: Install bundler dependencies - run: bundle install - - name: Install yeetd - run: | - wget https://github.com/biscuitehh/yeetd/releases/download/1.0/yeetd-normal.pkg - sudo installer -pkg yeetd-normal.pkg -target / - yeetd & + - uses: actions/checkout@v4 + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + - name: Update bundler + run: gem install bundler + - name: Install bundler dependencies + run: bundle install + - name: Run build + run: bundle exec fastlane buildLane + env: + CI: true + - name: Deploy to Cocoapods Mindbox/MindboxNotifications + run: | + pod repo update + set -eo pipefail + pod lib lint --allow-warnings + pod trunk push Mindbox.podspec --allow-warnings + pod trunk push MindboxNotifications.podspec --allow-warnings + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TOKEN }} - - name: Run build - run: bundle exec fastlane buildLane - env: - CI: true - - name: Deploy to Cocoapods Mindbox/MindboxNotifications - run: | - pod repo update - set -eo pipefail - pod lib lint --allow-warnings - pod trunk push Mindbox.podspec --allow-warnings - pod trunk push MindboxNotifications.podspec --allow-warnings - env: - COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TOKEN }} + release-github: + needs: [publish] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Release generation + run: ./.github/git-release.sh + env: + GH_TOKEN: ${{ github.token }} merge: needs: [publish] runs-on: ubuntu-latest steps: - - name: Checkout develop branch - uses: actions/checkout@v4 - with: - ref: develop - - name: Create Pull Request - run: gh pr create --base develop --head master --title "Merge 'master' into 'develop' after release" --body "Automated Pull Request to merge 'master' into 'develop' after release" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Merge Pull Request - run: | - pr_number=$(gh pr list --base develop --head master --json number --jq '.[0].number') - gh pr merge $pr_number --merge - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout develop branch + uses: actions/checkout@v4 + with: + ref: develop + - name: Create Pull Request + run: gh pr create --base develop --head master --title "Merge 'master' into 'develop' after release" --body "Automated Pull Request to merge 'master' into 'develop' after release" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Merge Pull Request + run: | + pr_number=$(gh pr list --base develop --head master --json number --jq '.[0].number') + gh pr merge $pr_number --merge + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + notify-on-error: + needs: [unit-tests, set-tag, logger-publish, delay, check-podspecs-with-retry, publish, release-github, merge] + runs-on: ubuntu-latest + if: ${{ failure() }} + steps: + - name: Determine failed job + id: get-failed-job + run: | + FAILED_JOB="None" + if [[ "${{ needs.unit-tests.result }}" == "failure" ]]; then + FAILED_JOB="unit-tests" + elif [[ "${{ needs.set-tag.result }}" == "failure" ]]; then + FAILED_JOB="set-tag" + elif [[ "${{ needs.logger-publish.result }}" == "failure" ]]; then + FAILED_JOB="logger-publish" + elif [[ "${{ needs.delay.result }}" == "failure" ]]; then + FAILED_JOB="delay" + elif [[ "${{ needs.check-podspecs-with-retry.result }}" == "failure" ]]; then + FAILED_JOB="check-podspecs-with-retry" + elif [[ "${{ needs.publish.result }}" == "failure" ]]; then + FAILED_JOB="publish" + elif [[ "${{ needs.release-github.result }}" == "failure" ]]; then + FAILED_JOB="release-github" + elif [[ "${{ needs.merge.result }}" == "failure" ]]; then + FAILED_JOB="merge" + fi + echo "FAILED_JOB=$FAILED_JOB" >> $GITHUB_ENV + - name: Send message to LOOP + env: + LOOP_NOTIFICATION_WEBHOOK_URL: ${{ secrets.LOOP_NOTIFICATION_WEBHOOK_URL }} + VERSION: ${{ github.ref_name }} + FAILED_JOB: ${{ env.FAILED_JOB }} + run: | + MESSAGE=$(cat < Date: Wed, 24 Jul 2024 19:34:36 +0300 Subject: [PATCH 4/6] MBX-3507: New image size for rich push notifications (#423) * New image size for rich push notifications * Fix division by zero and accessingSecurityScopedResource --- Mindbox/Info.plist | 2 +- .../MindboxNotificationService.swift | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Mindbox/Info.plist b/Mindbox/Info.plist index 7953f1a8..87afad09 100644 --- a/Mindbox/Info.plist +++ b/Mindbox/Info.plist @@ -17,6 +17,6 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 5614 + 5615 diff --git a/MindboxNotifications/MindboxNotificationService.swift b/MindboxNotifications/MindboxNotificationService.swift index c45063a8..75c8458f 100644 --- a/MindboxNotifications/MindboxNotificationService.swift +++ b/MindboxNotifications/MindboxNotificationService.swift @@ -121,6 +121,9 @@ public class MindboxNotificationService: NSObject { if let attachment = notification.request.content.attachments.first, attachment.url.startAccessingSecurityScopedResource() { + defer { + attachment.url.stopAccessingSecurityScopedResource() + } createImageView(with: attachment.url.path, view: viewController?.view) } createActions(with: payload, context: context) @@ -157,17 +160,24 @@ public class MindboxNotificationService: NSObject { return } - let imageView = UIImageView(image: UIImage(data: data)) - imageView.contentMode = .scaleAspectFill + let image = UIImage(data: data) + let imageView = UIImageView(image: image) + imageView.contentMode = .scaleAspectFit imageView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(imageView) + + let imageHeight = image?.size.height ?? 0 + let imageWidth = image?.size.width ?? 0 + + let imageRatio = (imageWidth > 0) ? imageHeight / imageWidth : 0 + let imageViewHeight = view.bounds.width * imageRatio + NSLayoutConstraint.activate([ - imageView.widthAnchor.constraint(equalTo: view.widthAnchor), - imageView.leftAnchor.constraint(equalTo: view.leftAnchor), - imageView.rightAnchor.constraint(equalTo: view.rightAnchor), + imageView.leadingAnchor.constraint(equalTo: view.leadingAnchor), + imageView.trailingAnchor.constraint(equalTo: view.trailingAnchor), imageView.topAnchor.constraint(equalTo: view.topAnchor), imageView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - imageView.heightAnchor.constraint(lessThanOrEqualToConstant: 300), + imageView.heightAnchor.constraint(lessThanOrEqualToConstant: imageViewHeight), ]) } From 15beed92f8acb1c59fc0563579db3bba7e831fd6 Mon Sep 17 00:00:00 2001 From: Anka Date: Fri, 26 Jul 2024 12:10:38 +0000 Subject: [PATCH 5/6] Bump SDK version from 2.10.2 to 2.10.3-rc --- Mindbox.podspec | 4 ++-- MindboxLogger.podspec | 2 +- MindboxNotifications.podspec | 4 ++-- SDKVersionProvider/SDKVersionConfig.xcconfig | 2 +- SDKVersionProvider/SDKVersionProvider.swift | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Mindbox.podspec b/Mindbox.podspec index 4b26ac99..e57d9c5a 100644 --- a/Mindbox.podspec +++ b/Mindbox.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "Mindbox" - spec.version = "2.10.2" + spec.version = "2.10.3-rc" spec.summary = "SDK for integration with Mindbox" spec.description = "This library allows you to integrate data transfer to Mindbox Marketing Cloud" spec.homepage = "https://github.com/mindbox-cloud/ios-sdk" @@ -14,6 +14,6 @@ Pod::Spec.new do |spec| 'Mindbox' => ['Mindbox/**/*.xcassets', 'Mindbox/**/*.xcdatamodeld', 'Mindbox/**/*.xcprivacy'] } spec.swift_version = "5" - spec.dependency 'MindboxLogger', '2.10.2' + spec.dependency 'MindboxLogger', '2.10.3-rc' end diff --git a/MindboxLogger.podspec b/MindboxLogger.podspec index c061fa17..cb1b0e82 100644 --- a/MindboxLogger.podspec +++ b/MindboxLogger.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "MindboxLogger" - spec.version = "2.10.2" + spec.version = "2.10.3-rc" spec.summary = "SDK for utilities to work with Mindbox" spec.description = "-" spec.homepage = "https://github.com/mindbox-cloud/ios-sdk" diff --git a/MindboxNotifications.podspec b/MindboxNotifications.podspec index 359e1c88..79366963 100644 --- a/MindboxNotifications.podspec +++ b/MindboxNotifications.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "MindboxNotifications" - spec.version = "2.10.2" + spec.version = "2.10.3-rc" spec.summary = "SDK for integration notifications with Mindbox" spec.description = "This library allows you to integrate notifications and transfer them to Mindbox Marketing Cloud" spec.homepage = "https://github.com/mindbox-cloud/ios-sdk" @@ -14,6 +14,6 @@ Pod::Spec.new do |spec| 'MindboxNotifications' => ['MindboxNotifications/**/*.xcprivacy'] } spec.swift_version = "5" - spec.dependency 'MindboxLogger', '2.10.2' + spec.dependency 'MindboxLogger', '2.10.3-rc' end diff --git a/SDKVersionProvider/SDKVersionConfig.xcconfig b/SDKVersionProvider/SDKVersionConfig.xcconfig index bb904f7b..48537767 100644 --- a/SDKVersionProvider/SDKVersionConfig.xcconfig +++ b/SDKVersionProvider/SDKVersionConfig.xcconfig @@ -1 +1 @@ -MARKETING_VERSION = 2.10.2 +MARKETING_VERSION = 2.10.3-rc diff --git a/SDKVersionProvider/SDKVersionProvider.swift b/SDKVersionProvider/SDKVersionProvider.swift index 232cc7a8..81f34aae 100644 --- a/SDKVersionProvider/SDKVersionProvider.swift +++ b/SDKVersionProvider/SDKVersionProvider.swift @@ -8,6 +8,6 @@ import Foundation public class SDKVersionProvider { - public static let sdkVersion = "2.10.2" + public static let sdkVersion = "2.10.3-rc" } From 8687d61b810b9eb130e6e9f7a6e23d6d4d307d32 Mon Sep 17 00:00:00 2001 From: Anka Date: Fri, 26 Jul 2024 12:10:38 +0000 Subject: [PATCH 6/6] Bump 'Example/Podfile' SDK version from 2.10.2 to 2.10.3-rc --- Example/Podfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Example/Podfile b/Example/Podfile index 07f1d35b..f4ce6688 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,13 +1,13 @@ use_frameworks! target 'Example' do - pod 'Mindbox', '2.10.2' + pod 'Mindbox', '2.10.3-rc' end target 'MindboxNotificationServiceExtension' do - pod 'MindboxNotifications', '2.10.2' + pod 'MindboxNotifications', '2.10.3-rc' end target 'MindboxNotificationContentExtension' do - pod 'MindboxNotifications', '2.10.2' + pod 'MindboxNotifications', '2.10.3-rc' end