-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Build Manager | ||
|
||
on: | ||
push: | ||
tags: [ "*" ] | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-manager: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Generate version | ||
id: parse_version | ||
run: | | ||
COMMIT_NUM=$(git rev-list --count HEAD) | ||
VERSION=$(echo "$COMMIT_NUM + 200 + 10000" | bc) | ||
echo "Generated Version: $VERSION" | ||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | ||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
with: | ||
gradle-home-cache-cleanup: true | ||
|
||
- name: Build with Gradle | ||
run: | | ||
chmod +x gradlew | ||
./gradlew build | ||
- name: Sign Release | ||
env: | ||
SIGNING_KEY: ${{ secrets.SIGNING_KEY }} | ||
if: ${{ env.SIGNING_KEY != '' }} | ||
continue-on-error: true | ||
uses: kevin-david/zipalign-sign-android-release@v1.1 | ||
id: sign_app | ||
with: | ||
releaseDirectory: app/build/outputs/apk/release | ||
signingKeyBase64: ${{ secrets.SIGNING_KEY }} | ||
alias: ${{ secrets.ALIAS }} | ||
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | ||
keyPassword: ${{ secrets.KEY_PASSWORD }} | ||
- name: Upload build artifact2 | ||
env: | ||
SIGNING_KEY: ${{ secrets.SIGNING_KEY }} | ||
if: ${{ env.SIGNING_KEY == '' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: myinjector | ||
path: app/build/outputs/apk/release/* | ||
- name: Upload build artifact | ||
env: | ||
SIGNING_KEY: ${{ secrets.SIGNING_KEY }} | ||
if: ${{ env.SIGNING_KEY != '' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: myinjector | ||
path: ${{steps.sign_app.outputs.signedReleaseFile}} | ||
- name: Post to channel | ||
if: ${{github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag'}} | ||
env: | ||
BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | ||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | ||
COMMIT_URL: ${{ github.event.head_commit.url }} | ||
COMMIT_ID: ${{ github.event.head_commit.id }} | ||
run: | | ||
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then | ||
OUTPUT="app/build/outputs/apk/release" | ||
export Release=$(find $OUTPUT -name "*.apk") | ||
URL=$(python3 .github/scripts/telegram_url.py -1002058433411) | ||
curl -v "$URL" -F Release=@${{ steps.sign_app.outputs.signedReleaseFile }} | ||
URL=$(python3 .github/scripts/telegram_url.py -1001910818234) | ||
curl -v "$URL" -F Release=@${{ steps.sign_app.outputs.signedReleaseFile }} | ||
fi | ||
- name: Release apk | ||
env: | ||
SIGNING_KEY: ${{ secrets.SIGNING_KEY }} | ||
if: ${{ env.SIGNING_KEY != '' && github.ref_type == 'tag' }} | ||
continue-on-error: true | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
token: ${{ github.token }} | ||
tag: ${{ steps.parse_version.outputs.VERSION }} | ||
artifacts: ${{steps.sign_app.outputs.signedReleaseFile}} | ||
generateReleaseNotes: true | ||
makeLatest: true | ||
replacesArtifacts: true |