Add bump build action

This commit is contained in:
Arkadiusz Fal 2023-02-25 13:59:49 +01:00
parent 0995e3ee2f
commit 0c7af0351b
6 changed files with 98 additions and 39 deletions

View File

@ -6,6 +6,7 @@ on:
workflow_dispatch: workflow_dispatch:
env: env:
APP_NAME: Yattee
FASTLANE_USER: ${{ secrets.FASTLANE_USER }} FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }} FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
ITC_TEAM_ID: ${{ secrets.ITC_TEAM_ID }} ITC_TEAM_ID: ${{ secrets.ITC_TEAM_ID }}
@ -22,7 +23,29 @@ env:
TESTFLIGHT_EXTERNAL_GROUPS: ${{ secrets.TESTFLIGHT_EXTERNAL_GROUPS }} TESTFLIGHT_EXTERNAL_GROUPS: ${{ secrets.TESTFLIGHT_EXTERNAL_GROUPS }}
jobs: 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: testflight:
needs: bump_build
strategy: strategy:
matrix: matrix:
lane: ['mac beta', 'ios beta', 'tvos beta'] lane: ['mac beta', 'ios beta', 'tvos beta']
@ -47,6 +70,7 @@ jobs:
path: fastlane/builds/**/*.ipa path: fastlane/builds/**/*.ipa
if-no-files-found: ignore if-no-files-found: ignore
mac_notarized: mac_notarized:
needs: bump_build
name: Build and notarize macOS app name: Build and notarize macOS app
runs-on: macos-latest runs-on: macos-latest
steps: steps:
@ -76,7 +100,7 @@ jobs:
path: ${{ env.ZIP_PATH }} path: ${{ env.ZIP_PATH }}
if-no-files-found: error if-no-files-found: error
release: release:
needs: ['testflight', 'mac_notarized'] needs: ['bump_build', 'testflight', 'mac_notarized']
name: Create GitHub release name: Create GitHub release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

4
.gitignore vendored
View File

@ -97,3 +97,7 @@ iOSInjectionProject/
# User-specific xcconfig files # User-specific xcconfig files
Xcode-config/DEVELOPMENT_TEAM.xcconfig Xcode-config/DEVELOPMENT_TEAM.xcconfig
# Bundler
.bundle/
Vendor/bundle/

1
AS_CONNECT_BUILD_VERSION Normal file
View File

@ -0,0 +1 @@
136

View File

@ -211,6 +211,7 @@ GEM
PLATFORMS PLATFORMS
arm64-darwin-21 arm64-darwin-21
x86_64-darwin-19 x86_64-darwin-19
x86_64-linux
DEPENDENCIES DEPENDENCIES
fastlane fastlane

View File

@ -1,3 +1,5 @@
APP_NAME = "Yattee"
CERTIFICATES_GIT_URL = "git@github.com:developer/yattee-certificates.git" CERTIFICATES_GIT_URL = "git@github.com:developer/yattee-certificates.git"
GIT_AUTHORIZATION = "" # For certificates repo, https://github.com/settings/tokens/new (repo scope) GIT_AUTHORIZATION = "" # For certificates repo, https://github.com/settings/tokens/new (repo scope)
FASTLANE_USER = "developer@mail.com" # Apple ID FASTLANE_USER = "developer@mail.com" # Apple ID

View File

@ -13,6 +13,7 @@
# Uncomment the line if you want fastlane to automatically update itself # Uncomment the line if you want fastlane to automatically update itself
# update_fastlane # update_fastlane
APP_NAME = ENV['APP_NAME']
DEVELOPER_KEY_ID = ENV['DEVELOPER_KEY_ID'] DEVELOPER_KEY_ID = ENV['DEVELOPER_KEY_ID']
DEVELOPER_KEY_ISSUER_ID = ENV['DEVELOPER_KEY_ISSUER_ID'] DEVELOPER_KEY_ISSUER_ID = ENV['DEVELOPER_KEY_ISSUER_ID']
DEVELOPER_KEY_CONTENT = ENV['DEVELOPER_KEY_CONTENT'] DEVELOPER_KEY_CONTENT = ENV['DEVELOPER_KEY_CONTENT']
@ -23,6 +24,11 @@ DEVELOPER_APP_IDENTIFIER = ENV['DEVELOPER_APP_IDENTIFIER']
GIT_AUTHORIZATION = ENV['GIT_AUTHORIZATION'] GIT_AUTHORIZATION = ENV['GIT_AUTHORIZATION']
TESTFLIGHT_EXTERNAL_GROUPS = ENV['TESTFLIGHT_EXTERNAL_GROUPS'] 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) def delete_temp_keychain(name)
delete_keychain( delete_keychain(
name: name name: name
@ -51,17 +57,38 @@ end
desc "Bump build number and commit" desc "Bump build number and commit"
lane :bump_build do lane :bump_build do
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 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( commit_version_bump(
message: "Bump build number to #{get_build_number}" 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 end
desc "Bump version number and commit" desc "Bump version number and commit"
lane :bump_version do lane :bump_version do
increment_version_number increment_version_number
commit_version_bump( commit_version_bump(
message: "Bump version number to #{get_version_number}" message: "Bump version number to #{get_version_number}",
xcodeproj: XCODEPROJ
) )
end end
@ -76,16 +103,16 @@ platform :ios do
key_content: DEVELOPER_KEY_CONTENT key_content: DEVELOPER_KEY_CONTENT
) )
build = get_build_number(xcodeproj: "Yattee.xcodeproj") build = get_build_number(xcodeproj: XCODEPROJ)
version = get_version_number( version = get_version_number(
xcodeproj: "Yattee.xcodeproj", xcodeproj: XCODEPROJ,
target: "Yattee (iOS)" target: "#{APP_NAME} (iOS)"
) )
match( match(
type: 'appstore', type: 'appstore',
platform: 'ios', 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), git_basic_authorization: Base64.strict_encode64(GIT_AUTHORIZATION),
readonly: true, readonly: true,
keychain_name: TEMP_KEYCHAIN_USER, keychain_name: TEMP_KEYCHAIN_USER,
@ -94,13 +121,13 @@ platform :ios do
) )
build_app( build_app(
scheme: "Yattee (iOS)", scheme: "#{APP_NAME} (iOS)",
output_directory: "fastlane/builds/#{version}-#{build}/iOS", output_directory: "fastlane/builds/#{version}-#{build}/iOS",
output_name: "Yattee-#{version}-iOS.ipa", output_name: "#{APP_NAME}-#{version}-iOS.ipa",
export_options: { export_options: {
provisioningProfiles: { provisioningProfiles: {
"#{DEVELOPER_APP_IDENTIFIER}" => "match AppStore #{DEVELOPER_APP_IDENTIFIER}", "#{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 key_content: DEVELOPER_KEY_CONTENT
) )
build = get_build_number(xcodeproj: "Yattee.xcodeproj") build = get_build_number(xcodeproj: XCODEPROJ)
version = get_version_number( version = get_version_number(
xcodeproj: "Yattee.xcodeproj", xcodeproj: XCODEPROJ,
target: "Yattee (tvOS)" target: "#{APP_NAME} (tvOS)"
) )
match( match(
@ -146,9 +173,9 @@ platform :tvos do
) )
build_app( build_app(
scheme: "Yattee (tvOS)", scheme: "#{APP_NAME} (tvOS)",
output_directory: "fastlane/builds/#{version}-#{build}/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_method: "app-store",
export_options: { export_options: {
provisioningProfiles: { provisioningProfiles: {
@ -180,10 +207,10 @@ platform :mac do
key_content: DEVELOPER_KEY_CONTENT key_content: DEVELOPER_KEY_CONTENT
) )
build = get_build_number(xcodeproj: "Yattee.xcodeproj") build = get_build_number(xcodeproj: XCODEPROJ)
version = get_version_number( version = get_version_number(
xcodeproj: "Yattee.xcodeproj", xcodeproj: XCODEPROJ,
target: "Yattee (macOS)" target: "#{APP_NAME} (macOS)"
) )
match( match(
@ -199,9 +226,9 @@ platform :mac do
) )
build_app( build_app(
scheme: "Yattee (macOS)", scheme: "#{APP_NAME} (macOS)",
output_directory: "fastlane/builds/#{version}-#{build}/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_method: "app-store",
export_options: { export_options: {
provisioningProfiles: { provisioningProfiles: {
@ -231,10 +258,10 @@ platform :mac do
key_content: DEVELOPER_KEY_CONTENT key_content: DEVELOPER_KEY_CONTENT
) )
build = get_build_number(xcodeproj: "Yattee.xcodeproj") build = get_build_number(xcodeproj: XCODEPROJ)
version = get_version_number( version = get_version_number(
xcodeproj: "Yattee.xcodeproj", xcodeproj: XCODEPROJ,
target: "Yattee (macOS)" target: "#{APP_NAME} (macOS)"
) )
match( match(
@ -249,9 +276,9 @@ platform :mac do
) )
build_mac_app( build_mac_app(
scheme: "Yattee (macOS)", scheme: "#{APP_NAME} (macOS)",
output_directory: "fastlane/builds/#{version}-#{build}/macOS", output_directory: "fastlane/builds/#{version}-#{build}/macOS",
output_name: "Yattee", output_name: "#{APP_NAME}",
export_method: "developer-id", export_method: "developer-id",
export_options: { export_options: {
provisioningProfiles: { provisioningProfiles: {
@ -261,7 +288,7 @@ platform :mac do
) )
notarize( notarize(
package: "fastlane/builds/#{version}-#{build}/macOS/Yattee.app", package: "fastlane/builds/#{version}-#{build}/macOS/#{APP_NAME}.app",
bundle_id: "#{DEVELOPER_APP_IDENTIFIER}", bundle_id: "#{DEVELOPER_APP_IDENTIFIER}",
api_key: api_key, api_key: api_key,
) )