Skip to content

Commit

Permalink
Merge pull request #1088 from get10101/feat/release-testflight-regtes…
Browse files Browse the repository at this point in the history
…t-on-each-push-to-master

feat: release regtest ios app on push to main using fastlane
  • Loading branch information
bonomat authored Aug 14, 2023
2 parents 529938b + 57d1a2e commit 3bf33e3
Show file tree
Hide file tree
Showing 14 changed files with 647 additions and 22 deletions.
16 changes: 16 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,19 @@ ESPLORA_ENDPOINT=http://35.189.57.114:3000
COORDINATOR_P2P_ENDPOINT=03507b924dae6595cfb78492489978127c5f1e3877848564de2015cd6d41375802@35.189.57.114:9045
COORDINATOR_PORT_HTTP=80
NETWORK=regtest

# Fastlane variables
FASTLANE_DEVELOPER_APP_ID="1234567890"
FASTLANE_DEVELOPER_APP_IDENTIFIER="finance.get10101.app"
FASTLANE_PROVISIONING_PROFILE_SPECIFIER="sample"
#FASTLANE_APP_SCHEME="Runner"
FASTLANE_APP_SCHEME="test" # or "Runner"
FASTLANE_APPLE_ID="[email protected]"
FASTLANE_TEMP_KEYCHAIN_USER="[email protected]"
FASTLANE_TEMP_KEYCHAIN_PASSWORD="some-random-password"
FASTLANE_APPLE_ISSUER_ID="12234124-1111-2222-3333-444444444444"
FASTLANE_APPLE_KEY_ID="123456678"
FASTLANE_APPLE_KEY_CONTENT="-----BEGIN PRIVATE KEY-----\....\n-----END PRIVATE KEY-----"
FASTLANE_GIT_AUTHORIZATION="username:github_token"
FASTLANE_APP_STORE_CONNECT_TEAM_ID=123456789
FASTLANE_DEVELOPER_PORTAL_TEAM_ID=1234567890
6 changes: 4 additions & 2 deletions .github/workflows/build-release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
with:
tag: ${{ github.ref_name }}

build_testflight_release:
build_and_release_mainnet_ios_app_for_latest_main:
permissions:
packages: write
contents: read
uses: ./.github/workflows/ios.yml
uses: ./.github/workflows/ios-fastlane.yml
secrets: inherit
with:
esplora_endpoint: https://blockstream.info/api
Expand All @@ -32,6 +32,8 @@ jobs:
tag: ${{ github.ref_name }}
oracle_endpoint: https://oracle.holzeis.me
oracle_pubkey: 16f88cf7d21e6c0f46bcbc983a4e3b19726c6c98858cc31c83551a88fde171c0
fastlane_developer_app_identifier: finance.get10101.app
fastlane_provisioning_profile_specifier: match AppStore finance.get10101.app 1691412333"

build_android_apk:
runs-on: macos-latest
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/deliverables-push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ jobs:
- 'mobile/**'
- 'Cargo.*'
build_and_release_ios_app_for_latest_main:
build_and_release_regtest_ios_app_for_latest_main:
needs: changes
if: needs.changes.outputs.ios-app == 'true' && contains(github.event.head_commit.message, 'release') == 'false' && contains(github.event.head_commit.message, 'Merge') == 'false'
if: needs.changes.outputs.ios-app == 'true'
permissions:
packages: write
contents: read
uses: ./.github/workflows/ios.yml
uses: ./.github/workflows/ios-fastlane.yml
secrets: inherit
with:
esplora_endpoint: https://blockstream.info/api
esplora_endpoint: http://35.189.57.114:3000
coordinator_p2p_endpoint: 03507b924dae6595cfb78492489978127c5f1e3877848564de2015cd6d41375802@35.189.57.114:9045
coordinator_port_http: 80
network: regtest
tag: main
oracle_endpoint: http://api.test.10101.finance:8081
oracle_pubkey: 5d12d79f575b8d99523797c46441c0549eb0defb6195fe8a080000cbe3ab3859
fastlane_developer_app_identifier: finance.get10101.app.test
fastlane_provisioning_profile_specifier: match AppStore finance.get10101.app.test
169 changes: 169 additions & 0 deletions .github/workflows/ios-fastlane.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
name: "Fastlane: Build and release ios app to TestFlight"

on:
workflow_call:
inputs:
coordinator_port_http:
required: true
type: string
esplora_endpoint:
required: true
type: string
coordinator_p2p_endpoint:
required: true
type: string
network:
required: true
type: string
description: "The target network for the release, e.g. mainnet/regtest"
tag:
required: true
description: "The branch, tag or SHA to checkout."
type: string
oracle_endpoint:
required: true
type: string
oracle_pubkey:
required: true
description: "The public key of the oracle. Must match with the public key returned at http://${oracle_endpoint}/oracle/publickey"
type: string
fastlane_provisioning_profile_specifier:
required: true
description: "For regtest enter 'match AppStore finance.get10101.app.test' or mainnet enter 'match AppStore finance.get10101.app 1691412333'"
type: string
fastlane_developer_app_identifier:
required: true
description: "For regtest enter 'finance.get10101.app.test' or mainnet enter 'finance.get10101.app'"
type: string
workflow_dispatch:
inputs:
coordinator_port_http:
required: true
type: string
esplora_endpoint:
required: true
type: string
coordinator_p2p_endpoint:
required: true
type: string
network:
required: true
type: string
description: "The target network for the release, e.g. mainnet/regtest"
tag:
required: true
description: "The branch, tag or SHA to checkout."
type: string
oracle_endpoint:
required: true
type: string
oracle_pubkey:
required: true
description: "The public key of the oracle. Must match with the public key returned at http://${oracle_endpoint}/oracle/publickey"
type: string

jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
# fetch the complete history to correctly calculate build_number
fetch-depth: 0
ref: ${{ inputs.tag }}

- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "14.2"

- uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version: ${{ env.FLUTTER_VERSION }}
architecture: x64

- uses: actions/cache@v3
id: cache-deps
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./rust/target
key: ${{ runner.os }}-cargo-build-release-ios-${{ hashFiles('**/Cargo.lock') }}

- name: Install just
if: steps.cache-deps.outputs.cache-hit != 'true'
run: cargo install just

- name: Install fastlane
run: |
cd mobile/ios/fastlane
gem install bundler
bundle install
bundle info fastlane
- name: Install FFI bindings
if: steps.cache-deps.outputs.cache-hit != 'true'
run: just deps-gen

- name: Install ios dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: cargo install cargo-lipo

- name: Set rustup targets
run: rustup target add aarch64-apple-ios x86_64-apple-ios

- name: Generate FFI bindings
run: just gen

- name: Build iOS Rust lib in release mode
run: just ios-release

- name: Parse version from pubspec.yaml
id: version
uses: jbutcher5/[email protected]
with:
file: "mobile/pubspec.yaml"
key-path: '["version"]'

- name: Build iOS Archive
id: build-ios
run: |
NETWORK=$NETWORK just build-ipa-no-codesign
env:
ESPLORA_ENDPOINT: ${{ inputs.esplora_endpoint }}
COORDINATOR_P2P_ENDPOINT: ${{ inputs.coordinator_p2p_endpoint }}
NETWORK: ${{ inputs.network }}
COORDINATOR_PORT_HTTP: ${{ inputs.coordinator_port_http }}
ORACLE_ENDPOINT: ${{ inputs.oracle_endpoint }}
ORACLE_PUBKEY: ${{ inputs.oracle_pubkey }}

- name: Release to TestFlight
env:
# secrets
FASTLANE_APPLE_ID: ${{ secrets.FASTLANE_APPLE_ID }}
FASTLANE_APP_STORE_CONNECT_TEAM_ID: ${{ secrets.FASTLANE_APP_STORE_CONNECT_TEAM_ID }}
FASTLANE_DEVELOPER_PORTAL_TEAM_ID: ${{ secrets.FASTLANE_DEVELOPER_PORTAL_TEAM_ID }}
FASTLANE_DEVELOPER_APP_ID: ${{ secrets.FASTLANE_DEVELOPER_APP_ID }}
FASTLANE_TEMP_KEYCHAIN_USER: ${{ secrets.FASTLANE_TEMP_KEYCHAIN_USER }}
FASTLANE_TEMP_KEYCHAIN_PASSWORD: ${{ secrets.FASTLANE_TEMP_KEYCHAIN_PASSWORD }}
FASTLANE_APPLE_ISSUER_ID: ${{ secrets.FASTLANE_APPLE_ISSUER_ID }}
FASTLANE_APPLE_KEY_ID: ${{ secrets.FASTLANE_APPLE_KEY_ID }}
FASTLANE_APPLE_KEY_CONTENT: ${{ secrets.FASTLANE_APPLE_KEY_CONTENT }}
FASTLANE_GIT_AUTHORIZATION: ${{ secrets.FASTLANE_GIT_AUTHORIZATION }}
MATCH_PASSWORD: ${{ secrets.FASTLANE_MATCH_PASSWORD }}
# inputs
FASTLANE_DEVELOPER_APP_IDENTIFIER: ${{ inputs.fastlane_developer_app_identifier }}
FASTLANE_PROVISIONING_PROFILE_SPECIFIER: ${{ inputs.fastlane_provisioning_profile_specifier }}
NETWORK: ${{ inputs.network }}
run: |
if [ "$NETWORK" = "mainnet" ]; then
FASTLANE_APP_SCHEME="Runner"
else
FASTLANE_APP_SCHEME="test"
fi
echo "APP_SCHEME is set to $FASTLANE_APP_SCHEME"
just publish-testflight-fastlane
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ data/**

# prometheus data
services/prometheus/data

# fastlane generated files
10101.app.dSYM.zip
10101.ipa
mobile/ios/build
mobile/ios/fastlane/report.xml
mobile/ios/fastlane/README.md
19 changes: 19 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,22 @@ just release-testflight
```

Once uploaded, log into `appstoreconnect.apple.com/apps/` and approve testing the new version.

## Using fastlane

Make sure that all environment variables are set in the `.env` file.

You will also need to install [`fastlane`](https://fastlane.tools/).

1. We need to build the IPA file first without code signing because fastlane does not support `--dart-define`.
Building the IPA file adds some overheads but ensures that these variables are set.

```bash
just build-ipa-no-codesign
```

2. Execute fastlane to build a signed IPA file and upload to Testflight

```bash
just publish-testflight-fastlane
```
10 changes: 8 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ wait-for-coordinator-to-be-ready:
echo "Max attempts reached. Coordinator is still not ready."
exit 1

build-ipa:
build-ipa args="":
#!/usr/bin/env bash
BUILD_NUMBER=$(git rev-list HEAD --count)
args=()
Expand All @@ -344,11 +344,17 @@ build-ipa:
--dart-define="COMMIT=$(git rev-parse HEAD)" \
--dart-define="BRANCH=$(git rev-parse --abbrev-ref HEAD)" \
--dart-define="COORDINATOR_PORT_HTTP=${COORDINATOR_PORT_HTTP}" \
--build-number=${BUILD_NUMBER}
--build-number=${BUILD_NUMBER} \
{{args}}

publish-testflight:
cd mobile && xcrun altool --upload-app --type ios --file ./build/ios/ipa/10101.ipa --apiKey ${ALTOOL_API_KEY} --apiIssuer ${ALTOOL_API_ISSUER}

build-ipa-no-codesign: (build-ipa "--no-codesign")

publish-testflight-fastlane:
cd mobile/ios/fastlane && bundle exec fastlane closed_beta --verbose

release-testflight: gen ios build-ipa publish-testflight

version:
Expand Down
Loading

0 comments on commit 3bf33e3

Please sign in to comment.