|
| 1 | +name: macOS Build & Distribute (TestFlight / App Store) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + distribution: |
| 7 | + description: Where to distribute this build |
| 8 | + type: choice |
| 9 | + required: true |
| 10 | + options: [testflight, appstore] |
| 11 | + default: testflight |
| 12 | + |
| 13 | +jobs: |
| 14 | + build_and_ship: |
| 15 | + name: Build & Ship to → ${{ inputs.distribution }} |
| 16 | + runs-on: macos-latest |
| 17 | + |
| 18 | + env: |
| 19 | + KEYCHAIN_NAME: signing-${{ github.run_id }}.keychain-db |
| 20 | + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} |
| 21 | + APP_IDENTIFIER: org.mifospay |
| 22 | + APPSTORE_KEY_ID: ${{ secrets.APPSTORE_KEY_ID }} |
| 23 | + APPSTORE_ISSUER_ID: ${{ secrets.APPSTORE_ISSUER_ID }} |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: ☕ Set up Java 21 (Temurin) |
| 30 | + uses: actions/setup-java@v4 |
| 31 | + with: |
| 32 | + distribution: temurin |
| 33 | + java-version: "21" |
| 34 | + |
| 35 | + - name: Set up Ruby & bundle |
| 36 | + uses: ruby/setup-ruby@v1 |
| 37 | + with: |
| 38 | + bundler-cache: true |
| 39 | + |
| 40 | + - name: Install Fastlane dependencies |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + gem install bundler |
| 44 | + bundler install --jobs 4 --retry 3 |
| 45 | +
|
| 46 | + - name: Create & unlock temporary keychain |
| 47 | + run: | |
| 48 | + security create-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_NAME}" |
| 49 | + security set-keychain-settings -lut 21600 "${KEYCHAIN_NAME}" |
| 50 | + security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_NAME}" |
| 51 | + security list-keychains -d user -s "${KEYCHAIN_NAME}" $(security list-keychains -d user | sed 's/[ "]//g') |
| 52 | +
|
| 53 | + - name: Import Mac App Distribution certificate |
| 54 | + env: |
| 55 | + MAC_APP_DISTRIBUTION_CERTIFICATE_B64: ${{ secrets.MAC_APP_DISTRIBUTION_CERTIFICATE_B64 }} |
| 56 | + CERTIFICATES_PASSWORD: ${{ secrets.CERTIFICATES_PASSWORD }} |
| 57 | + run: | |
| 58 | + CERT="${RUNNER_TEMP}/mac_app_distribution.p12" |
| 59 | + printf '%s' "$MAC_APP_DISTRIBUTION_CERTIFICATE_B64" | base64 -D > "$CERT" |
| 60 | + security import "$CERT" -P "$CERTIFICATES_PASSWORD" -A -t cert -f pkcs12 -k "${KEYCHAIN_NAME}" |
| 61 | + security set-key-partition-list -S apple-tool:,apple: -k "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_NAME}" |
| 62 | + echo "APP_CERTIFICATE_PATH=$CERT" >> "$GITHUB_ENV" |
| 63 | +
|
| 64 | + - name: Import Mac Installer Distribution certificate |
| 65 | + env: |
| 66 | + MAC_INSTALLER_DISTRIBUTION_CERTIFICATE_B64: ${{ secrets.MAC_INSTALLER_DISTRIBUTION_CERTIFICATE_B64 }} |
| 67 | + CERTIFICATES_PASSWORD: ${{ secrets.CERTIFICATES_PASSWORD }} |
| 68 | + run: | |
| 69 | + CERT="${RUNNER_TEMP}/mac_installer_distribution.p12" |
| 70 | + printf '%s' "$MAC_INSTALLER_DISTRIBUTION_CERTIFICATE_B64" | base64 -D > "$CERT" |
| 71 | + security import "$CERT" -P "$CERTIFICATES_PASSWORD" -A -t cert -f pkcs12 -k "${KEYCHAIN_NAME}" |
| 72 | + security set-key-partition-list -S apple-tool:,apple: -k "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_NAME}" |
| 73 | + echo "INSTALLER_CERTIFICATE_PATH=$CERT" >> "$GITHUB_ENV" |
| 74 | +
|
| 75 | + - name: Write Embedded provisioning profile |
| 76 | + env: |
| 77 | + MAC_EMBEDDED_PROVISION_B64: ${{ secrets.MAC_EMBEDDED_PROVISION_B64 }} |
| 78 | + run: | |
| 79 | + mkdir -p cmp-desktop |
| 80 | + echo "$MAC_EMBEDDED_PROVISION_B64" > cmp-desktop/embedded.provisionprofile.b64 |
| 81 | + base64 -d -i cmp-desktop/embedded.provisionprofile.b64 > cmp-desktop/embedded.provisionprofile |
| 82 | +
|
| 83 | + - name: Write Runtime provisioning profile |
| 84 | + env: |
| 85 | + MAC_RUNTIME_PROVISION_B64: ${{ secrets.MAC_RUNTIME_PROVISION_B64 }} |
| 86 | + run: | |
| 87 | + echo "$MAC_RUNTIME_PROVISION_B64" > cmp-desktop/runtime.provisionprofile.b64 |
| 88 | + base64 -d -i cmp-desktop/runtime.provisionprofile.b64 > cmp-desktop/runtime.provisionprofile |
| 89 | +
|
| 90 | + - name: Write App Store Connect API key (.p8) |
| 91 | + env: |
| 92 | + APPSTORE_CONNECT_API_KEY_B64: ${{ secrets.APPSTORE_AUTH_KEY }} |
| 93 | + run: | |
| 94 | + mkdir -p secrets |
| 95 | + echo "$APPSTORE_CONNECT_API_KEY_B64" | base64 --decode > secrets/Auth_key.p8 |
| 96 | +
|
| 97 | + - name: Upload to TestFlight |
| 98 | + if: ${{ inputs.distribution == 'testflight' }} |
| 99 | + run: | |
| 100 | + bundle exec fastlane mac desktop_testflight \ |
| 101 | + app_identifier:"$APP_IDENTIFIER" \ |
| 102 | + appstore_key_id:"$APPSTORE_KEY_ID" \ |
| 103 | + appstore_issuer_id:"$APPSTORE_ISSUER_ID" \ |
| 104 | + key_file_path:secrets/Auth_key.p8 |
| 105 | +
|
| 106 | + - name: Submit to App Store (Production) |
| 107 | + if: ${{ inputs.distribution == 'appstore' }} |
| 108 | + run: | |
| 109 | + bundle exec fastlane mac desktop_release \ |
| 110 | + app_identifier:"$APP_IDENTIFIER" \ |
| 111 | + appstore_key_id:"$APPSTORE_KEY_ID" \ |
| 112 | + appstore_issuer_id:"$APPSTORE_ISSUER_ID" \ |
| 113 | + key_file_path:secrets/Auth_key.p8 |
0 commit comments