You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FYReader/.github/workflows/reader.yml

113 lines
4.4 KiB

3 years ago
name: Auto build and delay
3 years ago
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
3 years ago
- uses: actions/checkout@v2
# 获取打包秘钥
- name: Checkout Android Keystore
uses: actions/checkout@v2
with:
repository: fengyuecanzhu/Key
token: ${{ secrets.KEY_TOKEN }} # 连接仓库的token,需要单独配置
path: keystore # 仓库的根目录名
3 years ago
# 读取配置
3 years ago
- name: Prepare Config
3 years ago
id: config
run: |
echo "读取配置"
source ${{ github.workspace }}/app/version_code.properties
version=$VERSION_CODE
hun=$(expr ${version} / 100)
ten=$(expr ${version} / 10)
ten=$(expr ${ten} % 10)
one=$(expr ${version} % 10)
versionN=v$hun.$ten.$one
3 years ago
3 years ago
echo ::set-output name=need_create_release::"$NEED_CREATE_RELEASE"
echo ::set-output name=version_name::"$versionN"
3 years ago
3 years ago
echo need_create_release=$NEED_CREATE_RELEASE
echo version_name=$versionN
3 years ago
3 years ago
if [[ $NEED_CREATE_RELEASE == 'true' ]];then
echo ::set-output name=lanzou_folder_id::"1608604"
echo ::set-output name=lanzou_share_url::"https://fycz.lanzoui.com/b00ngso7e"
else
echo ::set-output name=lanzou_folder_id::"2226473"
echo ::set-output name=lanzou_share_url::"https://fycz.lanzoui.com/b00nu1f8d"
fi
3 years ago
# 编译打包
- name: Build With Gradle
run: |
echo "开始编译打包"
chmod +x gradlew
if [[ ${{ steps.config.outputs.need_create_release }} == 'true' ]];then
echo "进行release构建"
./gradlew assembleRelease --parallel
3 years ago
else
3 years ago
echo "进行Debug构建"
./gradlew assembleDebug --parallel
3 years ago
fi
3 years ago
- name: Get File Path
id: get_path
run: |
3 years ago
path="$GITHUB_WORKSPACE/app/build/outputs/apk/release"
3 years ago
if [[ ${{ steps.config.outputs.need_create_release }} != 'true' ]];then
path="$GITHUB_WORKSPACE/app/build/outputs/apk/debug"
fi
3 years ago
files=$(ls $path)
for f in $files
do
if [[ $f == *"apk" ]]; then
file=$f
echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 文件:$file"
break
fi
done
echo ::set-output name=file_name::"$file"
echo ::set-output name=file_path::"$path/$file"
3 years ago
- name: Upload App To Artifact
uses: actions/upload-artifact@v2
with:
name: FYReader-apk
path: ${{ steps.get_path.outputs.file_path }}
- name: Upload App To Lanzou
3 years ago
run: |
3 years ago
echo "上传APP至蓝奏云"
python3 $GITHUB_WORKSPACE/keystore/scripts/lzy.py "${{ steps.get_path.outputs.file_path }}" "${{ steps.config.outputs.lanzou_folder_id }}"
3 years ago
echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 分享链接: ${{ steps.config.outputs.lanzou_share_url }}"
3 years ago
- name: Upload App To Team
run: |
echo "上传APP至官网"
python3 $GITHUB_WORKSPACE/keystore/scripts/team.py "$GITHUB_WORKSPACE" "${{ steps.config.outputs.lanzou_folder_id }}" "${{ steps.config.outputs.need_create_release }}"
echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 官网链接:https://reader.fycz.tk/"
3 years ago
- name: Create Release
id: create_release
3 years ago
if: ${{ steps.config.outputs.need_create_release == 'true' }}
3 years ago
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TZ: Asia/Shanghai
with:
tag_name: ${{ steps.config.outputs.version_name }}
release_name: FYReader_${{ steps.config.outputs.version_name }}
3 years ago
body_path: ${{ github.workspace }}/app/release.md
3 years ago
draft: false
3 years ago
- name: Upload Release Asset
id: upload_release_asset
3 years ago
if: ${{ steps.config.outputs.need_create_release == 'true' && steps.create_release.outputs.upload_url }}
3 years ago
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
3 years ago
asset_path: ${{ steps.get_path.outputs.file_path }}
3 years ago
asset_name: FYReader_${{ steps.config.outputs.version_name }}.apk
3 years ago
asset_content_type: application/vnd.android.package-archive