-
Notifications
You must be signed in to change notification settings - Fork 109
97 lines (82 loc) · 3.65 KB
/
build.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
name: Build IITC and push artifacts
on:
push:
branches:
- master
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Set env BRANCH
run: echo "BRANCH=$(echo $GITHUB_REF | cut -d'/' -f 3)" >> $GITHUB_ENV
- name: Set env BUILD_TYPE and ARCHIVE_DIR (optional)
run: |
if [[ $BRANCH == 'master' ]]; then
echo "BUILD_TYPE=beta" >> "$GITHUB_ENV"
echo "ARCHIVE_DIR=beta_archive" >> "$GITHUB_ENV"
else
echo "BUILD_TYPE=release" >> "$GITHUB_ENV"
echo "ARCHIVE_DIR=release_archive" >> "$GITHUB_ENV"
fi
- name: Set env ENABLE_CHECK_APP_UPDATES
run: echo "ENABLE_CHECK_APP_UPDATES=true" >> "$GITHUB_ENV"
- name: Download localbuildsettings.py
run: wget https://iitc.app/deploy/localbuildsettings.py
- name: Run build.py
env:
KEYSTORE_PASS: ${{ secrets.KEYSTORE_PASS }}
ALIAS_NAME: ${{ secrets.ALIAS_NAME }}
ALIAS_PASS: ${{ secrets.ALIAS_PASS }}
run: ./build.py $BUILD_TYPE
- name: Set env with artifacts
run: |
echo "ARTIFACT_IITC_MOBILE=$( ls -d ./build/${{ env.BUILD_TYPE }}/* | grep '.apk' )" >> "$GITHUB_ENV"
echo "ARTIFACT_IITC_ZIP=$( ls -d ./build/${{ env.BUILD_TYPE }}/* | grep '.zip' )" >> "$GITHUB_ENV"
- name: Set env BUILDSTAMP
run: |
echo "BUILDSTAMP=$(date -u +'%Y-%m-%d_%H-%M' -d"$(stat -c %y ./build/${{ env.BUILD_TYPE }}/total-conversion-build.user.js)")" >> "$GITHUB_ENV"
- uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "./build/${{ env.BUILD_TYPE }}/*.zip,./build/${{ env.BUILD_TYPE }}/*.apk"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Send APK to Telegram
env:
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
TG_CHAT_ID: ${{ secrets.TG_CHAT_ID }}
TG_THREAD_ID: ${{ secrets.TG_THREAD_ID }}
if: ${{ env.TG_BOT_TOKEN != ''}}
run: |
TEXT="🤖 *New IITC Mobile ${{ env.BUILD_TYPE }} build: *[${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})"
APIPARAMS="-F parse_mode=MarkdownV2 -F disable_notification=true -F chat_id=${{ env.TG_CHAT_ID }} -F is_topic_message=true -F message_thread_id=${{ env.TG_THREAD_ID }} https://api.telegram.org/bot${{ env.TG_BOT_TOKEN }}/sendDocument"
curl -s -F document=@"${{ env.ARTIFACT_IITC_MOBILE }}" -F caption="$TEXT" $APIPARAMS
- name: Save PR metadata
run: |
mkdir artifact
mv ./build/${{ env.BUILD_TYPE }} ./artifact/build
mkdir -p ./artifact/.metadata
echo ${{ env.BUILD_TYPE }} > ./artifact/.metadata/build_type
echo ${{ github.sha }} > ./artifact/.metadata/commit
echo $( ls ./artifact/build/ | grep '.apk' ) > ./artifact/.metadata/apk_filename
echo $( ls ./artifact/build/ | grep '.zip' ) > ./artifact/.metadata/zip_filename
echo $(date -u +'%Y-%m-%d_%H-%M' -d"$(stat -c %y ./artifact/build/total-conversion-build.user.js)") > ./artifact/.metadata/buildstamp
- uses: actions/upload-artifact@v4
with:
name: build
include-hidden-files: true
path: |
./artifact/.metadata/
./artifact/build/