Skip to content

Commit 53411ba

Browse files
authored
[#225] 테스트플라이트 자동 배포가 실패하는 현상을 해결한다 (#241)
* style: 정확하게 테플이라는 이름 명시 * refactor: 앱 빌드 시간 단축 * chore: fastlane/README.md 추적 끄기 * test: lint 모듈 validation 스킵 * fix: 내부 testflight 이름과 겹치는 현상 수정 * fix: export_method 수정 * chore: 테스트플라이트 CI 배포 서명 설정 수정 * chore: 테스트플라이트 CI 서명 옵션 보정 * fix: fastlane 배포용 인증서 설치 흐름 수정 * feat: Apple Store Connect에 올라간 최신 빌드 번호 + 1 형태로 새 빌드 번호를 규정하도록 추가 * feat: 타깃의 Release 서명을 수동으로 고정 * style: 문자열 상수화 * fix: Apple Store Connect에서 최신 빌드번호를 조회하지 못하는 이슈 해결 * fix: fastlane 대신 spaceship을 통해 가져오도록 변경 * fix: CI 환경에서 시크릿키로 생성되는 p8 파일 위치를 찾지 못하는 현상 해결 * fix: 경로 이슈 해결 * test: 토큰 재생성 대신 기존에 생성한 것을 그대로 사용하도록 수정 * refactor: api_key 자체를 넘기도록 개선 * test: 해시값 디버깅 * test: 키 해시 확인 * style: 디버깅 코드 제거 * feat: 태그 기반으로 testflight 배포 * feat: 깃헙 릴리즈 자동화 * feat: 앱스토어 버전은 빌드를 새로 만들지 않고 TestFlight용으로 만들어진 최신 빌드를 사용하도록 변경 * style: 스네이크 케이스 적용
1 parent 5bf1ea1 commit 53411ba

3 files changed

Lines changed: 49 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
2121

2222
permissions:
23-
contents: read
23+
contents: write
2424

2525
jobs:
2626
release:
@@ -62,3 +62,24 @@ jobs:
6262
6363
- name: Release to App Store Connect
6464
run: bundle exec fastlane release
65+
66+
- name: Read release version
67+
id: release_version
68+
run: |
69+
version=$(ruby -e 'project = File.read("DevLog.xcodeproj/project.pbxproj"); match = project.match(/MARKETING_VERSION = ([^;]+);/); abort("MARKETING_VERSION not found") if match.nil?; puts match[1]')
70+
echo "version=$version" >> "$GITHUB_OUTPUT"
71+
echo "tag=v$version" >> "$GITHUB_OUTPUT"
72+
73+
- name: Create GitHub Release
74+
env:
75+
GH_TOKEN: ${{ github.token }}
76+
run: |
77+
if gh release view "${{ steps.release_version.outputs.tag }}" >/dev/null 2>&1; then
78+
echo "Release already exists for ${{ steps.release_version.outputs.tag }}"
79+
exit 0
80+
fi
81+
82+
gh release create "${{ steps.release_version.outputs.tag }}" \
83+
--target "${{ github.event.pull_request.merge_commit_sha }}" \
84+
--title "${{ steps.release_version.outputs.tag }}" \
85+
--generate-notes

.github/workflows/testflight.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: iOS TestFlight
22

33
on:
44
push:
5-
branches:
6-
- develop
5+
tags:
6+
- "qa-*"
77
workflow_dispatch:
88

99
env:

fastlane/Fastfile

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ platform :ios do
88
private_lane :fetch_latest_testflight_build_number do |options|
99
require "spaceship"
1010

11-
apiKey = options[:api_key]
12-
versionNumber = options[:version]
11+
api_key = options[:api_key]
12+
version_number = options[:version]
1313

14-
Spaceship::ConnectAPI.token = Spaceship::ConnectAPI::Token.create(**apiKey)
14+
Spaceship::ConnectAPI.token = Spaceship::ConnectAPI::Token.create(**api_key)
1515

1616
app = Spaceship::ConnectAPI::App.find(APP_IDENTIFIER)
1717
UI.user_error!("Could not find app for #{APP_IDENTIFIER}") if app.nil?
1818

1919
filter = {
2020
"state" => "PROCESSING,FAILED,COMPLETE",
21-
"cfBundleShortVersionString" => versionNumber,
21+
"cfBundleShortVersionString" => version_number,
2222
"platform" => Spaceship::ConnectAPI::Platform.map("ios")
2323
}
2424

@@ -54,21 +54,21 @@ platform :ios do
5454

5555
api_key = asc_api_key
5656

57-
versionNumber = get_version_number(
57+
version_number = get_version_number(
5858
xcodeproj: XCODE_PROJ,
5959
target: TARGET_NAME
6060
)
6161

62-
latestTestflightBuildNumber = fetch_latest_testflight_build_number(
62+
latest_testflight_build_number = fetch_latest_testflight_build_number(
6363
api_key: api_key,
64-
version: versionNumber
64+
version: version_number
6565
)
6666

6767
setup_ci if ENV["CI"]
6868

6969
increment_build_number(
7070
xcodeproj: XCODE_PROJ,
71-
build_number: latestTestflightBuildNumber + 1
71+
build_number: latest_testflight_build_number + 1
7272
)
7373

7474
match(
@@ -84,8 +84,8 @@ platform :ios do
8484
)
8585

8686
if ENV["CI"] == "true"
87-
provisioningProfileSpecifier = lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING][APP_IDENTIFIER].to_s
88-
UI.user_error!("Missing App Store provisioning profile mapping for #{APP_IDENTIFIER}") if provisioningProfileSpecifier.empty?
87+
provisioning_profile_specifier = lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING][APP_IDENTIFIER].to_s
88+
UI.user_error!("Missing App Store provisioning profile mapping for #{APP_IDENTIFIER}") if provisioning_profile_specifier.empty?
8989

9090
update_code_signing_settings(
9191
use_automatic_signing: false,
@@ -95,7 +95,7 @@ platform :ios do
9595
targets: [TARGET_NAME],
9696
build_configurations: ["Release"],
9797
code_sign_identity: "Apple Distribution",
98-
profile_name: provisioningProfileSpecifier
98+
profile_name: provisioning_profile_specifier
9999
)
100100
end
101101

@@ -123,13 +123,26 @@ platform :ios do
123123
end
124124

125125
lane :release do
126-
api_key = build_for_store
126+
api_key = asc_api_key
127+
version_number = get_version_number(
128+
xcodeproj: XCODE_PROJ,
129+
target: TARGET_NAME
130+
)
131+
latest_testflight_build_number = fetch_latest_testflight_build_number(
132+
api_key: api_key,
133+
version: version_number
134+
)
135+
136+
UI.user_error!("No existing TestFlight build found for #{version_number}") if latest_testflight_build_number <= 0
127137

128138
upload_to_app_store(
129139
api_key: api_key,
140+
app_version: version_number,
141+
build_number: latest_testflight_build_number.to_s,
130142
force: true,
131143
skip_metadata: true,
132144
skip_screenshots: true,
145+
skip_binary_upload: true,
133146
submit_for_review: true,
134147
automatic_release: false
135148
)

0 commit comments

Comments
 (0)