From b1c8a820b55e9b693ae89a237b437d8638f0358e Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Sat, 17 May 2025 12:51:46 -0700 Subject: [PATCH] feat(ci): update build workflows --- .github/workflows/build.yml | 18 +++--- .github/workflows/release.yml | 77 ++++++++++-------------- .github/workflows/wrapper-validation.yml | 6 +- 3 files changed, 41 insertions(+), 60 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 849fba3..2d344ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,8 @@ -name: Build APK +name: Build Debug on: push: - branches: - - '*' pull_request: - branches: - - '*' workflow_dispatch: permissions: @@ -18,15 +14,15 @@ jobs: steps: - uses: actions/checkout@v4 - - name: set up JDK 17 - uses: actions/setup-java@v2 + - name: set up JDK 21 + uses: actions/setup-java@v4 with: - java-version: 17 - distribution: 'zulu' - cache: 'gradle' + java-version: 21 + distribution: zulu + cache: "gradle" - name: Build project with Gradle - run: chmod +x ./gradlew && ./gradlew :app:assembleDebug + run: chmod +x ./gradlew && ./gradlew :app:assembleDebug --stacktrace - name: Upload apk as artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a22bb0b..a189ced 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,73 +2,58 @@ name: Publish Release on: push: - branches: - - 'release' + tags: [ "v*.*.*" ] workflow_dispatch: +concurrency: + group: "release" + cancel-in-progress: true + +permissions: + contents: write + jobs: publish: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 + + - name: Setup JDK 21 + uses: actions/setup-java@v4 with: - persist-credentials: true - ref: release - path: src - - - name: Check target version - id: version - run: | - cd $GITHUB_WORKSPACE/src - version=$(cat app/build.gradle.kts | grep -E 'versionName = "' | cut -d \" -f 2) - version="v$version" - if git show-ref --tags --quiet --verify -- "refs/tags/$version" >/dev/null; then - echo "Git tag $version already exists, failing to publish"; - exit 1 - else - echo "::set-output name=release_tag::$version" - fi - - - name: Setup Android SDK - uses: android-actions/setup-android@v2 - - - name: Setup JDK 17 - uses: actions/setup-java@v2 - with: - java-version: 17 + java-version: 21 distribution: zulu - cache: gradle + cache: "gradle" - name: Build Manager env: SIGNING_KEY_ALIAS: ${{ secrets.keyAlias }} SIGNING_KEY_PASSWORD: ${{ secrets.keyPassword }} SIGNING_STORE_PASSWORD: ${{ secrets.keystorePassword }} + SIGNING_STORE_FILE: ${{ github.workspace }}/release.keystore run: | - cd $GITHUB_WORKSPACE/src - echo "${{ secrets.keystore }}" | base64 -d > ../../release.keystore + echo "${{ secrets.keystore }}" | base64 -d > release.keystore + chmod +x ./gradlew && ./gradlew :app:packageRelease --stacktrace + rm release.keystore - chmod +x gradlew - ./gradlew :app:packageRelease + - name: Upload apk as artifact + uses: actions/upload-artifact@v4 + with: + name: app + if-no-files-found: error + path: app/build/outputs/apk/release/app-release.apk - rm ../../release.keystore - - - name: Release + - name: Publish Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - cd $GITHUB_WORKSPACE/src - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" - - tag="${{ steps.version.outputs.release_tag }}" - git tag "$tag" - git push origin "$tag" - apk_file="aliucord-manager-$tag.apk" - mv -T ./app/build/outputs/apk/release/app-release.apk "../$apk_file" + mv -T ./app/build/outputs/apk/release/app-release.apk "./$apk_file" gh release create "$tag" \ --title "Aliucord Manager $tag" \ + --generate-notes \ + --verify-tag \ + --fail-on-no-commits \ "../$apk_name" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/wrapper-validation.yml b/.github/workflows/wrapper-validation.yml index 32c785a..06880cc 100644 --- a/.github/workflows/wrapper-validation.yml +++ b/.github/workflows/wrapper-validation.yml @@ -4,11 +4,11 @@ on: workflow_dispatch: push: paths: - - gradle/** - - gradlew.* + - gradle/wrapper/** + - gradlew* pull_request: paths: - - gradle/** + - gradle/wrapper/** - gradlew* jobs: