-
Notifications
You must be signed in to change notification settings - Fork 4
141 lines (123 loc) · 5.84 KB
/
build-release-android.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: Build Android Release
on:
pull_request_review:
types: [submitted]
env:
CARGO_TERM_COLOR: always
ORG_GRADLE_PROJECT_sonatypeUsername : ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword : ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey : ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword : ${{ secrets.SIGNING_SECRET }}
jobs:
build:
name: Build Android 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: ${{ runner.os }}-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-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 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 = "/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 = "/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 = "/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 = "/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.sh
popd
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.0.1
- name: Read VERSION file
id: getversion
run: echo "version=$(cat VERSION)+$(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: Publish
id: publish
run: |
pushd ${{github.workspace}}/publish/android
./gradlew assemble
echo "tokencore_sha256=$(shasum -a 256 ${{github.workspace}}/publish/android/tokencore/build/outputs/aar/tokencore-release.aar | awk '{ print $1 }')" >> $GITHUB_OUTPUT
echo "tokencore-release.aar sha256: $(shasum -a 256 ${{github.workspace}}/publish/android/tokencore/build/outputs/aar/tokencore-release.aar | awk '{ print $1 }')"
VERSION=${{steps.getversion.outputs.version}} ./gradlew publishToSonatype closeSonatypeStagingRepository
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 }}\nTokenCore Sha256: ${{ steps.publish.outputs.tokencore_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 android-token-core: ${{ job.status }}\nVERSION: ${{ steps.getversion.outputs.version }}\nTokenCore Sha256: ${{ steps.publish.outputs.tokencore_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