name: Android Release on: push: branches: - master jobs: release: runs-on: ubuntu-latest steps: - name: Checkout uses: https://git.daemonlord.ru/actions/checkout@v4 with: fetch-depth: 0 tags: true - name: Set up JDK 17 uses: https://git.daemonlord.ru/actions/setup-java@v4 with: distribution: temurin java-version: 17 - name: Install Node.js run: | curl -fsSL https://deb.nodesource.com/setup_22.x | bash - apt-get install -y nodejs - name: Extract versionName run: | VERSION=$(grep -oP 'versionName\s+"[^"]+"' app/build.gradle | head -n1 | cut -d'"' -f2 | tr -d '\r\n') echo $VERSION > version.txt echo "Detected version: $VERSION" - name: Stop if version already released id: stop run: | VERSION=$(cat version.txt) echo "version=$VERSION" >> $GITHUB_OUTPUT if git show-ref --tags --quiet --verify "refs/tags/$VERSION"; then echo "Version $VERSION already released, stopping job." echo "continue=false" >> $GITHUB_OUTPUT else echo "Version $VERSION not released yet, continuing workflow..." echo "continue=true" >> $GITHUB_OUTPUT fi - name: Decode keystore if: steps.stop.outputs.continue == 'true' run: | echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > app/release.keystore - name: Check keystore if: steps.stop.outputs.continue == 'true' run: ls -l app/ - name: Make Gradlew executable if: steps.stop.outputs.continue == 'true' run: chmod +x ./gradlew - name: Set up Android SDK if: steps.stop.outputs.continue == 'true' run: | mkdir -p $HOME/Android/sdk/cmdline-tools wget https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip -O cmdline-tools.zip unzip -q cmdline-tools.zip -d $HOME/Android/sdk/cmdline-tools mv $HOME/Android/sdk/cmdline-tools/cmdline-tools $HOME/Android/sdk/cmdline-tools/latest export ANDROID_SDK_ROOT=$HOME/Android/sdk export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH # Устанавливаем пакеты без интерактивного ввода yes | sdkmanager --sdk_root=$ANDROID_SDK_ROOT --licenses || true sdkmanager --sdk_root=$ANDROID_SDK_ROOT "platform-tools" "platforms;android-36" "build-tools;36.0.0" --verbose echo "ANDROID_SDK_ROOT=$HOME/Android/sdk" >> $GITHUB_ENV echo "PATH=$HOME/Android/sdk/cmdline-tools/latest/bin:$HOME/Android/sdk/platform-tools:$PATH" >> $GITHUB_ENV - name: Build Release APK if: steps.stop.outputs.continue == 'true' env: KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} KEY_ALIAS: ${{ secrets.KEY_ALIAS }} KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} run: | VERSION=$(cat version.txt) ./gradlew assembleRelease - name: Create git tag if: steps.stop.outputs.continue == 'true' run: | VERSION=$(cat version.txt) git tag $VERSION git push origin $VERSION - name: Create Gitea Release if: steps.stop.outputs.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.stop.outputs.version }} name: Release ${{ steps.stop.outputs.version }} body: | Android release ${{ steps.stop.outputs.version }} files: | app/build/outputs/apk/release/*.apk