-
Notifications
You must be signed in to change notification settings - Fork 33
141 lines (136 loc) · 5.4 KB
/
ci.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
# Copyright 2023-2024, shadow3 (@shadow3aaa)
#
# This file is part of fas-rs.
#
# fas-rs is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# fas-rs is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with fas-rs. If not, see <https://www.gnu.org/licenses/>.
name: ci-build
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
env:
CARGO_TERM_COLOR: always
jobs:
release-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup ndk
run: |
ndk_url=$(wget -qO- https://github.com/android/ndk/releases/latest | grep -e 'https://dl.google.com/android/repository/android-ndk-.*-linux.zip' | sed -n 's/.*<a href="\([^"]*\)".*/\1/p')
wget -O ndk.zip $ndk_url -nv
mkdir ~/ndk_temp
unzip ndk.zip -d ~/ndk_temp 2>&1 > /dev/null
mv ~/ndk_temp/*/* ~/ndk_temp
- name: Setup rust toolchains
run: |
rustup default nightly
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
rustup component add rust-src
rustup update
- name: Install cargo ndk
run: cargo install cargo-ndk
- name: Other deps
run: |
sudo apt update
sudo apt install gcc-multilib
- name: Build
run: |
export ANDROID_NDK_HOME=$(realpath ~/ndk_temp)
export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
python3 ./make.py build --release --nightly
- name: Prepare artifacts
run: |
mkdir -p output/artifact/release
unzip "output/fas-rs_release_*.zip" -d output/artifact/release
- name: Upload release version
uses: actions/upload-artifact@v4
with:
name: fas-rs(release)
compression-level: 9
path: output/artifact/release
debug-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup ndk
run: |
ndk_url=$(wget -qO- https://github.com/android/ndk/releases/latest | grep -e 'https://dl.google.com/android/repository/android-ndk-.*-linux.zip' | sed -n 's/.*<a href="\([^"]*\)".*/\1/p')
wget -O ndk.zip $ndk_url -nv
mkdir ~/ndk_temp
unzip ndk.zip -d ~/ndk_temp 2>&1 > /dev/null
mv ~/ndk_temp/*/* ~/ndk_temp
- name: Setup rust toolchains
run: |
rustup default nightly
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
rustup component add rust-src
rustup update
- name: Install cargo ndk
run: cargo install cargo-ndk
- name: Other deps
run: |
sudo apt update
sudo apt install gcc-multilib
- name: Build
run: |
export ANDROID_NDK_HOME=$(realpath ~/ndk_temp)
export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
python3 ./make.py build --debug --nightly
- name: Prepare artifacts
run: |
mkdir -p output/artifact/debug
unzip "output/fas-rs_debug_*.zip" -d output/artifact/debug
- name: Upload debug version
uses: actions/upload-artifact@v4
with:
name: fas-rs(debug)
compression-level: 9
path: output/artifact/debug
push_to_ci_group:
if: github.event_name == 'push'
runs-on: ubuntu-latest
name: Push to CI Group
needs:
- debug-build
- release-build
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Package Artifacts
run: |
cd "${{ github.workspace }}/artifacts/fas-rs(debug)"
zip -9 -rq "../fas-rs(debug)" .
cd "${{ github.workspace }}/artifacts/fas-rs(release)"
zip -9 -rq "../fas-rs(release)" .
- name: Post to Debug Group
shell: bash
env:
GROUP_DEBUG_ID: ${{ secrets.TELEGRAM_TO }}
BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
THREAD_ID: ${{ secrets.THREAD_ID }}
COMMIT_MESSAGE: |+
New push to GitHub
```
${{ github.event.head_commit.message }}
```by `${{ github.event.head_commit.author.name }}`
See commit detail [here](${{ github.event.head_commit.url }})
run: |
ESCAPED=$(python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"])))')
cd ${{ github.workspace }}
echo $COMMIT_MESSAGE_FIXED
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${GROUP_DEBUG_ID}&message_thread_id=${THREAD_ID}&media=%5B%7B%22type%22:%22document%22,%20%22media%22:%22attach://debug_zip%22,%22parse_mode%22:%22MarkdownV2%22,%22caption%22:\"\"%7D,%7B%22type%22:%22document%22,%20%22media%22:%22attach://release_zip%22,%22parse_mode%22:%22MarkdownV2%22,%22caption%22:${ESCAPED}%7D%5D" -F debug_zip="@artifacts/fas-rs(debug).zip" -F release_zip="@artifacts/fas-rs(release).zip"