[optimize] Optimize text presentation #77
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pre-Release | |
# 触发器 | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'master' | |
paths-ignore: | |
- '**.md' | |
- 'doc/**' | |
- 'image/**' | |
pull_request: | |
branches: | |
- 'master' | |
paths-ignore: | |
- '**.md' | |
- 'doc/**' | |
- 'image/**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Checkout Secret | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ secrets.SECRET_REPO }} | |
token: ${{ secrets.TOKEN }} # 连接仓库的Token | |
path: secret | |
# 准备 secret 文件 | |
- name: Copy Secret Files | |
run: | | |
cd secret/Rays-Android | |
cp key.jks ../.. | |
cp secret.gradle ../.. | |
cp -rf assets ../../app/src/main | |
# 清理 secret 文件 | |
- name: Clean Temp Secret Files | |
run: | | |
rm -rf ./secret | |
# 构建 | |
- name: Build with Gradle | |
run: | | |
bash ./gradlew assembleGitHubRelease | |
# 上传 apk | |
- name: Upload Pre-Release Apk | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Pre-Release Apk | |
path: app/build/outputs/apk/GitHub/release/*.apk | |
# 获取 apk 路径 | |
- name: Get Pre-Release Apk File Path | |
run: | | |
echo "PRE_RELEASE_APK=$(find app/build/outputs/apk/GitHub/release -name '*.apk' -type f | head -1)" >> $GITHUB_ENV | |
# 发送至 Telegram 频道 | |
- name: Post to Telegram Channel | |
if: github.ref == 'refs/heads/master' && contains(github.event.head_commit.message, '[skip_post]') == false | |
env: | |
CHANNEL_ID: ${{ secrets.TELEGRAM_TO }} | |
BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} | |
PRE_RELEASE: ${{ env.PRE_RELEASE_APK }} | |
COMMIT_MESSAGE: |+ | |
GitHub New CI\ | |
`${{ github.event.head_commit.message }}` | |
by `${{ github.event.head_commit.author.name }}` | |
Commit details [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"])))'` | |
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2Fpre_release%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D" -F pre_release="@$PRE_RELEASE" |