legado/.github/workflows/release.yml

141 lines
4.8 KiB
YAML
Raw Normal View History

name: Release Build
2022-01-03 23:59:44 +08:00
on:
# push:
# branches:
# - master
# paths:
# - 'CHANGELOG.md'
workflow_dispatch:
2022-01-03 23:59:44 +08:00
jobs:
2022-03-16 21:16:04 +08:00
prepare:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
outputs:
version: ${{ steps.set-ver.outputs.version }}
play: ${{ steps.check.outputs.play }}
sign: ${{ steps.check.outputs.sign }}
steps:
- id: set-ver
run: |
echo "version=$(date -d "8 hour" -u +3.%y.%m%d%H)" >> $GITHUB_OUTPUT
2022-03-16 21:16:04 +08:00
- id: check
run: |
if [ ! -z "${{ secrets.RELEASE_KEY_STORE }}" ]; then
echo "sign=yes" >> $GITHUB_OUTPUT
2022-03-16 21:16:04 +08:00
fi
if [ ! -z "${{ secrets.SERVICE_ACCOUNT_JSON }}" ]; then
echo "play=yes" >> $GITHUB_OUTPUT
2022-03-16 21:16:04 +08:00
fi
2022-01-03 23:59:44 +08:00
build:
2022-03-16 21:16:04 +08:00
needs: prepare
if: ${{ needs.prepare.outputs.sign }}
strategy:
matrix:
product: [ app, google ]
fail-fast: false
2022-01-03 23:59:44 +08:00
runs-on: ubuntu-latest
env:
2022-03-16 21:16:04 +08:00
product: ${{ matrix.product }}
VERSION: ${{ needs.prepare.outputs.version }}
play: ${{ needs.prepare.outputs.play }}
2022-01-03 23:59:44 +08:00
steps:
- uses: actions/checkout@v4
2022-03-05 15:38:40 +08:00
2023-04-16 08:45:25 +08:00
- name: Set up JDK 17
uses: actions/setup-java@v4
2023-04-16 08:45:25 +08:00
with:
distribution: 'temurin'
java-version: 17
2022-01-03 23:59:44 +08:00
- name: Release Apk Sign
run: |
# not use this output
# echo "KeyStore=yes" >> $GITHUB_OUTPUT
2024-03-14 20:14:32 +08:00
echo -e "\n" >> gradle.properties
2022-03-16 21:16:04 +08:00
echo RELEASE_KEY_ALIAS='${{ secrets.RELEASE_KEY_ALIAS }}' >> gradle.properties
echo RELEASE_KEY_PASSWORD='${{ secrets.RELEASE_KEY_PASSWORD }}' >> gradle.properties
echo RELEASE_STORE_PASSWORD='${{ secrets.RELEASE_STORE_PASSWORD }}' >> gradle.properties
echo RELEASE_STORE_FILE='./key.jks' >> gradle.properties
echo ${{ secrets.RELEASE_KEY_STORE }} | base64 --decode > $GITHUB_WORKSPACE/app/key.jks
2022-03-05 15:38:40 +08:00
2022-01-03 23:59:44 +08:00
- name: Unify Version Name
run: |
echo "统一版本号"
2022-03-16 21:16:04 +08:00
sed "/def version/c def version = \"${{ env.VERSION }}\"" $GITHUB_WORKSPACE/app/build.gradle -i
2022-03-05 15:38:40 +08:00
- name: Set up Gradle
2024-02-02 07:57:54 +08:00
uses: gradle/actions/setup-gradle@v3
2022-01-03 23:59:44 +08:00
- name: Build With Gradle
run: |
2022-03-16 21:16:04 +08:00
echo "开始进行${{ env.product }}构建"
2022-01-03 23:59:44 +08:00
chmod +x gradlew
2022-03-16 21:16:04 +08:00
./gradlew assemble${{ env.product }}release --build-cache --parallel --daemon --warning-mode all
2022-03-05 15:38:40 +08:00
2022-01-03 23:59:44 +08:00
- name: Organize the Files
run: |
mkdir -p ${{ github.workspace }}/apk/
cp -rf ${{ github.workspace }}/app/build/outputs/apk/*/*/*.apk ${{ github.workspace }}/apk/
2022-03-16 21:16:04 +08:00
2022-01-03 23:59:44 +08:00
- name: Upload App To Artifact
uses: actions/upload-artifact@v4
2022-01-03 23:59:44 +08:00
with:
2022-03-16 21:16:04 +08:00
name: legado_${{ env.product }}
2022-01-03 23:59:44 +08:00
path: ${{ github.workspace }}/apk/*.apk
2022-03-05 15:38:40 +08:00
2022-01-03 23:59:44 +08:00
- name: Release
2022-03-16 21:16:04 +08:00
if: ${{ env.product == 'app' }}
2024-03-17 11:49:16 +08:00
uses: softprops/action-gh-release@v2
2022-01-03 23:59:44 +08:00
with:
2022-03-16 21:16:04 +08:00
name: legado_app_${{ env.VERSION }}
tag_name: ${{ env.VERSION }}
2022-01-03 23:59:44 +08:00
body_path: ${{ github.workspace }}/CHANGELOG.md
draft: false
prerelease: false
2022-03-16 21:16:04 +08:00
files: ${{ github.workspace }}/apk/legado_app_*.apk
2022-01-03 23:59:44 +08:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2022-03-16 21:16:04 +08:00
- name: Prepare For GooglePlay
if: env.product == 'google' && env.play == 'yes'
run: |
mkdir -p ReleaseNotes
ln -s ${{ github.workspace }}/CHANGELOG.md ReleaseNotes/whatsnew-en-US
ln -s ${{ github.workspace }}/CHANGELOG.md ReleaseNotes/whatsnew-zh-CN
- name: Release To GooglePlay
if: env.product == 'google' && env.play == 'yes'
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: io.legado.play
releaseFiles: ${{ github.workspace }}/apk/legado_google_*.apk
track: production
whatsNewDirectory: ${{ github.workspace }}/ReleaseNotes
2022-01-03 23:59:44 +08:00
- name: Push Assets To "release" Branch
2022-03-17 12:38:19 +08:00
if: ${{ github.actor == 'gedoor' }}
2022-01-03 23:59:44 +08:00
run: |
2022-03-16 21:16:04 +08:00
cd $GITHUB_WORKSPACE/apk/
git init
git checkout -b release
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git remote add origin "https://${{ github.actor }}:${{ secrets.ACTIONS_TOKEN }}@github.com/${{ github.actor }}/release"
2022-01-03 23:59:44 +08:00
git add *.apk
2022-03-16 21:16:04 +08:00
git commit -m "${{ env.VERSION }}"
2022-01-03 23:59:44 +08:00
git push -f -u origin release
2022-03-16 21:16:04 +08:00
2022-01-03 23:59:44 +08:00
- name: Purge Jsdelivr Cache
2022-03-17 12:38:19 +08:00
if: ${{ github.actor == 'gedoor' }}
2022-01-03 23:59:44 +08:00
run: |
result=$(curl -s https://purge.jsdelivr.net/gh/${{ github.actor }}/release@release/)
2022-01-03 23:59:44 +08:00
if echo $result |grep -q 'success.*true'; then
echo "jsdelivr缓存更新成功"
else
echo $result
fi