|
1 | | -# This workflow will build a Swift project |
2 | | -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift |
3 | | - |
4 | | -name: appstore-release |
| 1 | +name: App Store Release |
5 | 2 |
|
6 | 3 | on: |
7 | 4 | pull_request: |
8 | 5 | branches: |
9 | 6 | - main |
| 7 | + types: |
| 8 | + - closed |
| 9 | + |
| 10 | + workflow_dispatch: |
10 | 11 |
|
11 | 12 | jobs: |
12 | | - build: |
| 13 | + deploy: |
| 14 | + if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }} |
13 | 15 | runs-on: macos-26 |
| 16 | + timeout-minutes: 120 |
| 17 | + |
| 18 | + env: |
| 19 | + # App Store Connect |
| 20 | + APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} |
| 21 | + APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} |
| 22 | + APP_STORE_CONNECT_API: ${{ secrets.APP_STORE_CONNECT_API }} |
| 23 | + |
| 24 | + # Team IDs |
| 25 | + DEVELOPMENT_TEAM: ${{ secrets.DEVELOPMENT_TEAM }} |
| 26 | + APP_STORE_CONNECT_TEAM_ID: ${{ secrets.APP_STORE_CONNECT_TEAM_ID }} |
| 27 | + |
| 28 | + # Match (Code Signing) |
| 29 | + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} |
| 30 | + MATCH_KEYCHAIN_NAME: fastlane_tmp.keychain-db |
| 31 | + MATCH_GIT_PRIVATE_KEY: ${{ secrets.MATCH_GIT_PRIVATE_KEY }} |
| 32 | + |
| 33 | + # Review Information |
| 34 | + DEMO_USER: ${{ secrets.DEMO_USER }} |
| 35 | + DEMO_PASSWORD: ${{ secrets.DEMO_PASSWORD }} |
| 36 | + PHONE_NUMBER: ${{ secrets.PHONE_NUMBER }} |
| 37 | + |
| 38 | + # Fastlane |
| 39 | + FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT: '120' |
| 40 | + FASTLANE_XCODE_LIST_TIMEOUT: '120' |
| 41 | + FASTLANE_DISABLE_COLORS: 'true' |
14 | 42 |
|
15 | 43 | steps: |
16 | | - - uses: actions/checkout@v4 |
17 | | - |
18 | | - - name: Set up Xcode |
19 | | - uses: maxim-lobanov/setup-xcode@v1 |
20 | | - with: |
21 | | - xcode-version: latest-stable |
22 | | - |
23 | | - - uses: shimataro/ssh-key-action@v2 |
24 | | - with: |
25 | | - key: ${{ secrets.SSH_KEY }} |
26 | | - known_hosts: ${{ secrets.KNOWN_HOSTS }} |
27 | | - |
28 | | - - name: initial mise |
29 | | - run: | |
30 | | - curl https://mise.jdx.dev/install.sh | sh |
31 | | - echo "$HOME/.local/share/mise/bin" >> $GITHUB_PATH |
32 | | - echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH |
33 | | -
|
34 | | - - name: initial tuist |
35 | | - run: mise install tuist |
36 | | - |
37 | | - - name: Generate Project |
38 | | - env: |
39 | | - MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} |
40 | | - DEVELOPMENT_TEAM: ${{ secrets.DEVELOPMENT_TEAM }} |
41 | | - run: | |
42 | | - fastlane appstore_profile |
43 | | - make release |
44 | | -
|
45 | | - - name: Build Archive |
46 | | - env: |
47 | | - APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} |
48 | | - APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} |
49 | | - APP_STORE_CONNECT_API: ${{ secrets.APP_STORE_CONNECT_API }} |
50 | | - run: fastlane archive |
51 | | - |
52 | | - - name: Appstore Release |
53 | | - env: |
54 | | - APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} |
55 | | - APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} |
56 | | - APP_STORE_CONNECT_API: ${{ secrets.APP_STORE_CONNECT_API }} |
57 | | - run: fastlane appstore_release |
| 44 | + - name: Checkout code |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Set up Xcode |
| 48 | + uses: maxim-lobanov/setup-xcode@v1 |
| 49 | + with: |
| 50 | + xcode-version: latest-stable |
| 51 | + |
| 52 | + - name: Setup Ruby |
| 53 | + uses: ruby/setup-ruby@v1 |
| 54 | + with: |
| 55 | + ruby-version: '3.3' |
| 56 | + bundler-cache: true |
| 57 | + |
| 58 | + - name: Setup SSH for Match |
| 59 | + if: env.MATCH_GIT_PRIVATE_KEY != '' |
| 60 | + run: | |
| 61 | + mkdir -p "$HOME/.ssh" |
| 62 | + echo "$MATCH_GIT_PRIVATE_KEY" > "$HOME/.ssh/match_git_key" |
| 63 | + chmod 600 "$HOME/.ssh/match_git_key" |
| 64 | +
|
| 65 | + eval "$(ssh-agent -s)" |
| 66 | + ssh-add "$HOME/.ssh/match_git_key" |
| 67 | + ssh-keyscan -H github.com >> "$HOME/.ssh/known_hosts" |
| 68 | +
|
| 69 | + cat >> "$HOME/.ssh/config" << EOF |
| 70 | + Host github.com |
| 71 | + IdentityFile ~/.ssh/match_git_key |
| 72 | + StrictHostKeyChecking yes |
| 73 | + User git |
| 74 | + EOF |
| 75 | +
|
| 76 | + - name: Setup SSH for Private repo |
| 77 | + uses: shimataro/ssh-key-action@v2 |
| 78 | + with: |
| 79 | + key: ${{ secrets.SSH_KEY }} |
| 80 | + known_hosts: ${{ secrets.KNOWN_HOSTS }} |
| 81 | + |
| 82 | + - name: Setup keychain |
| 83 | + if: env.MATCH_PASSWORD != '' |
| 84 | + run: | |
| 85 | + security create-keychain -p "$MATCH_PASSWORD" "$MATCH_KEYCHAIN_NAME" |
| 86 | + security set-keychain-settings -lut 21600 "$MATCH_KEYCHAIN_NAME" |
| 87 | + security unlock-keychain -p "$MATCH_PASSWORD" "$MATCH_KEYCHAIN_NAME" |
| 88 | +
|
| 89 | + existing_keychains=$(security list-keychains | tr -d '"') |
| 90 | + security list-keychains -s "$MATCH_KEYCHAIN_NAME" $existing_keychains |
| 91 | + security default-keychain -s "$MATCH_KEYCHAIN_NAME" |
| 92 | +
|
| 93 | + - name: Setup mise |
| 94 | + run: | |
| 95 | + curl https://mise.jdx.dev/install.sh | sh |
| 96 | + echo "$HOME/.local/share/mise/bin" >> $GITHUB_PATH |
| 97 | + echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH |
| 98 | +
|
| 99 | + - name: Install Tuist |
| 100 | + run: mise install tuist |
| 101 | + |
| 102 | + - name: Setup code signing |
| 103 | + run: bundle exec fastlane appstore_profile |
| 104 | + |
| 105 | + - name: Generate project with Tuist |
| 106 | + run: make release |
| 107 | + |
| 108 | + - name: Update release notes from PR description |
| 109 | + env: |
| 110 | + GH_TOKEN: ${{ github.token }} |
| 111 | + run: | |
| 112 | + PR_BODY=$(gh pr view ${{ github.event.pull_request.number }} --json body --jq '.body') |
| 113 | +
|
| 114 | + if [ -z "$PR_BODY" ]; then |
| 115 | + echo "버그 수정 및 성능 개선" > fastlane/release_notes.txt |
| 116 | + else |
| 117 | + echo "$PR_BODY" > fastlane/release_notes.txt |
| 118 | + fi |
| 119 | +
|
| 120 | + echo "Release notes updated:" |
| 121 | + cat fastlane/release_notes.txt |
| 122 | +
|
| 123 | + - name: Build archive |
| 124 | + run: bundle exec fastlane archive |
| 125 | + |
| 126 | + - name: Submit to App Store |
| 127 | + run: bundle exec fastlane appstore_release |
| 128 | + |
| 129 | + - name: Get app version |
| 130 | + id: version |
| 131 | + run: | |
| 132 | + VERSION=$(xcodebuild -project Projects/App/App.xcodeproj -showBuildSettings | grep MARKETING_VERSION | head -1 | awk '{print $3}') |
| 133 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 134 | +
|
| 135 | + - name: Create Git tag and Release draft |
| 136 | + env: |
| 137 | + GH_TOKEN: ${{ github.token }} |
| 138 | + run: | |
| 139 | + VERSION="${{ steps.version.outputs.version }}" |
| 140 | + TAG="v$VERSION" |
| 141 | +
|
| 142 | + # 태그 생성 |
| 143 | + git config user.name "github-actions[bot]" |
| 144 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 145 | + git tag -a "$TAG" -m "Release $VERSION" |
| 146 | + git push origin "$TAG" |
| 147 | +
|
| 148 | + # Release draft 생성 |
| 149 | + PR_BODY=$(gh pr view ${{ github.event.pull_request.number }} --json body --jq '.body') |
| 150 | + if [ -z "$PR_BODY" ]; then |
| 151 | + RELEASE_NOTES="버그 수정 및 성능 개선" |
| 152 | + else |
| 153 | + RELEASE_NOTES="$PR_BODY" |
| 154 | + fi |
| 155 | +
|
| 156 | + gh release create "$TAG" \ |
| 157 | + --title "Release $VERSION" \ |
| 158 | + --notes "$RELEASE_NOTES" \ |
| 159 | + --draft |
| 160 | +
|
| 161 | + - name: Upload logs on failure |
| 162 | + if: failure() |
| 163 | + uses: actions/upload-artifact@v4 |
| 164 | + with: |
| 165 | + name: xcode-logs |
| 166 | + path: | |
| 167 | + ~/Library/Logs/gym |
| 168 | + ~/Library/Developer/Xcode/DerivedData |
| 169 | + /Users/runner/Library/Developer/Xcode/Archives |
| 170 | + if-no-files-found: ignore |
| 171 | + retention-days: 3 |
| 172 | + |
| 173 | + - name: Cleanup |
| 174 | + if: always() |
| 175 | + run: | |
| 176 | + # SSH cleanup |
| 177 | + if [ -n "$MATCH_GIT_PRIVATE_KEY" ]; then |
| 178 | + ssh-add -D >/dev/null 2>&1 || true |
| 179 | + rm -f "$HOME/.ssh/match_git_key" |
| 180 | + fi |
| 181 | +
|
| 182 | + # Keychain cleanup |
| 183 | + if [ -n "$MATCH_PASSWORD" ]; then |
| 184 | + security delete-keychain "$MATCH_KEYCHAIN_NAME" 2>/dev/null || true |
| 185 | + fi |
0 commit comments