Generate Test React STG #204
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate Test React STG | |
env: | |
DEVELOPER_DIR: /Applications/Xcode_15.0.1.app/Contents/Developer | |
on: | |
workflow_dispatch: | |
inputs: | |
ref: | |
default: main | |
description: "Git Tag, Branch or SHA to build" | |
required: true | |
secrets: | |
BUILD_USER_PAT: | |
required: true | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
secrets: | |
BUILD_USER_PAT: | |
required: true | |
jobs: | |
build-android-stg: | |
name: Generate Play Store STG | |
permissions: | |
actions: write | |
contents: write | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: 'Checkout ${{ inputs.ref }}' | |
uses: actions/checkout@v2 | |
with: | |
path: source | |
ref: '${{ inputs.ref }}' | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
cache: gradle | |
distribution: temurin | |
java-version: 17 | |
- name: Install Google API python client | |
run: | | |
pip install google-api-python-client | |
- name: Get new version code | |
run: | | |
echo $GOOGLE_PLAY_SERVICE_ACCOUNT > $RUNNER_TEMP/.service_account | |
python3 build-utils/get_version_code.py $RUNNER_TEMP/.service_account com.namiml.stg.testreactnative internal --quiet >> $RUNNER_TEMP/.new_version_code | |
rm -f .service_account | |
env: | |
GOOGLE_PLAY_SERVICE_ACCOUNT: '${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT }}' | |
working-directory: source | |
- name: Update version code | |
working-directory: source/examples/Basic/android/app | |
run: | | |
NEW_VERSION_CODE=`cat $RUNNER_TEMP/.new_version_code` | |
echo $NEW_VERSION_CODE | |
sed -i "s/versionCode 1/versionCode $NEW_VERSION_CODE/" build.gradle | |
- name: Update App Platform ID | |
working-directory: source/examples/Basic/config/ | |
run: | | |
sed -i "s/ANDROID_STG_APP_PLATFORM_ID/$BASIC_ANDROID_STG_APP_PLATFORM_ID/" index.ts | |
env: | |
BASIC_ANDROID_STG_APP_PLATFORM_ID: '${{ secrets.ANDROID_STG_APP_PLATFORM_ID }}' | |
- name: Create the Keystore | |
run: | | |
# import keystore from secrets | |
echo $KEYSTORE_BASE64 | base64 -d > $RUNNER_TEMP/my_production.keystore | |
env: | |
KEYSTORE_BASE64: '${{ secrets.KEY_STORE_BASE64 }}' | |
- name: Install test app dependencies | |
run: | | |
yarn install | |
working-directory: source/examples/Basic | |
- name: Manually create the bundle | |
run: | | |
mkdir -p android/app/src/main/assets/ | |
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle | |
working-directory: source/examples/Basic | |
- name: Build Android App Bundle | |
run: | | |
./gradlew clean bundleStagingRelease | |
working-directory: source/examples/Basic/android | |
- name: Sign Android App Bundle | |
run: | | |
jarsigner -keystore $RUNNER_TEMP/my_production.keystore -storepass '${{ secrets.KEY_STORE_PASSWORD }}' -keypass '${{ secrets.KEY_PASSWORD }}' -sigalg SHA256withRSA -digestalg SHA-256 -signedjar build/outputs/bundle/stagingRelease/app-staging-release-signed.aab build/outputs/bundle/stagingRelease/app-staging-release.aab '${{ secrets.KEY_ALIAS }}' | |
working-directory: source/examples/Basic/android/app | |
- name: Uploading to test track | |
uses: r0adkll/[email protected] | |
with: | |
packageName: 'com.namiml.stg.testreactnative' | |
releaseFiles: source/examples/Basic/android/app/build/outputs/bundle/stagingRelease/app-staging-release-signed.aab | |
serviceAccountJsonPlainText: '${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT }}' | |
status: completed | |
track: internal | |
build-ios-stg: | |
name: Generate Apple STG | |
permissions: | |
actions: write | |
contents: write | |
id-token: write | |
runs-on: macos-13 | |
timeout-minutes: 40 | |
steps: | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: "Checkout ${{ inputs.ref }}" | |
uses: actions/checkout@v2 | |
with: | |
path: source | |
ref: "${{ inputs.ref }}" | |
- name: Checkout appstoreconnect-build-tools | |
uses: actions/checkout@v2 | |
with: | |
path: appstoreconnect-build-tools | |
ref: main | |
repository: namiml/appstoreconnect-build-tools | |
- name: Set up Python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: "3.10" | |
- name: Get expected build number | |
run: | | |
pip3 install requests | |
pip3 install pydantic==1.10.11 | |
pip3 install cryptography | |
pip3 install PyJWT | |
echo "1.0" > $RUNNER_TEMP/.current_version | |
export CURRENT_VERSION=`cat $RUNNER_TEMP/.current_version` | |
python3 get_next_build.py com.namiml.stg.testreactnative --prerelease --version=$CURRENT_VERSION --platform=IOS > $RUNNER_TEMP/.next_build_number | |
working-directory: appstoreconnect-build-tools | |
env: | |
APPSTORE_API_KEY_ID: "${{ secrets.APPSTORE_API_KEY_ID }}" | |
APPSTORE_API_PRIVATE_KEY: "${{ secrets.APPSTORE_API_PRIVATE_KEY }}" | |
APPSTORE_ISSUER_ID: "${{ secrets.APPSTORE_ISSUER_ID }}" | |
- name: Install Apple Certificate | |
uses: apple-actions/import-codesign-certs@v1 | |
with: | |
p12-file-base64: "${{ secrets.IOS_P12_BASE64 }}" | |
p12-password: "${{ secrets.IOS_CERTIFICATE_PASSWORD }}" | |
- name: Install the provisioning profile | |
run: | | |
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | |
echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode -o $PP_PATH | |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | |
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles | |
env: | |
PROVISIONING_CERTIFICATE_BASE64: "${{ secrets.IOS_MOBILE_PROVISION_BASE64_TEST_REACT_STG }}" | |
- name: Store App Store Private Key | |
run: | | |
mkdir ~/.private_keys | |
echo '${{ secrets.APPSTORE_API_PRIVATE_KEY }}' > ~/.private_keys/AuthKey_'${{ secrets.APPSTORE_API_KEY_ID }}'.p8 | |
- name: Update ExportOptions.plist | |
run: | | |
sed -i '' -e "s/APPSTORE_TEAM_ID/${{ secrets.APPSTORE_TEAM_ID }}/" ExportOptions.plist | |
sed -i '' -e "s/APPSTORE_PROVISIONING_PROFILE_UUID/${{ secrets.APPSTORE_PROV_PROFILE_UUID_TEST_REACT_STG }}/g" ExportOptions.plist | |
working-directory: source/examples/Basic/ios | |
- name: Adjust version & build number | |
run: |- | |
export CURRENT_VERSION=`cat $RUNNER_TEMP/.current_version` | |
export BUILD_NUMBER=`cat $RUNNER_TEMP/.next_build_number` | |
sed -i '' -e "s/CURRENT_PROJECT_VERSION = 1/CURRENT_PROJECT_VERSION = $BUILD_NUMBER/" ios/Basic.xcodeproj/project.pbxproj | |
sed -i '' -e "s/MARKETING_VERSION = 1.0/MARKETING_VERSION = $CURRENT_VERSION/" ios/Basic.xcodeproj/project.pbxproj | |
sed -i '' -e "s/<string>1<\/string>/<string>$BUILD_NUMBER<\/string>/" ios/Basic/Info.plist | |
working-directory: source/examples/Basic | |
- name: Install test app dependencies | |
run: | | |
yarn install | |
working-directory: source/examples/Basic | |
- name: Update App Platform ID | |
working-directory: source/examples/Basic/config/ | |
run: | | |
sed -i '' -e "s/APPLE_STG_APP_PLATFORM_ID/$BASIC_APPLE_STG_APP_PLATFORM_ID/" index.ts | |
env: | |
BASIC_APPLE_STG_APP_PLATFORM_ID: '${{ secrets.APPLE_STG_APP_PLATFORM_ID }}' | |
- name: Install test iOS dependencies | |
run: | | |
pod install --repo-update | |
working-directory: source/examples/Basic/ios | |
# - name: Apply Patches | |
# run: | | |
# patch -p0 < *.patch | |
# working-directory: source/examples/Basic/patches | |
- name: Build resolve Swift dependencies | |
run: | | |
xcodebuild -resolvePackageDependencies -workspace ios/Basic.xcworkspace -scheme Basic -configuration Release | |
working-directory: source/examples/Basic | |
- name: Build xArchive | |
run: | | |
xcodebuild -workspace ios/Basic.xcworkspace -scheme Basic -configuration Release DEVELOPMENT_TEAM='${{ secrets.APPSTORE_TEAM_ID }}' -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app-stg.xcarchive PROVISIONING_PROFILE='${{ secrets.APPSTORE_PROV_PROFILE_UUID_TEST_REACT_STG }}' clean archive CODE_SIGN_IDENTITY='${{ secrets.CODE_SIGNING_IDENTITY }}' | |
working-directory: source/examples/Basic | |
- name: Export IPA | |
run: | | |
xcodebuild -exportArchive -archivePath build-output/app-stg.xcarchive -exportPath build-output/ios-stg -exportOptionsPlist ios/ExportOptions.plist | |
working-directory: source/examples/Basic | |
- name: Upload app to TestFlight | |
run: | | |
xcrun altool --upload-app --type ios --file build-output/ios-stg/Basic.ipa --apiKey $APPSTORE_API_KEY_ID --apiIssuer $APPSTORE_ISSUER_ID | |
working-directory: source/examples/Basic | |
env: | |
APPSTORE_API_KEY_ID: "${{ secrets.APPSTORE_API_KEY_ID }}" | |
APPSTORE_ISSUER_ID: "${{ secrets.APPSTORE_ISSUER_ID }}" | |
build-tvos-stg: | |
name: Build TestNamiTV tvOS STG | |
permissions: | |
actions: write | |
contents: write | |
id-token: write | |
runs-on: macos-13 | |
timeout-minutes: 40 | |
steps: | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: "Checkout ${{ inputs.ref }}" | |
uses: actions/checkout@v2 | |
with: | |
path: source | |
ref: "${{ inputs.ref }}" | |
- name: Checkout appstoreconnect-build-tools | |
uses: actions/checkout@v2 | |
with: | |
path: appstoreconnect-build-tools | |
ref: main | |
repository: namiml/appstoreconnect-build-tools | |
- name: Set up Python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: "3.10" | |
- name: Get expected build number | |
run: | | |
pip3 install requests | |
pip3 install pydantic==1.10.11 | |
pip3 install cryptography | |
pip3 install PyJWT | |
echo "1.0" > $RUNNER_TEMP/.current_version | |
export CURRENT_VERSION=`cat $RUNNER_TEMP/.current_version` | |
python3 get_next_build.py com.namiml.stg.testreactnative --prerelease --platform=TV_OS > $RUNNER_TEMP/.next_build_number | |
working-directory: appstoreconnect-build-tools | |
env: | |
APPSTORE_API_KEY_ID: "${{ secrets.APPSTORE_API_KEY_ID }}" | |
APPSTORE_API_PRIVATE_KEY: "${{ secrets.APPSTORE_API_PRIVATE_KEY }}" | |
APPSTORE_ISSUER_ID: "${{ secrets.APPSTORE_ISSUER_ID }}" | |
- name: Install Apple Certificate | |
uses: apple-actions/import-codesign-certs@v1 | |
with: | |
p12-file-base64: "${{ secrets.IOS_P12_BASE64 }}" | |
p12-password: "${{ secrets.IOS_CERTIFICATE_PASSWORD }}" | |
- name: Install the provisioning profile | |
run: | | |
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision | |
echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode -o $PP_PATH | |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles | |
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles | |
env: | |
PROVISIONING_CERTIFICATE_BASE64: "${{ secrets.IOS_MOBILE_PROVISION_BASE64_TEST_REACT_TVOS_STG }}" | |
- name: Store App Store Private Key | |
run: | | |
mkdir ~/.private_keys | |
echo '${{ secrets.APPSTORE_API_PRIVATE_KEY }}' > ~/.private_keys/AuthKey_'${{ secrets.APPSTORE_API_KEY_ID }}'.p8 | |
- name: Update ExportOptions.plist | |
run: | | |
sed -i '' -e "s/APPSTORE_TEAM_ID/${{ secrets.APPSTORE_TEAM_ID }}/" ExportOptions.plist | |
sed -i '' -e "s/APPSTORE_PROVISIONING_PROFILE_UUID/${{ secrets.APPSTORE_PROV_PROFILE_UUID_TEST_REACT_TVOS_STG }}/g" ExportOptions.plist | |
working-directory: source/examples/TestNamiTV/ios | |
- name: Adjust version & build number | |
run: |- | |
export CURRENT_VERSION=`cat $RUNNER_TEMP/.current_version` | |
export BUILD_NUMBER=`cat $RUNNER_TEMP/.next_build_number` | |
sed -i '' -e "s/CURRENT_PROJECT_VERSION = 1/CURRENT_PROJECT_VERSION = $BUILD_NUMBER/" ios/Basic.xcodeproj/project.pbxproj | |
sed -i '' -e "s/MARKETING_VERSION = 1.0/MARKETING_VERSION = $CURRENT_VERSION/" ios/Basic.xcodeproj/project.pbxproj | |
sed -i '' -e "s/<string>1<\/string>/<string>$BUILD_NUMBER<\/string>/" ios/Info-STG.plist | |
working-directory: source/examples/TestNamiTV | |
- name: Install test app dependencies | |
run: | | |
yarn install | |
working-directory: source/examples/TestNamiTV | |
- name: Update App Platform ID | |
working-directory: source/examples/TestNamiTV/config/ | |
run: | | |
sed -i '' -e "s/APPLE_STAGE_APP_PLATFORM_ID/$TESTNAMITV_APPLE_STG_APP_PLATFORM_ID/" index.ts | |
env: | |
TESTNAMITV_APPLE_STG_APP_PLATFORM_ID: '${{ secrets.APPLE_STG_APP_PLATFORM_ID }}' | |
- name: Install test tvOS dependencies | |
run: | | |
RCT_NEW_ARCH_ENABLED=0 SWIFT_VERSION=5 pod install --repo-update | |
working-directory: source/examples/TestNamiTV/ios | |
# - name: Apply Patches | |
# run: | | |
# patch -p0 < *.patch | |
# working-directory: source/examples/TestNamiTV/patches | |
- name: Build resolve Swift dependencies | |
run: | | |
xcodebuild -resolvePackageDependencies -workspace ios/Basic.xcworkspace -scheme Basic-tvOS -configuration Release | |
working-directory: source/examples/TestNamiTV | |
- name: Build xArchive | |
run: | | |
xcodebuild -workspace ios/Basic.xcworkspace -scheme Basic-tvOS -configuration Release DEVELOPMENT_TEAM='${{ secrets.APPSTORE_TEAM_ID }}' -sdk 'appletvos' -destination 'generic/platform=tvOS' -archivePath build-output/app-stg.xcarchive PROVISIONING_PROFILE='${{ secrets.APPSTORE_PROV_PROFILE_UUID_TEST_REACT_TVOS_STG }}' clean archive CODE_SIGN_IDENTITY='${{ secrets.CODE_SIGNING_IDENTITY }}' | |
working-directory: source/examples/TestNamiTV | |
- name: Export IPA | |
run: | | |
xcodebuild -exportArchive -archivePath build-output/app-stg.xcarchive -exportPath build-output/tvos-stg -exportOptionsPlist ios/ExportOptions.plist | |
working-directory: source/examples/TestNamiTV | |
- name: Upload app to TestFlight | |
run: | | |
xcrun altool --upload-app --type tvos --file build-output/tvos-stg/Basic-tvOS.ipa --apiKey $APPSTORE_API_KEY_ID --apiIssuer $APPSTORE_ISSUER_ID | |
working-directory: source/examples/TestNamiTV | |
env: | |
APPSTORE_API_KEY_ID: "${{ secrets.APPSTORE_API_KEY_ID }}" | |
APPSTORE_ISSUER_ID: "${{ secrets.APPSTORE_ISSUER_ID }}" |