|
| 1 | +name: Release Build |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + tag: |
| 6 | + description: 'Release Tag' |
| 7 | + required: true |
| 8 | + upload: |
| 9 | + description: 'Upload: If want ignore' |
| 10 | + required: false |
| 11 | + publish: |
| 12 | + description: 'Publish: If want ignore' |
| 13 | + required: false |
| 14 | + play: |
| 15 | + description: 'Play: If want ignore' |
| 16 | + required: false |
| 17 | +jobs: |
| 18 | + libcore: |
| 19 | + name: Native Build (LibCore) |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v3 |
| 24 | + - name: Golang Status |
| 25 | + run: find buildScript libcore/*.sh | xargs cat | sha1sum > golang_status |
| 26 | + - name: Libcore Status |
| 27 | + run: git ls-files libcore | xargs cat | sha1sum > libcore_status |
| 28 | + - name: LibCore Cache |
| 29 | + id: cache |
| 30 | + uses: actions/cache@v3 |
| 31 | + with: |
| 32 | + path: | |
| 33 | + app/libs/libcore.aar |
| 34 | + key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }} |
| 35 | + - name: Golang Cache |
| 36 | + if: steps.cache.outputs.cache-hit != 'true' |
| 37 | + uses: actions/cache@v3 |
| 38 | + with: |
| 39 | + path: build/golang |
| 40 | + key: go-${{ hashFiles('.github/workflows/*', 'golang_status') }} |
| 41 | + - name: Native Build |
| 42 | + if: steps.cache.outputs.cache-hit != 'true' |
| 43 | + run: ./run init action go && ./run lib core |
| 44 | + build: |
| 45 | + name: Build OSS APK |
| 46 | + runs-on: ubuntu-latest |
| 47 | + needs: |
| 48 | + - libcore |
| 49 | + steps: |
| 50 | + - name: Checkout |
| 51 | + uses: actions/checkout@v3 |
| 52 | + - name: Golang Status |
| 53 | + run: find buildScript libcore/*.sh | xargs cat | sha1sum > golang_status |
| 54 | + - name: Libcore Status |
| 55 | + run: git ls-files libcore | xargs cat | sha1sum > libcore_status |
| 56 | + - name: LibCore Cache |
| 57 | + uses: actions/cache@v3 |
| 58 | + with: |
| 59 | + path: | |
| 60 | + app/libs/libcore.aar |
| 61 | + key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }} |
| 62 | + - name: Gradle cache |
| 63 | + uses: actions/cache@v3 |
| 64 | + with: |
| 65 | + path: ~/.gradle |
| 66 | + key: gradle-oss-${{ hashFiles('**/*.gradle.kts') }} |
| 67 | + - name: Gradle Build |
| 68 | + env: |
| 69 | + BUILD_PLUGIN: none |
| 70 | + run: | |
| 71 | + echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 72 | + echo "ndk.dir=${ANDROID_HOME}/ndk/25.0.8775105" >> local.properties |
| 73 | + export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" |
| 74 | + ./run init action gradle |
| 75 | + ./gradlew app:assembleOssRelease |
| 76 | + APK=$(find app/build/outputs/apk -name '*arm64-v8a*.apk') |
| 77 | + APK=$(dirname $APK) |
| 78 | + echo "APK=$APK" >> $GITHUB_ENV |
| 79 | + - uses: actions/upload-artifact@v3 |
| 80 | + with: |
| 81 | + name: APKs |
| 82 | + path: ${{ env.APK }} |
| 83 | + publish: |
| 84 | + name: Publish Release |
| 85 | + if: github.event.inputs.publish != 'y' |
| 86 | + runs-on: ubuntu-latest |
| 87 | + needs: build |
| 88 | + steps: |
| 89 | + - name: Checkout |
| 90 | + uses: actions/checkout@v3 |
| 91 | + - name: Donwload Artifacts |
| 92 | + uses: actions/download-artifact@v3 |
| 93 | + with: |
| 94 | + name: APKs |
| 95 | + path: artifacts |
| 96 | + - name: Release |
| 97 | + run: | |
| 98 | + wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz |
| 99 | + tar -xvf ghr.tar.gz |
| 100 | + mv ghr*linux_amd64/ghr . |
| 101 | + mkdir apks |
| 102 | + find artifacts -name "*.apk" -exec cp {} apks \; |
| 103 | + ./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks |
| 104 | + upload: |
| 105 | + name: Upload Release |
| 106 | + if: github.event.inputs.upload != 'y' |
| 107 | + runs-on: ubuntu-latest |
| 108 | + needs: build |
| 109 | + steps: |
| 110 | + - name: Donwload Artifacts |
| 111 | + uses: actions/download-artifact@v3 |
| 112 | + with: |
| 113 | + name: APKs |
| 114 | + path: artifacts |
| 115 | + - name: Release |
| 116 | + run: | |
| 117 | + mkdir apks |
| 118 | + find artifacts -name "*.apk" -exec cp {} apks \; |
| 119 | +
|
| 120 | + function upload() { |
| 121 | + for apk in $@; do |
| 122 | + echo ">> Uploading $apk" |
| 123 | + curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \ |
| 124 | + -X POST \ |
| 125 | + -F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \ |
| 126 | + -F document="@$apk" \ |
| 127 | + --silent --show-error --fail >/dev/null & |
| 128 | + done |
| 129 | + for job in $(jobs -p); do |
| 130 | + wait $job || exit 1 |
| 131 | + done |
| 132 | + } |
| 133 | + upload apks/* |
| 134 | + play: |
| 135 | + name: Build Play Bundle |
| 136 | + if: github.event.inputs.play != 'y' |
| 137 | + runs-on: ubuntu-latest |
| 138 | + needs: |
| 139 | + - libcore |
| 140 | + steps: |
| 141 | + - name: Checkout |
| 142 | + uses: actions/checkout@v3 |
| 143 | + - name: Golang Status |
| 144 | + run: find buildScript libcore/*.sh | xargs cat | sha1sum > golang_status |
| 145 | + - name: Libcore Status |
| 146 | + run: git ls-files libcore | xargs cat | sha1sum > libcore_status |
| 147 | + - name: LibCore Cache |
| 148 | + uses: actions/cache@v3 |
| 149 | + with: |
| 150 | + path: | |
| 151 | + app/libs/libcore.aar |
| 152 | + key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }} |
| 153 | + - name: Gradle cache |
| 154 | + uses: actions/cache@v3 |
| 155 | + with: |
| 156 | + path: ~/.gradle |
| 157 | + key: gradle-play-${{ hashFiles('**/*.gradle.kts') }} |
| 158 | + - name: Checkout Library |
| 159 | + run: | |
| 160 | + git submodule update --init 'app/*' |
| 161 | + - name: Gradle Build |
| 162 | + run: | |
| 163 | + echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 164 | + echo "ndk.dir=${ANDROID_HOME}/ndk/25.0.8775105" >> local.properties |
| 165 | + export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" |
| 166 | + ./run init action gradle |
| 167 | + ./gradlew bundlePlayRelease |
| 168 | + - uses: actions/upload-artifact@v3 |
| 169 | + with: |
| 170 | + name: AAB |
| 171 | + path: app/build/outputs/bundle/playRelease/app-play-release.aab |
0 commit comments