name: Android Release on: push: branches: - master jobs: release: runs-on: ubuntu-latest steps: # ------------------- Checkout ------------------- - name: Checkout uses: https://git.daemonlord.ru/actions/checkout@v4 with: fetch-depth: 0 tags: true # ------------------- Setup JDK ------------------- - name: Set up JDK 17 uses: https://git.daemonlord.ru/actions/setup-java@v4 with: distribution: temurin java-version: 17 # ------------------- Install Node.js ------------------- - name: Install Node.js run: | curl -fsSL https://deb.nodesource.com/setup_22.x | bash - apt-get install -y nodejs # ------------------- Extract version ------------------- - name: Extract versionName id: extract_version run: | VERSION=$(grep -oP 'versionName\s+"[^"]+"' app/build.gradle | head -n1 | cut -d'"' -f2 | tr -d '\r\n') echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Detected version: $VERSION" # ------------------- Stop if already released ------------------- - name: Stop if version already released id: stop run: | VERSION=${{ steps.extract_version.outputs.version }} if git show-ref --tags --quiet --verify "refs/tags/$VERSION"; then echo "Version $VERSION already released, stopping job." echo "CONTINUE=false" >> $GITHUB_ENV else echo "Version $VERSION not released yet, continuing workflow..." echo "CONTINUE=true" >> $GITHUB_ENV fi # ------------------- Decode keystore ------------------- - name: Decode keystore if: env.CONTINUE == 'true' run: | echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > app/release.keystore - name: Make Gradlew executable if: env.CONTINUE == 'true' run: chmod +x ./gradlew # ------------------- Set up Android SDK ------------------- - name: Set up Android SDK if: env.CONTINUE == 'true' uses: https://git.daemonlord.ru/actions/setup-android@v3 # ------------------- Build Release APK ------------------- - name: Build Release APK if: env.CONTINUE == 'true' env: KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} KEY_ALIAS: ${{ secrets.KEY_ALIAS }} KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} run: ./gradlew --no-daemon assembleRelease # ------------------- Git tag ------------------- - name: Create git tag if: env.CONTINUE == 'true' run: | git tag $VERSION git push origin $VERSION # ------------------- Gitea release ------------------- - name: Create Gitea Release if: env.CONTINUE == 'true' uses: https://git.daemonlord.ru/actions/gitea-release-action@v1 with: server_url: https://git.daemonlord.ru repository: ${{ gitea.repository }} token: ${{ secrets.API_TOKEN }} tag_name: ${{ steps.extract_version.outputs.version }} name: Release ${{ steps.extract_version.outputs.version }} body: | Android release ${{ steps.extract_version.outputs.version }} files: | app/build/outputs/apk/release/*.apk