EEYatHo 앱 깎는 이야기

Git ) GithubAction - EEYatHo iOS 본문

Git

Git ) GithubAction - EEYatHo iOS

EEYatHo 2021. 8. 4. 10:46
반응형

나중에 시간 지나서 보면, 잘 할 수 있도록 기록하는 용도.

 

.github/workflows/swift.yml 에 있는 파일로 여러 스크립트나 옵션들 설정 가능.

 

gpg로 필요한 certification 이랑, provision 암호화하고 .github/secrets에 올림.

 

복호화에 필요한 정보는 깃헙액션 옵션에 secrets에 올림.

 

name: Swift

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: macos-latest # macOS 최신버전이서 빌드한다는 뜻

    env:
        XC_VERSION: ${{ '12.5.1' }}
        XC_PROJECT: ${{ 'Nemo.xcworkspace' }}
        XC_SCHEME: ${{ 'Nemo' }}
        XC_ARCHIVE_PATH: ${{ 'Nemo.xcarichive' }}
        XC_EXPORT_PATH: ${{ './artifacts' }}
        KEYCHAIN: ${{ 'test.keychain' }}
        
        DECRYPTED_CERTS_FILE_PATH: ${{ '.github/secrets/distribution.p12' }}
        ENCRYPTED_CERTS_FILE_PATH: ${{ '.github/secrets/distribution.p12.gpg' }}
        DECRYPTED_PROVISION_FILE_PATH: ${{ '.github/secrets/githubAction.mobileprovision' }}
        ENCRYPTED_PROVISION_FILE_PATH: ${{ '.github/secrets/githubAction.mobileprovision.gpg' }}
        CERT_ENCRYPTION_PWD: ${{ secrets.CERT_ENCRYPTION_PWD }}
        PROVISION_ENCRYPTION_PWD: ${{ secrets.PROVISION_ENCRYPTION_PWD }}
        CERT_EXPORT_PWD: ${{ secrets.CERT_EXPORT_PWD }}

    steps:
    - uses: actions/checkout@v2 # 여기에 코드를 복사하여 테스트를 진행
    - name: 임시 키체인 생성 # 작업의 이름
      run: | # 작업 명령어들
        security create-keychain -p "" "$KEYCHAIN"
        security list-keychains -s "$KEYCHAIN"
        security default-keychain -s "$KEYCHAIN"
        security unlock-keychain -p "" "$KEYCHAIN"
        security set-keychain-settings
        
        gpg -d -o "$DECRYPTED_CERTS_FILE_PATH" --pinentry-mode=loopback --passphrase "$CERT_ENCRYPTION_PWD" "$ENCRYPTED_CERTS_FILE_PATH"
        gpg -d -o "$DECRYPTED_PROVISION_FILE_PATH" --pinentry-mode=loopback --passphrase "$PROVISION_ENCRYPTION_PWD" "$ENCRYPTED_PROVISION_FILE_PATH"
        security import "$DECRYPTED_CERTS_FILE_PATH" -k "$KEYCHAIN" -P "$CERT_EXPORT_PWD" -A
        security set-key-partition-list -S apple-tool:,apple: -s -k "" "$KEYCHAIN"
        
        mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles"
        cd ".github/secrets"
        
        echo `ls *.mobileprovision`
        for PROVISION in `ls *.mobileprovision`
        do
            echo Hello, world!
            UUID=`/usr/libexec/PlistBuddy -c 'Print :UUID' /dev/stdin <<< $(security cms -D -i ./$PROVISION)`
            cp "./$PROVISION" "$HOME/Library/MobileDevice/Provisioning Profiles/$UUID.mobileprovision"
        done
    - name: pod install 실행
      run: |
        pod install --repo-update --clean-install
        
    # name 새로 하면, 원래 경로로 초기화됨
    - name: 아카이브 생성
      run: |
        mkdir artifacts
        xcodebuild archive -workspace Nemo.xcworkspace -scheme Nemo -configuration release -archivePath Nemo.xcarchive
    - name: ExportOptions.plist 생성
      run: |
        cat << EOF > ExportOptions.plist
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        
        <plist version="1.0">
        <dict>
            <key>method</key>
            <string>app-store</string>
            <key>teamID</key>
            <string>[teamID]</string>
            <key>uploadBitcode</key>
            <true/>
            <key>compileBitcode</key>
            <true/>
            <key>uploadSymbols</key>
            <true/>
            <key>signingStyle</key>
            <string>manual</string>
            <key>signingCertificate</key>
            <string>Apple Distribution</string>
            <key>provisioningProfiles</key>
            <dict>
                <key>[Bundle ID]</key>
                <string>githubAction</string>
            </dict>
        </dict>
        </plist>
        EOF
    - name: ipa 생성
      run: |
        xcodebuild -exportArchive -archivePath Nemo.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath "$XC_EXPORT_PATH"
    - name: Upload Artifact
      uses: actions/upload-artifact@v2
      with:
        name: Artifacts
        path: ./artifacts

 

 

 

Comments