Files
Exclave/.github/workflows/release.yml
2021-05-21 18:25:35 +08:00

319 lines
10 KiB
YAML

name: Release Build
on:
workflow_dispatch:
inputs:
tag:
description: 'Release Tag'
required: true
upload:
description: 'Upload: If want ignore'
required: false
publish:
description: 'Publish: If want ignore'
required: false
play:
description: 'Play: If want ignore'
required: false
jobs:
check:
name: Check Access
runs-on: ubuntu-latest
steps:
- name: "Check access"
uses: "lannonbr/repo-permission-check-action@2.0.0"
with:
permission: "write"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
core:
name: Native Build (Core)
runs-on: ubuntu-latest
needs: check
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch Status
run: git submodule status 'library/core/*' > core_status
- name: Core Cache
id: cache
uses: actions/cache@v2
with:
path: |
app/libs/core-release.aar
key: ${{ hashFiles('core_status') }}
- name: Gradle cache
uses: actions/cache@v2
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ~/.gradle
key: native-${{ hashFiles('**/*.gradle') }}
- name: Native Build
if: steps.cache.outputs.cache-hit != 'true'
run: |
echo "sdk.dir=${ANDROID_HOME}" > local.properties
echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
./run lib core
v2ray:
name: Native Build (V2Ray)
runs-on: ubuntu-latest
needs: check
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch Status
run: git submodule status library/v2ray > v2ray_status
- name: V2Ray Cache
id: cache
uses: actions/cache@v2
with:
path: |
app/libs/libv2ray.aar
key: ${{ hashFiles('bin/lib/v2ray/*', 'v2ray_status') }}
- name: Install Golang
uses: actions/setup-go@v2
if: steps.cache.outputs.cache-hit != 'true'
with:
go-version: 1.16
- name: Gradle cache
uses: actions/cache@v2
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ~/.gradle
key: native-${{ hashFiles('**/*.gradle') }}
- name: Native Build
if: steps.cache.outputs.cache-hit != 'true'
run: |
echo "sdk.dir=${ANDROID_HOME}" > local.properties
echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
./run lib v2ray
shadowsocks:
name: Native Build (Shadowsocks)
runs-on: ubuntu-latest
needs: check
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch Status
run: git submodule status 'library/shadowsocks/*' > shadowsocks_status
- name: Shadowsocks Cache
id: cache
uses: actions/cache@v2
with:
path: |
app/libs/shadowsocks-release.aar
key: ${{ hashFiles('library/shadowsocks/build.gradle.kts', 'shadowsocks_status') }}
- name: Install Rust
if: steps.cache.outputs.cache-hit != 'true'
run: ./run init action shadowsocks
- name: Gradle cache
uses: actions/cache@v2
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ~/.gradle
key: native-${{ hashFiles('**/*.gradle') }}
- name: Native Build
if: steps.cache.outputs.cache-hit != 'true'
run: |
echo "sdk.dir=${ANDROID_HOME}" > local.properties
echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
./run lib shadowsocks
shadowsocksr:
name: Native Build (ShadowsocksR)
runs-on: ubuntu-latest
needs: check
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch Status
run: git submodule status 'library/shadowsocksr/*' > shadowsocksr_status
- name: ShadowsocksR Cache
id: cache
uses: actions/cache@v2
with:
path: |
app/libs/shadowsocksr-release.aar
key: ${{ hashFiles('shadowsocksr_status') }}
- name: Gradle cache
uses: actions/cache@v2
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ~/.gradle
key: native-${{ hashFiles('**/*.gradle') }}
- name: Native Build
if: steps.cache.outputs.cache-hit != 'true'
run: |
echo "sdk.dir=${ANDROID_HOME}" > local.properties
echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
./run lib shadowsocksr
build:
name: Gradle Build
runs-on: ubuntu-latest
needs:
- core
- v2ray
- shadowsocks
- shadowsocksr
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch Status
run: |
git submodule status 'library/core/*' > core_status
git submodule status 'library/shadowsocks/*' > shadowsocks_status
git submodule status 'library/shadowsocksr/*' > shadowsocksr_status
git submodule status library/v2ray > v2ray_status
- name: Core Cache
uses: actions/cache@v2
with:
path: |
app/libs/core-release.aar
key: ${{ hashFiles('core_status') }}
- name: V2Ray Cache
uses: actions/cache@v2
with:
path: |
app/libs/libv2ray.aar
key: ${{ hashFiles('bin/lib/v2ray/*', 'v2ray_status') }}
- name: Shadowsocks Cache
uses: actions/cache@v2
with:
path: |
app/libs/shadowsocks-release.aar
key: ${{ hashFiles('library/shadowsocks/build.gradle.kts', 'shadowsocks_status') }}
- name: ShadowsocksR Cache
uses: actions/cache@v2
with:
path: |
app/libs/shadowsocksr-release.aar
key: ${{ hashFiles('shadowsocksr_status') }}
- name: Gradle cache
uses: actions/cache@v2
with:
path: ~/.gradle
key: gradle-${{ hashFiles('**/*.gradle') }}
- name: Checkout Library
run: |
git submodule update --init 'app/*'
- name: Debug Build
run: |
echo "sdk.dir=${ANDROID_HOME}" > local.properties
echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
./run update_assets
./gradlew app:assembleOssRelease
APK=$(find app/build/outputs/apk -name '*arm64-v8a*.apk')
APK=$(dirname $APK)
echo "APK=$APK" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
with:
name: SagetNet
path: ${{ env.APK }}
publish:
name: Publish Release
if: github.event.inputs.publish != 'y'
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Donwload Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Release
run: |
wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz
tar -xvf ghr.tar.gz
mv ghr*linux_amd64/ghr .
mkdir apks
find artifacts -name "*.apk" -exec cp {} apks \;
./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks
upload:
name: Upload Release
if: github.event.inputs.upload != 'y'
runs-on: ubuntu-latest
needs: build
steps:
- name: Donwload Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Release
run: |
mkdir apks
find artifacts -name "*.apk" -exec cp {} apks \;
function upload() {
for apk in $@; do
echo ">> Uploading $apk"
curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \
-X POST \
-F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \
-F document="@$apk" \
--silent --show-error --fail >/dev/null &
done
for job in $(jobs -p); do
wait $job || exit 1
done
}
upload apks/*.apk
play:
name: Publish to Play Store
if: github.event.inputs.play != 'y'
runs-on: ubuntu-latest
needs:
- core
- v2ray
- shadowsocks
- shadowsocksr
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Fetch Status
run: |
git submodule status 'library/core/*' > core_status
git submodule status 'library/shadowsocks/*' > shadowsocks_status
git submodule status 'library/shadowsocksr/*' > shadowsocksr_status
git submodule status library/v2ray > v2ray_status
- name: Core Cache
uses: actions/cache@v2
with:
path: |
app/libs/core-release.aar
key: ${{ hashFiles('core_status') }}
- name: V2Ray Cache
uses: actions/cache@v2
with:
path: |
app/libs/libv2ray.aar
key: ${{ hashFiles('bin/lib/v2ray/*', 'v2ray_status') }}
- name: Shadowsocks Cache
uses: actions/cache@v2
with:
path: |
app/libs/shadowsocks-release.aar
key: ${{ hashFiles('library/shadowsocks/build.gradle.kts', 'shadowsocks_status') }}
- name: ShadowsocksR Cache
uses: actions/cache@v2
with:
path: |
app/libs/shadowsocksr-release.aar
key: ${{ hashFiles('shadowsocksr_status') }}
- name: Gradle cache
uses: actions/cache@v2
with:
path: ~/.gradle
key: gradle-${{ hashFiles('**/*.gradle') }}
- name: Checkout Library
run: |
git submodule update --init 'app/*'
- name: Debug Build
run: |
echo "sdk.dir=${ANDROID_HOME}" > local.properties
echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties
export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
./run update_assets
cat > service_account_credentials.json << EOF
${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }}"
EOF
./gradlew app:publishPlayRelease
echo "APK=$APK" >> $GITHUB_ENV