Skip to content
name: Dwei1120 Build self
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check New Commit
run: |
upstreamCode=https://github.com/Dwei1120/tv2.6
echo "upstreamCode=$upstreamCode" >> $GITHUB_ENV
commit=$(curl -sL $upstreamCode/commits/dev |grep -o '/Dwei1120/tv2.6/commit/[a-z0-9]\+' |head -1 | cut -d\/ -f5)
if ! git log --oneline |grep -q "$commit"; then
echo "commit=$commit" >> $GITHUB_ENV
echo "commitS=${commit:0:7}" >> $GITHUB_ENV
fi
- name: Checkout Source Code and Zip
if: ${{ env.commit }}
run: |
git clone ${{ env.upstreamCode }} TVBoxOSC
cd TVBoxOSC
git checkout ${{ env.commit }}
echo "tag=$(git log --date=format:'%Y%m%d-%H%M' --pretty=format:%cd ${{ env.commitS }} -1)" >> $GITHUB_ENV
zip -q -x ".git/*" -r ${{ env.commitS }}-source.zip .
- name: Release Apk Sign
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 }}/.github/workflows/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
- name: Build Debug With Gradle
if: ${{ env.commit }}
working-directory: TVBoxOSC
run: |
chmod +x gradlew
./gradlew assembledebug --build-cache --parallel --daemon --warning-mode all
- name: Prepare App
if: ${{ env.commit }}
working-directory: TVBoxOSC
run: |
rm -rf apk/
mkdir -p apk/
for file in `find ~ -name "*debug*.apk" -print`; do
mv "$file" apk/TVBox_Dwei1120_${{ env.tag }}_Debug.apk
done
- name: Upload App To Artifact
uses: actions/upload-artifact@v3
if: ${{ env.commit }}
with:
name: TVBox_Dwei1120_Debug
path: TVBoxOSC/apk/*
- name: Release and Upload Assets(release area)
uses: softprops/action-gh-release@v1
if: ${{ env.commit }}
with:
name: ${{ env.tag }}
tag_name: ${{ env.tag }}
body: ${{ env.commit }}
files: |
TVBoxOSC/apk/*
TVBoxOSC/${{ env.commitS }}-source.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}