legado/.github/workflows/release.yml

100 lines
3.9 KiB
YAML
Raw Permalink Normal View History

2021-08-09 19:31:33 +08:00
name: Build and Release
2020-07-30 20:15:52 +08:00
2020-12-09 08:05:38 +08:00
on:
2020-07-30 20:15:52 +08:00
push:
2020-12-09 08:05:38 +08:00
branches:
- master
2021-08-09 19:31:33 +08:00
paths:
- 'CHANGELOG.md'
# schedule:
# - cron: '0 4 * * *'
2020-07-30 20:15:52 +08:00
jobs:
build:
runs-on: ubuntu-latest
2020-12-09 08:05:38 +08:00
env:
2021-03-12 16:39:59 +08:00
# 登录蓝奏云后在控制台运行document.cookie
ylogin: ${{ secrets.LANZOU_ID }}
phpdisk_info: ${{ secrets.LANZOU_PSD }}
2021-02-27 20:16:46 +08:00
# 蓝奏云里的文件夹ID阅读3测试版:2670621
2021-08-10 19:38:43 +08:00
LANZOU_FOLDER_ID: 'b0f7pt4ja'
2020-12-09 08:05:38 +08:00
# 是否上传到artifact
2020-12-28 10:54:58 +08:00
UPLOAD_ARTIFACT: 'true'
2020-07-30 20:15:52 +08:00
steps:
2020-12-09 08:05:38 +08:00
- uses: actions/checkout@v2
2021-08-26 21:29:32 +08:00
with:
fetch-depth: 0
- uses: actions/cache@v2
2020-12-09 08:05:38 +08:00
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
2021-02-11 01:06:34 +08:00
key: ${{ runner.os }}-legado-${{ hashFiles('**/updateLog.md') }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
2021-02-11 01:06:34 +08:00
${{ runner.os }}-legado-${{ hashFiles('**/updateLog.md') }}-
2020-12-29 10:22:19 +08:00
- name: Release Apk Sign
2020-12-09 08:05:38 +08:00
run: |
echo "给apk增加签名"
cp $GITHUB_WORKSPACE/.github/workflows/legado.jks $GITHUB_WORKSPACE/app/legado.jks
2021-02-11 12:40:46 +08:00
sed '$a\RELEASE_STORE_FILE=./legado.jks' $GITHUB_WORKSPACE/gradle.properties -i
sed '$a\RELEASE_KEY_ALIAS=legado' $GITHUB_WORKSPACE/gradle.properties -i
sed '$a\RELEASE_STORE_PASSWORD=gedoor_legado' $GITHUB_WORKSPACE/gradle.properties -i
sed '$a\RELEASE_KEY_PASSWORD=gedoor_legado' $GITHUB_WORKSPACE/gradle.properties -i
2021-08-07 15:00:29 +08:00
- name: Unify Version Name
run: |
echo "统一版本号"
VERSION=$(date -d "8 hour" -u +3.%y.%m%d%H)
2021-08-09 19:31:33 +08:00
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
2021-08-07 15:00:29 +08:00
sed "/def version/c def version = \"$VERSION\"" $GITHUB_WORKSPACE/app/build.gradle -i
- name: Build With Gradle
run: |
echo "开始进行release构建"
chmod +x gradlew
2021-08-25 19:20:43 +08:00
./gradlew assembleRelease --build-cache --parallel
2021-08-09 19:31:33 +08:00
- name: Organize the Files
2020-12-09 08:05:38 +08:00
run: |
2021-08-09 19:31:33 +08:00
mkdir -p ${{ github.workspace }}/apk/
cp -rf ${{ github.workspace }}/app/build/outputs/apk/*/*/*.apk ${{ github.workspace }}/apk/
2020-12-09 11:44:36 +08:00
- name: Upload App To Artifact
2020-12-09 08:05:38 +08:00
if: ${{ env.UPLOAD_ARTIFACT != 'false' }}
uses: actions/upload-artifact@v2
with:
name: legado apk
2021-08-05 22:16:18 +08:00
path: ${{ github.workspace }}/apk/*.apk
2020-12-09 11:44:36 +08:00
- name: Upload App To Lanzou
2021-03-12 18:43:51 +08:00
if: ${{ env.ylogin }}
2021-02-27 20:16:46 +08:00
run: |
path="$GITHUB_WORKSPACE/apk/"
python3 $GITHUB_WORKSPACE/.github/scripts/lzy_web.py "$path" "$LANZOU_FOLDER_ID"
2021-08-10 19:38:43 +08:00
echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 分享链接: https://kunfei.lanzoux.com/b0f7pt4ja"
2021-08-09 19:31:33 +08:00
- name: Release
uses: softprops/action-gh-release@59c3b4891632ff9a897f99a91d7bc557467a3a22
with:
name: legado_app_${{ env.RELEASE_VERSION }}
tag_name: ${{ env.RELEASE_VERSION }}
body_path: ${{ github.workspace }}/CHANGELOG.md
draft: false
prerelease: false
files: ${{ github.workspace }}/apk/*.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2021-08-09 22:50:32 +08:00
- name: Push Assets To "release" Branch
run: |
cd $GITHUB_WORKSPACE/apk || exit 1
git init
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b release
git add *.apk
2021-08-09 22:57:47 +08:00
git commit -m "${{ env.RELEASE_VERSION }}"
2021-08-09 22:50:32 +08:00
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git push -f -u origin release
- name: Purge Jsdelivr Cache
run: |
result=$(curl -s https://purge.jsdelivr.net/gh/${{ github.repository }}@release/)
if echo $result |grep -q 'success.*true'; then
echo "jsdelivr缓存更新成功"
else
echo $result
fi