Skip to content

Commit

Permalink
chore: optimize CI scripts (run-on macos, version, slack notification
Browse files Browse the repository at this point in the history
  • Loading branch information
XuNeal committed Mar 17, 2023
1 parent 58ae87c commit 31f083f
Show file tree
Hide file tree
Showing 11 changed files with 354 additions and 71 deletions.
96 changes: 71 additions & 25 deletions .github/workflows/build-release-android.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
name: Build Release Android
name: Build Android Release

on:
push:
tags:
- 'v*'
branches:
- main
issue_comment:
types: [created, edited]

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build Android Release
if: (
github.ref == 'refs/heads/main' ||
(github.event.issue.pull_request &&
contains(
fromJson('["build", "build android"]'),
github.event.comment.body
))
)

cross-compile:
name: cross compile
runs-on: ubuntu-20.04
runs-on: macos-latest

steps:
- name: Checkout repository
Expand All @@ -33,54 +43,90 @@ jobs:
- name: Install Rust
run: |
rustup toolchain install nightly-2022-10-31
rustup default nightly-2022-10-31-x86_64-unknown-linux-gnu
rustup default nightly-2022-10-31-x86_64-apple-darwin
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
rustup show
- name: Install dependent
run: |
sudo apt-get install -y libusb-dev libusb-1.0-0-dev libftdi1-dev libudev-dev
sudo apt-get install -y protobuf-compiler libprotobuf-dev
# - name: Install dependent
# run: |
# sudo apt-get install -y libusb-dev libusb-1.0-0-dev libftdi1-dev libudev-dev
# sudo apt-get install -y protobuf-compiler libprotobuf-dev

- name: Install dependency
run: |
brew install protobuf
- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Install Android Tools
run: sdkmanager "build-tools;29.0.3" "platforms;android-31" "ndk;25.2.9519653"

- name: Configure Rust Config File
run: |
echo '[target.armv7-linux-androideabi]' >> ~/.cargo/config
echo 'ar = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"' >> ~/.cargo/config
echo 'linker = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi29-clang"' >> ~/.cargo/config
echo 'ar = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"' >> ~/.cargo/config
echo 'linker = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi22-clang"' >> ~/.cargo/config
echo '[target.aarch64-linux-android]' >> ~/.cargo/config
echo 'ar = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"' >> ~/.cargo/config
echo 'linker = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang"' >> ~/.cargo/config
echo 'ar = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"' >> ~/.cargo/config
echo 'linker = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android29-clang"' >> ~/.cargo/config
echo '[target.i686-linux-android]' >> ~/.cargo/config
echo 'ar = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"' >> ~/.cargo/config
echo 'linker = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android29-clang"' >> ~/.cargo/config
echo 'ar = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"' >> ~/.cargo/config
echo 'linker = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/i686-linux-android29-clang"' >> ~/.cargo/config
echo '[target.x86_64-linux-android]' >> ~/.cargo/config
echo 'ar = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"' >> ~/.cargo/config
echo 'linker = "/usr/local/lib/android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android29-clang"' >> ~/.cargo/config
echo 'ar = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar"' >> ~/.cargo/config
echo 'linker = "/Users/runner/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android29-clang"' >> ~/.cargo/config
cat ~/.cargo/config
- name: Build TCX And IKC
run: |
pushd ${{github.workspace}}/script
./build-android-linux.sh
./build-android.sh
popd
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.0.1

- name: publish

- name: Read VERSION file
id: getversion
run: echo "version=$(cat VERSION)+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Get commits
id: getcommits
run: echo "commits=$(git log -5 --pretty=%B)" >> $GITHUB_OUTPUT

- name: Publish
run: |
pushd ${{github.workspace}}/publish/android
TAG_NAME=${{ github.ref }}
VERSION_NAME="VERSION=${TAG_NAME: 11}"
VERSION_NAME="VERSION=${{ steps.getversion.outputs.version }}"
echo 'NEXUS_USER=${{secrets.NEXUS_USER}}' >> ./local.properties
echo 'NEXUS_PASSWORD=${{secrets.NEXUS_PASSWORD}}' >> ./local.properties
echo ${VERSION_NAME} >> ./local.properties
./gradlew assemble
./gradlew pPPTNR
popd
- 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 android-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\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 android-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\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
63 changes: 50 additions & 13 deletions .github/workflows/build-release-ios.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
name: Build Release IOS
name: Build iOS Release

on:
push:
tags:
- 'v*'
branches:
- main
issue_comment:
types: [created, edited]

env:
CARGO_TERM_COLOR: always

jobs:

build:
name: build release
name: Build iOS Release
if: (
github.ref == 'refs/heads/main' ||
(github.event.issue.pull_request &&
contains(
fromJson('["build", "build ios"]'),
github.event.comment.body
))
)

runs-on: macos-latest

steps:
Expand Down Expand Up @@ -39,6 +49,15 @@ jobs:
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

- name: Get commits
id: getcommits
run: echo "commits=$(git log -5 --pretty=%B)" >> $GITHUB_OUTPUT


- name: Build And Publish
run: |
pushd ./imkey-core/ikc
Expand Down Expand Up @@ -84,11 +103,9 @@ jobs:
popd

pushd ./imkey-core/ios-release
TAG_NAME=${{ github.ref }}
VERSION_NAME=${TAG_NAME: 11}
PACKAGE_NAME=ios-release-v$VERSION_NAME.zip
PACKAGE_NAME=ios-release-${{ steps.getversion.outputs.version }}.zip
zip -q -r $PACKAGE_NAME .
curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/im/imkey/ios/$VERSION_NAME/$PACKAGE_NAME
curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/im/imkey/ios/${{ steps.getversion.outputs.version }}/$PACKAGE_NAME
popd

pushd ./token-core/tcx-examples/TokenCoreX
Expand All @@ -106,10 +123,30 @@ jobs:
popd

pushd ./token-core/ios-release
TAG_NAME=${{ github.ref }}
VERSION_NAME=${TAG_NAME: 11}
PACKAGE_NAME=ios-release-v$VERSION_NAME.zip
PACKAGE_NAME=ios-release-${{ steps.getversion.outputs.version }}.zip
zip -q -r $PACKAGE_NAME .
curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/com/consenlabs/ios/$VERSION_NAME/$PACKAGE_NAME
curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/com/consenlabs/ios/${{ steps.getversion.outputs.version }}/$PACKAGE_NAME
popd


- 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 }}\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 }}\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
146 changes: 146 additions & 0 deletions .github/workflows/integrate-fe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Build iOS Debug

on:
issue_comment:
types: [created, edited]

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build iOS Debug
if: (github.event.issue.pull_request &&
contains(
fromJson('["build debug"]'),
github.event.comment.body
))

runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1

- 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 x86_64-apple-ios
rustup show
cargo install cargo-lipo
brew install protobuf
- name: Read VERSION file
id: getversion
run: echo "version=$(cat VERSION)-alpha+$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Get commits
id: getcommits
run: echo "commits=$(git log -5 --pretty=%B)" >> $GITHUB_OUTPUT


- name: Build And Publish
run: |
pushd ./imkey-core/ikc
cargo lipo --release --targets x86_64-apple-ios
cbindgen ./src/lib.rs -l c > ${{github.workspace}}/target/connector.h
popd
pushd ./token-core/tcx
cargo lipo --release --targets 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-release-${{ steps.getversion.outputs.version }}.zip
zip -q -r $PACKAGE_NAME .
curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/im/imkey/ios/${{ steps.getversion.outputs.version }}/$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-release-${{ steps.getversion.outputs.version }}.zip
zip -q -r $PACKAGE_NAME .
curl -v -u ${{secrets.NEXUS_USER}}:${{secrets.NEXUS_PASSWORD}} --upload-file $PACKAGE_NAME https://nexus.token.im/repository/im-releases/com/consenlabs/ios/${{ steps.getversion.outputs.version }}/$PACKAGE_NAME
popd


- 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 }}\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 }}\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
Loading

0 comments on commit 31f083f

Please sign in to comment.