From 0c7af0351b0f2ff928320bcd368f59b66d1ecb15 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 25 Feb 2023 13:59:49 +0100 Subject: [PATCH] Add bump build action --- .github/workflows/release.yml | 26 ++++++++++- .gitignore | 4 ++ AS_CONNECT_BUILD_VERSION | 1 + Gemfile.lock | 1 + fastlane/.env.sample | 22 +++++----- fastlane/Fastfile | 83 +++++++++++++++++++++++------------ 6 files changed, 98 insertions(+), 39 deletions(-) create mode 100644 AS_CONNECT_BUILD_VERSION diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 58e81a67..353ade9c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,7 @@ on: workflow_dispatch: env: + APP_NAME: Yattee FASTLANE_USER: ${{ secrets.FASTLANE_USER }} FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }} ITC_TEAM_ID: ${{ secrets.ITC_TEAM_ID }} @@ -22,7 +23,29 @@ env: TESTFLIGHT_EXTERNAL_GROUPS: ${{ secrets.TESTFLIGHT_EXTERNAL_GROUPS }} jobs: + bump_build: + name: Bump build number + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - name: Configure git + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + bundler-cache: true + - uses: maierj/fastlane-action@v3.0.0 + with: + lane: bump_build + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GIT_AUTHORIZATION }} + branch: ${{ github.ref }} testflight: + needs: bump_build strategy: matrix: lane: ['mac beta', 'ios beta', 'tvos beta'] @@ -47,6 +70,7 @@ jobs: path: fastlane/builds/**/*.ipa if-no-files-found: ignore mac_notarized: + needs: bump_build name: Build and notarize macOS app runs-on: macos-latest steps: @@ -76,7 +100,7 @@ jobs: path: ${{ env.ZIP_PATH }} if-no-files-found: error release: - needs: ['testflight', 'mac_notarized'] + needs: ['bump_build', 'testflight', 'mac_notarized'] name: Create GitHub release runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index 50564eb6..fc4926d9 100644 --- a/.gitignore +++ b/.gitignore @@ -97,3 +97,7 @@ iOSInjectionProject/ # User-specific xcconfig files Xcode-config/DEVELOPMENT_TEAM.xcconfig + +# Bundler +.bundle/ +Vendor/bundle/ diff --git a/AS_CONNECT_BUILD_VERSION b/AS_CONNECT_BUILD_VERSION new file mode 100644 index 00000000..7296f257 --- /dev/null +++ b/AS_CONNECT_BUILD_VERSION @@ -0,0 +1 @@ +136 diff --git a/Gemfile.lock b/Gemfile.lock index 8ac2ee17..ae1d4263 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -211,6 +211,7 @@ GEM PLATFORMS arm64-darwin-21 x86_64-darwin-19 + x86_64-linux DEPENDENCIES fastlane diff --git a/fastlane/.env.sample b/fastlane/.env.sample index 2fbdd2b1..41b4a6c8 100644 --- a/fastlane/.env.sample +++ b/fastlane/.env.sample @@ -1,17 +1,19 @@ -CERTIFICATES_GIT_URL="git@github.com:developer/yattee-certificates.git" +APP_NAME = "Yattee" + +CERTIFICATES_GIT_URL = "git@github.com:developer/yattee-certificates.git" GIT_AUTHORIZATION = "" # For certificates repo, https://github.com/settings/tokens/new (repo scope) -FASTLANE_USER="developer@mail.com" # Apple ID -FASTLANE_PASSWORD="" # Apple ID Password -ITC_TEAM_ID="" # https://sarunw.com/posts/fastlane-find-team-id/ -TEAM_ID="" # Developer ID -DEVELOPER_NAME="" # Developer Name (Developer ID) +FASTLANE_USER = "developer@mail.com" # Apple ID +FASTLANE_PASSWORD = "" # Apple ID Password +ITC_TEAM_ID = "" # https://sarunw.com/posts/fastlane-find-team-id/ +TEAM_ID = "" # Developer ID +DEVELOPER_NAME = "" # Developer Name (Developer ID) # Developer Key -DEVELOPER_KEY_ID="" -DEVELOPER_KEY_ISSUER_ID="" -DEVELOPER_KEY_CONTENT="" +DEVELOPER_KEY_ID = "" +DEVELOPER_KEY_ISSUER_ID = "" +DEVELOPER_KEY_CONTENT = "" -FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD="" # Not needed for most users +FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD = "" # Not needed for most users TEMP_KEYCHAIN_USER = "keychain-user" TEMP_KEYCHAIN_PASSWORD = "keychain-password" DEVELOPER_APP_IDENTIFIER = "stream.yattee.app" diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 8745a737..290a3cc3 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -13,6 +13,7 @@ # Uncomment the line if you want fastlane to automatically update itself # update_fastlane +APP_NAME = ENV['APP_NAME'] DEVELOPER_KEY_ID = ENV['DEVELOPER_KEY_ID'] DEVELOPER_KEY_ISSUER_ID = ENV['DEVELOPER_KEY_ISSUER_ID'] DEVELOPER_KEY_CONTENT = ENV['DEVELOPER_KEY_CONTENT'] @@ -23,6 +24,11 @@ DEVELOPER_APP_IDENTIFIER = ENV['DEVELOPER_APP_IDENTIFIER'] GIT_AUTHORIZATION = ENV['GIT_AUTHORIZATION'] TESTFLIGHT_EXTERNAL_GROUPS = ENV['TESTFLIGHT_EXTERNAL_GROUPS'] +AS_CONNECT_BUILD_VERSION_FILENAME = 'AS_CONNECT_BUILD_VERSION' +AS_CONNECT_BUILD_VERSION_PATH = "../#{AS_CONNECT_BUILD_VERSION_FILENAME}" + +XCODEPROJ = "#{APP_NAME}.xcodeproj" + def delete_temp_keychain(name) delete_keychain( name: name @@ -51,17 +57,38 @@ end desc "Bump build number and commit" lane :bump_build do - increment_build_number - commit_version_bump( - message: "Bump build number to #{get_build_number}" - ) + as_connect_build_version = File.read(AS_CONNECT_BUILD_VERSION_PATH).to_i + build = get_build_number(xcodeproj: XCODEPROJ).to_i + + puts "AS Connect build version: #{as_connect_build_version}" + puts "Current build number: #{build}" + + if build <= as_connect_build_version + new_build_number = as_connect_build_version + 1 + + increment_build_number + actual_build_number = get_build_number(xcodeproj: XCODEPROJ).to_i + + puts "Bumped build number to #{actual_build_number}" + + File.open(AS_CONNECT_BUILD_VERSION_PATH, 'w+') { |file| file.write("#{new_build_number}\n") } + + commit_version_bump( + message: "Bump build number to #{get_build_number(xcodeproj: XCODEPROJ)}", + include: [AS_CONNECT_BUILD_VERSION_FILENAME], + xcodeproj: XCODEPROJ + ) + else + puts "Current build number is higher than App Store Connect build version" + end end desc "Bump version number and commit" lane :bump_version do increment_version_number commit_version_bump( - message: "Bump version number to #{get_version_number}" + message: "Bump version number to #{get_version_number}", + xcodeproj: XCODEPROJ ) end @@ -76,16 +103,16 @@ platform :ios do key_content: DEVELOPER_KEY_CONTENT ) - build = get_build_number(xcodeproj: "Yattee.xcodeproj") + build = get_build_number(xcodeproj: XCODEPROJ) version = get_version_number( - xcodeproj: "Yattee.xcodeproj", - target: "Yattee (iOS)" + xcodeproj: XCODEPROJ, + target: "#{APP_NAME} (iOS)" ) match( type: 'appstore', platform: 'ios', - app_identifier: ["#{DEVELOPER_APP_IDENTIFIER}", "#{DEVELOPER_APP_IDENTIFIER}.Open-in-Yattee"], + app_identifier: ["#{DEVELOPER_APP_IDENTIFIER}", "#{DEVELOPER_APP_IDENTIFIER}.Open-in-#{APP_NAME}"], git_basic_authorization: Base64.strict_encode64(GIT_AUTHORIZATION), readonly: true, keychain_name: TEMP_KEYCHAIN_USER, @@ -94,13 +121,13 @@ platform :ios do ) build_app( - scheme: "Yattee (iOS)", + scheme: "#{APP_NAME} (iOS)", output_directory: "fastlane/builds/#{version}-#{build}/iOS", - output_name: "Yattee-#{version}-iOS.ipa", + output_name: "#{APP_NAME}-#{version}-iOS.ipa", export_options: { provisioningProfiles: { "#{DEVELOPER_APP_IDENTIFIER}" => "match AppStore #{DEVELOPER_APP_IDENTIFIER}", - "#{DEVELOPER_APP_IDENTIFIER}.Open-in-Yattee" => "match AppStore #{DEVELOPER_APP_IDENTIFIER}.Open-in-Yattee" + "#{DEVELOPER_APP_IDENTIFIER}.Open-in-#{APP_NAME}" => "match AppStore #{DEVELOPER_APP_IDENTIFIER}.Open-in-#{APP_NAME}" } } ) @@ -128,10 +155,10 @@ platform :tvos do key_content: DEVELOPER_KEY_CONTENT ) - build = get_build_number(xcodeproj: "Yattee.xcodeproj") + build = get_build_number(xcodeproj: XCODEPROJ) version = get_version_number( - xcodeproj: "Yattee.xcodeproj", - target: "Yattee (tvOS)" + xcodeproj: XCODEPROJ, + target: "#{APP_NAME} (tvOS)" ) match( @@ -146,9 +173,9 @@ platform :tvos do ) build_app( - scheme: "Yattee (tvOS)", + scheme: "#{APP_NAME} (tvOS)", output_directory: "fastlane/builds/#{version}-#{build}/tvOS", - output_name: "Yattee-#{version}-tvOS.ipa", + output_name: "#{APP_NAME}-#{version}-tvOS.ipa", export_method: "app-store", export_options: { provisioningProfiles: { @@ -180,10 +207,10 @@ platform :mac do key_content: DEVELOPER_KEY_CONTENT ) - build = get_build_number(xcodeproj: "Yattee.xcodeproj") + build = get_build_number(xcodeproj: XCODEPROJ) version = get_version_number( - xcodeproj: "Yattee.xcodeproj", - target: "Yattee (macOS)" + xcodeproj: XCODEPROJ, + target: "#{APP_NAME} (macOS)" ) match( @@ -199,9 +226,9 @@ platform :mac do ) build_app( - scheme: "Yattee (macOS)", + scheme: "#{APP_NAME} (macOS)", output_directory: "fastlane/builds/#{version}-#{build}/macOS", - output_name: "Yattee-#{version}-macOS.app", + output_name: "#{APP_NAME}-#{version}-macOS.app", export_method: "app-store", export_options: { provisioningProfiles: { @@ -231,10 +258,10 @@ platform :mac do key_content: DEVELOPER_KEY_CONTENT ) - build = get_build_number(xcodeproj: "Yattee.xcodeproj") + build = get_build_number(xcodeproj: XCODEPROJ) version = get_version_number( - xcodeproj: "Yattee.xcodeproj", - target: "Yattee (macOS)" + xcodeproj: XCODEPROJ, + target: "#{APP_NAME} (macOS)" ) match( @@ -249,9 +276,9 @@ platform :mac do ) build_mac_app( - scheme: "Yattee (macOS)", + scheme: "#{APP_NAME} (macOS)", output_directory: "fastlane/builds/#{version}-#{build}/macOS", - output_name: "Yattee", + output_name: "#{APP_NAME}", export_method: "developer-id", export_options: { provisioningProfiles: { @@ -261,7 +288,7 @@ platform :mac do ) notarize( - package: "fastlane/builds/#{version}-#{build}/macOS/Yattee.app", + package: "fastlane/builds/#{version}-#{build}/macOS/#{APP_NAME}.app", bundle_id: "#{DEVELOPER_APP_IDENTIFIER}", api_key: api_key, )