-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (128 loc) · 5.56 KB
/
release_sample_app.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Release new Sample App version
run-name: 🚀 TestAPP ${{ github.actor }} started a new ${{inputs.version_bump_Type}} release in ${{inputs.channel_type}} channel
on:
workflow_dispatch:
inputs:
channel_type:
description: 'Choose Release channel'
required: true
default: 'stable'
type: choice
options:
- stable
- beta
- alpha
version_bump_Type:
description: 'Type of Version Number Bump'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
jobs:
Release-new-sample-app-version:
runs-on: macos-13
if: always() && !cancelled() && !contains(needs.*.result, 'failure')
steps:
- name: Setup Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Checkout main repo
uses: actions/checkout@v3
with:
path: main
token: ${{ secrets.GIT_TOKEN}}
- name: Setup ENV VARS
run: |
echo "CI_MAIN_REPO_PATH=$GITHUB_WORKSPACE/main" >> $GITHUB_ENV
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.SAMPLE_APP_ENTERPRISE_CERT }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
PROD_BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.PROD_BUILD_PROVISION_PROFILE_BASE64 }}
ALPHA_BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.ALPHA_BUILD_PROVISION_PROFILE_BASE64 }}
BETA_BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BETA_BUILD_PROVISION_PROFILE_BASE64 }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
PROD_PP_PATH=$RUNNER_TEMP/Dailymotion_Sample_InHouse.mobileprovision
BETA_PATH=$RUNNER_TEMP/Dailymotion_Sample_InHouse_Beta.mobileprovision
ALPHA_PATH=$RUNNER_TEMP/Dailymotion_Sample_InHouse_Alpha.mobileprovision
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$PROD_BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PROD_PP_PATH
echo -n "$BETA_BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $BETA_PATH
echo -n "$ALPHA_BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $ALPHA_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PROD_PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
cp $BETA_PATH ~/Library/MobileDevice/Provisioning\ Profiles
cp $ALPHA_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Set up ruby env
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.3
bundler-cache: true
- name: Config environment
run: |
chmod +x ./main/ci_scripts/config_env.sh
./main/ci_scripts/config_env.sh
shell: bash
- name: Sample App Release
env:
APP_CENTER_SECRET_ALPHA: ${{ secrets.APP_CENTER_SECRET_ALPHA }}
APP_CENTER_SECRET_BETA: ${{ secrets.APP_CENTER_SECRET_BETA }}
APP_CENTER_SECRET_PROD: ${{ secrets.APP_CENTER_SECRET_PROD }}
run: |
cd $(echo "${CI_MAIN_REPO_PATH}")
env="alpha"
target="Alpha"
apiToken=""
case ${{inputs.channel_type}} in
stable)
env="prod" ; target="Prod"
apiToken=$APP_CENTER_SECRET_PROD
;;
beta)
env="beta" ; target="Beta"
apiToken=$APP_CENTER_SECRET_BETA
;;
alpha)
env="alpha" ; target="Alpha"
apiToken=$APP_CENTER_SECRET_ALPHA
;;
*)
echo -n "Unknown release channel_type" ; exit 1
;;
esac
echo "ENV $env, Target $target"
echo "ApiToken chars: ${#apiToken}"
appDelegatePath=${CI_MAIN_REPO_PATH}/DailymotionPlayerSample/AppDelegate.swift
infoPlistPath=${CI_MAIN_REPO_PATH}/DailymotionPlayerSample/Info.plist
sed -i '' -e "s/<<AppCenterSecret>>/${apiToken}/g" $appDelegatePath
echo "AppDelegate at path ${appDelegatePath} secret replaced"
sed -i '' -e "s/AppCenterSecretPLIST/appcenter-${apiToken}/g" $infoPlistPath
echo "Info.plist at path ${infoPlistPath} secret replaced"
echo "Start build"
bundle exec fastlane ios SAMPLE_APP_CREATE_RELEASE api_token:$apiToken target:$target bump_type:${{ inputs.version_bump_Type }} --env $env --verbose
echo "Build Finished"
echo "Removing secrets"
sed -i '' -e "s/${apiToken}/<<AppCenterSecret>>/g" $appDelegatePath
echo "AppDelegate secret replaced"
sed -i '' -e "s/appcenter-${apiToken}/AppCenterSecretPLIST/g" $infoPlistPath
echo "Info.plist secret replaced"
echo "Start Tag the version"
bundle exec fastlane ios TEST_APP_GIT_TAG target:$target --verbose
shell: bash