-
Notifications
You must be signed in to change notification settings - Fork 8
230 lines (186 loc) · 7.28 KB
/
main.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: CI
on:
push:
branches:
- staging
- main
- develop
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
testIOS:
name : TestIOS
# runs-on: will be set to macos-latest when running on actual GHA.
# *** runs-on: ubuntu-latest is used when running via act on mac os. ***
runs-on: macos-14
steps:
- uses: actions/checkout@master
with:
submodules: true
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Install lcov
run: |
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/e92d2ae54954ebf485b484d8522104700b144fee/Formula/lcov.rb > lcov.rb
brew install ./lcov.rb
- name: Update gem
run: bundle update
- name: Install gems
run: bundle install
- name: Run tests on iOS (using fastlane)
run: bundle exec fastlane runIOSTests
testTVOS:
name : TestTVOS
# runs-on: will be set to macos-latest when running on actual GHA.
# *** runs-on: ubuntu-latest is used when running via act on mac os. ***
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Install lcov
run: brew install lcov
- name: Update gem
run: bundle update
- name: Install gems
run: bundle install
- name: Run tests on tvOS (using fastlane)
run: bundle exec fastlane runTVOSTests
testWatchOS:
name : TestWatchOS
# runs-on: will be set to macos-latest when running on actual GHA.
# *** runs-on: ubuntu-latest is used when running via act on mac os. ***
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Install lcov
run: brew install lcov
- name: Update gem
run: bundle update
- name: Install gems
run: bundle install
- name: Run tests on watchOS (using fastlane)
run: bundle exec fastlane runWatchOSTests
deployS3:
name: DeployS3
# runs-on: will be set to macos-latest when running on actual GHA.
# *** runs-on: ubuntu-latest is used when running via act on mac os. ***
runs-on: macos-14
needs: [testIOS, testTVOS, testWatchOS]
if: github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/main'
outputs:
version: ${{ steps.setOutput.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
# BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
# echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_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 $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Update gem
run: bundle update
- name: Install gems
run: bundle install
- name: Build NewRelic.xcframework (using fastlane)
run: bundle exec fastlane buildAndZip
- name: Get name
run: echo "version=$(cat fastlane/build_version)" >> $GITHUB_ENV
- id: setOutput
name: Print name
run: echo "version=${{ env.version }}" >> $GITHUB_OUTPUT
- name: Deploy to staging S3
run: "aws s3 cp NewRelic_XCFramework_Agent_${{ env.version }}.zip s3://nr-downloads-main/ios-v5/"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Upload build reports
if: failure() && steps.build-step.outcome != 'success'
uses: actions/upload-artifact@v3
with:
name: build-reports
path: /Users/runner/Library/Logs/fastlane/xcbuild/
# Create NewRelicAgent.podspec & Package.swift with new version number and checksum.
deployStagingSpecs:
name: DeployStagingSpecs
runs-on: macos-latest
needs: [deployS3]
if: github.ref == 'refs/heads/staging'
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Update gem
run: bundle update
- name: Install gems
run: bundle install
- name: Get name
run: echo "version=${{needs.deployS3.outputs.version}}" >> $GITHUB_ENV
- name: Print XCFramework name
run: echo "${{ env.version }}"
- name: Create Podspec for XCFramework version
run: |
cp cocoapods/NewRelicAgent.podspec.template NewRelicAgent.podspec
REPLACE=X.XX
sed -i bak "s/$REPLACE/${{ env.version }}/g" NewRelicAgent.podspec
sed -i -e 's/ios_agent/ios-v5/g' NewRelicAgent.podspec
rm NewRelicAgent.podspec-e
rm NewRelicAgent.podspecbak
- name: Create Package.swift for XCFramework version
run: |
cp NewRelic-SwiftPackage/Package.swift.template Package.swift
## Below README required for prod spm repo.
# cp cocoapods/README.md README.md
REPLACEVER={{VERSION}}
REPLACECHECKSUM={{CHECKSUM}}
XCFRAMEWORK_NAME="NewRelic_XCFramework_Agent_${{ env.version }}.zip"
curl https://download.newrelic.com/ios-v5/$XCFRAMEWORK_NAME -o $XCFRAMEWORK_NAME
SPM_CHECKSUM=`swift package compute-checksum ${XCFRAMEWORK_NAME}`
sed -i bak "s/$REPLACEVER/${{ env.version }}/g" Package.swift
sed -i -e "s/$REPLACECHECKSUM/$SPM_CHECKSUM/g" Package.swift
sed -i -e 's/ios_agent/ios-v5/g' Package.swift
rm Package.swift-e
rm Package.swiftbak
rm $XCFRAMEWORK_NAME
# Use git-auto-commit-action to push NewRelicAgent.podspec & Package.swift up to root of newrelic-ios-agent branch: staging.
# This should also tag the staging release branch w/ version number tag.
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[${{ env.version }}] Staging Release"
branch: staging
tagging_message: "${{ env.version }}"