-
Notifications
You must be signed in to change notification settings - Fork 4
178 lines (154 loc) · 7.28 KB
/
build-release-ios.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
name: Build iOS Release
on:
pull_request_review:
types: [submitted]
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
jobs:
build:
name: Build iOS Release
if: github.event.review.state == 'approved'
runs-on: macos-latest
steps:
- name: Get the latest commit SHA
id: sha
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const { owner, repo, number } = context.issue
const pr = await github.rest.pulls.get({
owner,
repo,
pull_number: number,
})
return pr.data.head.sha
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ steps.sha.outputs.result }}
fetch-depth: 5
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
target
key: macos-latest-nightly
- name: Install Rust
run: |
rustup toolchain install nightly-2022-10-31
rustup default nightly-2022-10-31-x86_64-apple-darwin
rustup target add aarch64-apple-ios x86_64-apple-ios
rustup show
cargo install cargo-lipo
brew install protobuf
- name: Read VERSION file
id: getversion
run: |
echo "version=$(cat VERSION)+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "tag_name=$(cat VERSION)" >> $GITHUB_OUTPUT
echo "short_commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Get commits
id: getcommits
shell: bash
run: |
OUTPUT="$(git log -n 5 --pretty=format:"%s")"
echo ::set-output name=commits::"${OUTPUT}"
- name: Build And Publish
id: build
run: |
pushd ./imkey-core/ikc
cargo lipo --release --targets aarch64-apple-ios x86_64-apple-ios
cbindgen ./src/lib.rs -l c > ${{github.workspace}}/target/connector.h
popd
pushd ./token-core/tcx
cargo lipo --release --targets aarch64-apple-ios x86_64-apple-ios
cbindgen ./src/lib.rs -l c > ${{github.workspace}}/target/tcx.h
popd
LIBS_IKC=./imkey-core/mobile-sdk/imKeyCoreX/imKeyCoreX
LIBS_TCX=./token-core/tcx-examples/TokenCoreX/TokenCoreX
cp ./target/universal/release/libconnector.a $LIBS_IKC/libconnector.a
cp ./target/universal/release/libtcx.a $LIBS_TCX/libtcx.a
cp ./target/connector.h $LIBS_IKC/connector.h
cp ./target/tcx.h $LIBS_TCX/tcx.h
if [ -d "./ios-release" ]; then
rm -rf ./ios-release
fi
BUILD_DIR=./Products
BUILD_ROOT=./Products
SYMROOT=./Products
BUILD_PRODUCTS=./Products
CONFIGURATION=Release
PROJECT_NAME_IKC=imKeyCoreX
PROJECT_NAME_TCX=TokenCoreX
pushd ./imkey-core/mobile-sdk/imKeyCoreX
mkdir -p $BUILD_DIR
UNIVERSAL_OUTPUTFOLDER=$BUILD_DIR/$CONFIGURATION-Universal
mkdir -p $UNIVERSAL_OUTPUTFOLDER
xcodebuild -target $PROJECT_NAME_IKC ONLY_ACTIVE_ARCH=NO -configuration $CONFIGURATION -sdk iphoneos BUILD_DIR=$BUILD_DIR BUILD_ROOT=$BUILD_ROOT build
xcodebuild -target $PROJECT_NAME_IKC -configuration Debug -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR=$BUILD_DIR BUILD_ROOT=$BUILD_ROOT EXCLUDED_ARCHS=arm64 build
cp -R $BUILD_DIR/$CONFIGURATION-iphoneos/$PROJECT_NAME_IKC.framework $UNIVERSAL_OUTPUTFOLDER/
lipo -create -output $UNIVERSAL_OUTPUTFOLDER/$PROJECT_NAME_IKC.framework/$PROJECT_NAME_IKC $BUILD_PRODUCTS/Debug-iphonesimulator/$PROJECT_NAME_IKC.framework/$PROJECT_NAME_IKC $BUILD_DIR/$CONFIGURATION-iphoneos/$PROJECT_NAME_IKC.framework/$PROJECT_NAME_IKC
cp -R $UNIVERSAL_OUTPUTFOLDER/ ../../ios-release
rm -rf $UNIVERSAL_OUTPUTFOLDER
popd
pushd ./imkey-core/ios-release
PACKAGE_NAME=ios-ikc-${{ steps.getversion.outputs.version }}.zip
zip -q -r $PACKAGE_NAME .
echo "imkeycorex_sha256=$(shasum -a 256 $PACKAGE_NAME | awk '{ print $1 }')" >> $GITHUB_OUTPUT
echo "imKeyCoreX sha256: $(shasum -a 256 $PACKAGE_NAME | awk '{ print $1 }')"
cp $PACKAGE_NAME ../../
popd
pushd ./token-core/tcx-examples/TokenCoreX
mkdir -p $BUILD_DIR
UNIVERSAL_OUTPUTFOLDER=$BUILD_DIR/$CONFIGURATION-Universal
mkdir -p $UNIVERSAL_OUTPUTFOLDER
xcodebuild -target $PROJECT_NAME_TCX ONLY_ACTIVE_ARCH=NO -configuration $CONFIGURATION -sdk iphoneos BUILD_DIR=$BUILD_DIR BUILD_ROOT=$BUILD_ROOT build
xcodebuild -target $PROJECT_NAME_TCX -configuration Debug -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR=$BUILD_DIR BUILD_ROOT=$BUILD_ROOT EXCLUDED_ARCHS=arm64 build
cp -R $BUILD_DIR/$CONFIGURATION-iphoneos/$PROJECT_NAME_TCX.framework $UNIVERSAL_OUTPUTFOLDER/
lipo -create -output $UNIVERSAL_OUTPUTFOLDER/$PROJECT_NAME_TCX.framework/$PROJECT_NAME_TCX $BUILD_PRODUCTS/Debug-iphonesimulator/$PROJECT_NAME_TCX.framework/$PROJECT_NAME_TCX $BUILD_DIR/$CONFIGURATION-iphoneos/$PROJECT_NAME_TCX.framework/$PROJECT_NAME_TCX
cp -R $UNIVERSAL_OUTPUTFOLDER/ ../../ios-release
rm -rf $UNIVERSAL_OUTPUTFOLDER
popd
pushd ./token-core/ios-release
PACKAGE_NAME=ios-tcx-${{ steps.getversion.outputs.version }}.zip
zip -q -r $PACKAGE_NAME .
echo "tokencorex_sha256=$(shasum -a 256 $PACKAGE_NAME | awk '{ print $1 }')" >> $GITHUB_OUTPUT
echo "TokenCoreX sha256: $(shasum -a 256 $PACKAGE_NAME | awk '{ print $1 }')"
cp $PACKAGE_NAME ../../
popd
- name: Release
uses: softprops/action-gh-release@v1
with:
name: "Release ${{ steps.getversion.outputs.version }}"
tag_name: "v${{ steps.getversion.outputs.version }}"
generate_release_notes: true
files: |
ios-ikc-${{ steps.getversion.outputs.version }}.zip
ios-tcx-${{ steps.getversion.outputs.version }}.zip
- name: Send custom JSON data to Slack workflow
id: slack
uses: slackapi/[email protected]
with:
# For posting a rich message using Block Kit
payload: |
{
"text": "New build of ios-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\nimKey Core X Sha256: ${{ steps.build.outputs.imkeycorex_sha256 }}\nToken Core X Sha256: ${{ steps.build.outputs.tokencorex_sha256 }}\nCheck more: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCommits:\n${{ steps.getcommits.outputs.commits }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "New build of ios-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\nimKey Core X Sha256: ${{ steps.build.outputs.imkeycorex_sha256 }}\nToken Core X Sha256: ${{ steps.build.outputs.tokencorex_sha256 }}\nCheck more: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCommits:\n${{ steps.getcommits.outputs.commits }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK