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/build.yml

91 lines
3.5 KiB

3 years ago
name: build
3 years ago
on:
push:
branches:
- master
3 years ago
- dev
3 years ago
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
3 years ago
versionN=v${version:0:1}.${version:1:1}.${version:2:1}
3 years ago
3 years ago
echo ::set-output name=need_create_release::"$CREATE_RELEASE"
3 years ago
echo ::set-output name=version_name::"$versionN"
3 years ago
3 years ago
echo need_create_release=$CREATE_RELEASE
3 years ago
echo version_name=$versionN
3 years ago
3 years ago
if [ $CREATE_RELEASE == 'true' -a ${{ github.ref }} == 'refs/heads/master' ];then
3 years ago
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
3 years ago
if [[ ${{ steps.config.outputs.need_create_release }} == 'true' ]];then
3 years ago
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
3 years ago
path="$GITHUB_WORKSPACE/app/build/outputs/apk/debug"
fi
3 years ago
echo ::set-output name=file_path::"$path"
3 years ago
- name: Upload Lanzou
3 years ago
run: |
3 years ago
echo "上传APP至蓝奏云"
3 years ago
tag_name=${{ steps.config.outputs.version_name }}
3 years ago
if [ ${{ steps.config.outputs.need_create_release }} != 'true' -o ${{ github.ref }} != 'refs/heads/master' ];then
3 years ago
gitHead=$(git rev-parse --short HEAD)
tag_name=${{ steps.config.outputs.version_name }}-$gitHead
fi
2 years ago
python3 $GITHUB_WORKSPACE/keystore/scripts/lzy.py "${{ steps.get_path.outputs.file_path }}/风月读书$tag_name.apk" "${{ steps.config.outputs.lanzou_folder_id }}" "$tag_name"
3 years ago
# 发布正式版
3 years ago
- name: Release
3 years ago
if: ${{ steps.config.outputs.need_create_release == 'true' && github.ref == 'refs/heads/master' }}
3 years ago
uses: softprops/action-gh-release@v1
3 years ago
with:
3 years ago
body_path: ./app/release.md
prerelease: false
3 years ago
draft: false
3 years ago
tag_name: ${{ steps.config.outputs.version_name }}
name: FYReader_${{ steps.config.outputs.version_name }}
files: |
2 years ago
${{ steps.get_path.outputs.file_path }}/风月读书${{ steps.config.outputs.version_name }}.apk
3 years ago
env:
3 years ago
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 years ago
# 上传Artifact
2 years ago
- name: Upload Artifact
3 years ago
uses: actions/upload-artifact@v3
with:
2 years ago
name: app
2 years ago
path: ${{ steps.get_path.outputs.file_path }}/风月读书*.apk