Skip to content

Build

Build #17027

Workflow file for this run

name: Build
on:
schedule:
- cron: 6 */3 * * *
# push:
# branches:
# - main
workflow_dispatch:
inputs:
arm64_support:
description: 'arm64 is supported, but ijk decoder is not supported.'
required: false
type: boolean
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- userName: q215613905
repoUrl: https://github.com/q215613905/TVBoxOS
branchName: main
javaVersion: 8
- userName: takagen99
repoUrl: https://github.com/takagen99/Box
branchName: main
javaVersion: 17
env:
local_xwalk: ${{ secrets.LOCAL_XWALK }}
# 登录蓝奏云后在控制台运行document.cookie
ylogin: ${{ secrets.YLOGIN }}
phpdisk_info: ${{ secrets.PHPDISK_INFO }}
# 蓝奏云里的文件夹ID
lanzou_folder_id: 5848262
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
path: actions
- name: Get The Lastest Commit
working-directory: actions
run: |
commit=$(curl -sL ${{ matrix.repoUrl }}/commits/${{ matrix.branchName }} |grep -o '/commit/[a-z0-9]\+' |head -1 | cut -d\/ -f3)
# if ! git log --oneline |grep -q "$commit"; then
if ! grep -q "$commit" ./log/${{ matrix.userName }}.txt; then
echo "commit=$commit" >> $GITHUB_ENV
echo "commit_id=${commit:0:7}" >> $GITHUB_ENV
fi
- name: Clone Source Code
if: ${{ env.commit }}
run: |
git clone -b ${{ matrix.branchName }} ${{ matrix.repoUrl }} TVBoxOSC
- name: Compress Source Code
if: ${{ env.commit }}
working-directory: TVBoxOSC
run: |
echo "tag=$(git log --date=format:'%Y.%m%d.%H%M' --pretty=format:%cd ${{ env.commit_id }} -1)" >> $GITHUB_ENV
echo "update_time=$(git log --date=format:'%Y/%m/%d %H:%M' --pretty=format:%cd ${{ env.commit_id }} -1)" >> $GITHUB_ENV
# tar -cJf source-${{ env.commitS }}.tar.xz --exclude=.git --exclude=.github *
zip -q -x ".git/*" -r ${{ matrix.userName }}_${{ env.commit_id }}_src.zip .
- name: Arm64 Support Beta
if: ${{ inputs.arm64_support }}
working-directory: TVBoxOSC
run: |
sed -i "/armeabi-v7a[\'\"]$/s#\$#, 'arm64-v8a'#" app/build.gradle
sed -i "/armeabi-v7a[\'\"]$/s#\$#, 'arm64-v8a'#" player/build.gradle
- name: Add Sign Info
if: ${{ env.commit }}
working-directory: TVBoxOSC
run: |
signingConfigs='ICAgIHNpZ25pbmdDb25maWdzIHtcCiAgICAgICAgaWYgKHByb2plY3QuaGFzUHJvcGVydHkoIlJFTEVBU0VfU1RPUkVfRklMRSIpKSB7XAogICAgICAgICAgICBteUNvbmZpZyB7XAogICAgICAgICAgICAgICAgc3RvcmVGaWxlIGZpbGUoUkVMRUFTRV9TVE9SRV9GSUxFKVwKICAgICAgICAgICAgICAgIHN0b3JlUGFzc3dvcmQgUkVMRUFTRV9TVE9SRV9QQVNTV09SRFwKICAgICAgICAgICAgICAgIGtleUFsaWFzIFJFTEVBU0VfS0VZX0FMSUFTXAogICAgICAgICAgICAgICAga2V5UGFzc3dvcmQgUkVMRUFTRV9LRVlfUEFTU1dPUkRcCiAgICAgICAgICAgICAgICB2MVNpZ25pbmdFbmFibGVkIHRydWVcCiAgICAgICAgICAgICAgICB2MlNpZ25pbmdFbmFibGVkIHRydWVcCiAgICAgICAgICAgICAgICBlbmFibGVWM1NpZ25pbmcgPSB0cnVlXAogICAgICAgICAgICAgICAgZW5hYmxlVjRTaWduaW5nID0gdHJ1ZVwKICAgICAgICAgICAgfVwKICAgICAgICB9XAogICAgfVwKXA=='
signingConfig='ICAgICAgICAgICAgaWYgKHByb2plY3QuaGFzUHJvcGVydHkoIlJFTEVBU0VfU1RPUkVfRklMRSIpKSB7XAogICAgICAgICAgICAgICAgc2lnbmluZ0NvbmZpZyBzaWduaW5nQ29uZmlncy5teUNvbmZpZ1wKICAgICAgICAgICAgfVwK'
signingConfigs="$(echo "$signingConfigs" |base64 -d )"
signingConfig="$(echo "$signingConfig" |base64 -d )"
sed -i -e "/defaultConfig {/i\\$signingConfigs " -e "/debug {/a\\$signingConfig " -e "/release {/a\\$signingConfig " ./app/build.gradle
cp -f ${{ github.workspace }}/actions/.github/scripts/TVBoxOSC.jks ./app/TVBoxOSC.jks
sed -i '$a\RELEASE_STORE_FILE=./TVBoxOSC.jks' ./gradle.properties
sed -i '$a\RELEASE_KEY_ALIAS=TVBoxOSC' ./gradle.properties
sed -i '$a\RELEASE_STORE_PASSWORD=TVBoxOSC' ./gradle.properties
sed -i '$a\RELEASE_KEY_PASSWORD=TVBoxOSC' ./gradle.properties
version_code=$(git rev-list --count HEAD)
echo "version code: $version_code"
sed -i "/ versionCode/c\\versionCode ${version_code}" ./app/build.gradle
sed -i "/ versionName/c\\versionName '${{ env.tag }}'" ./app/build.gradle
sed -i "/ applicationId/c\\applicationId '${{ matrix.userName }}.tvbox.osc'" ./app/build.gradle
sed -i "/android:text=/c\\ android:text=\"v${{ env.tag }}\\\\n本软件只提供聚合展示功能,所有资源来自网上, 软件不参与任何制作, 上传, 储存, 下载等内容。 软件仅供学习参考, 请于安装后24小时内删除。\\\\n\\\\n打包分发请保留出处\\\\n${{ matrix.repoUrl }}\"" ./app/src/main/res/layout/dialog_about.xml
- name: Fix Xwalk Library
if: ${{ env.commit && env.local_xwalk }}
working-directory: TVBoxOSC
run: |
if grep -q 'crosswalk' build.gradle; then
sed -i "/crosswalk/a\ maven { url 'https://celetor.github.io/crosswalk/releases/crosswalk/android/maven2' }\n maven { url 'https://maven.aliyun.com/repository/jcenter' }" build.gradle
else
sed -i "/jitpack.io/a\ maven { url 'https://celetor.github.io/crosswalk/releases/crosswalk/android/maven2' }\n maven { url 'https://maven.aliyun.com/repository/jcenter' }" build.gradle
fi
- name: Setup JDK
if: ${{ env.commit }}
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.javaVersion }}
- name: Setup Gradle
if: ${{ env.commit }}
uses: gradle/gradle-build-action@v2
with:
cache-disabled: false
- name: Build With Gradle
if: ${{ env.commit }}
working-directory: TVBoxOSC
run: |
chmod +x gradlew
./gradlew assembleRelease --build-cache --parallel --daemon --warning-mode all
- name: Rename App
if: ${{ env.commit }}
working-directory: TVBoxOSC
run: |
rm -rf apk/
mkdir -p apk/
for file in `find . -name "*.apk" -print`; do
filename=$(basename "$file")
if [[ $filename =~ "debug" ]] ; then
echo "ignore: $file"
elif [[ $filename =~ "release" ]] ; then
echo "move and rename: $file"
match_name=${filename##*release}
new_name="TVBox_${{ matrix.userName }}_${{ env.tag }}$match_name"
echo "new_name: $new_name"
mv "$file" "apk/$new_name"
else
echo "only move: $file"
mv "$file" apk/
fi
done
- name: Write Update Changelog
if: ${{ env.commit }}
run: |
cd actions
# myLastCommit=`git log --oneline |grep -o '[a-z0-9]\{40\}' |head -1`
# myLastCommit=$(grep "${{ matrix.userName }}" README.md |grep -o '[a-z0-9]\{40\}')
myLastCommit=$(grep '[a-z0-9]\{40\}' ./log/${{ matrix.userName }}.txt)
echo $myLastCommit
cd ../TVBoxOSC
export LESSCHARSET=utf-8
if [ "${{ env.commit }}" == "${myLastCommit}" ]; then
COMMIT_MESSAGE=$(git log --pretty=format:%B ${{ env.commit_id }} -1 |sed -e 's# \{2,\}#\n#g' -e '/^Merge pull/d' -e 's#"#\\"#g' -e '/^$/d' |cat -n |sort -k2,2 -k1,1n |uniq -f1 |sort -k1,1n |cut -f2- )
else
COMMIT_MESSAGE=$(git log --pretty=format:%B ${{ env.commit_id }}...${myLastCommit:0:7} |sed -e 's# \{2,\}#\n#g' -e '/^Merge pull/d' -e 's#"#\\"#g' -e '/^$/d' |cat -n |sort -k2,2 -k1,1n |uniq -f1 |sort -k1,1n |cut -f2- )
fi
echo -e "Credit: [${{ matrix.userName }}](${{ matrix.repoUrl }})\n${COMMIT_MESSAGE}" > Changelog.txt
echo "$COMMIT_MESSAGE" > desc.txt
- name: Release App
uses: softprops/action-gh-release@v2
if: ${{ env.commit }}
with:
name: ${{ env.tag }}
tag_name: ${{ env.tag }}_${{ matrix.userName }}
body_path: TVBoxOSC/Changelog.txt
files: |
TVBoxOSC/apk/*
TVBoxOSC/${{ matrix.userName }}_${{ env.commit_id }}_src.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit And Push
if: ${{ env.commit }}
working-directory: actions
continue-on-error: true
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git pull
# sed -i "/Update Time/c\\+ Update Time: ${{ env.update_time }}" README.md
# sed -i "/${{ matrix.userName }}/s#Updated: [a-zA-Z0-9]*#Updated: ${{ env.commit }}#" README.md
echo "${{ env.commit }}" > ./log/${{ matrix.userName }}.txt
git add --all
git commit -m "${{ matrix.userName }}_${{ env.commit }}"
git push origin main
- name: Upload App To Lanzou
if: ${{ env.commit && env.ylogin }}
run: python3 ${{ github.workspace }}/actions/.github/scripts/lanzou-api.py "${{ github.workspace }}/TVBoxOSC/apk/" "$lanzou_folder_id" "${{ github.workspace }}/TVBoxOSC/desc.txt"