release: v2.0.0 #1
This file contains hidden or 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
| name: Android CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| cd-build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| version_tag: ${{ steps.extract_version_name.outputs.version }} | |
| release_notes: ${{ steps.release_note_content.outputs.notes }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v2 | |
| - name: Generate local.properties | |
| run: echo '${{ secrets.LOCAL_PROPERTIES }}' | base64 -d > ./local.properties | |
| - name: Generate keystore.properties | |
| run: echo '${{ secrets.KEYSTORE_PROPERTIES }}' | base64 -d > ./keystore.properties | |
| - name: Generate metasearch.jks | |
| run: echo '${{ secrets.JAVA_KEY_STORE }}' | base64 -d > ./metasearch.jks | |
| - name: Extract Version Name from libs.versions.toml | |
| id: extract_version_name | |
| run: | | |
| set -euo pipefail | |
| VERSION=$(grep "versionName" gradle/libs.versions.toml | sed -E 's/.*versionName\s*=\s*"([^"]+)".*/\1/') | |
| if [[ -z "$VERSION" ]]; then | |
| echo "Error: Not Found versionName" >&2 | |
| exit 1 | |
| fi | |
| echo "version=v${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "Version extracted from toml: v${VERSION}" | |
| - name: Generate Simple Release Note | |
| id: release_note_content | |
| run: | | |
| set -euo pipefail | |
| RELEASE_COMMIT_SHA=$(git log -n 1 --grep="^release:" --pretty=format:%H) | |
| if [[ -z "$RELEASE_COMMIT_SHA" ]]; then | |
| echo "Error: 'release:' prefix commit not found." >&2 | |
| exit 1 | |
| else | |
| NOTES=$(git log -1 --format=%b $RELEASE_COMMIT_SHA | sed -e '/^\s*$/d' -e 's/^[[:space:]]*//') | |
| echo "Release commit SHA: $RELEASE_COMMIT_SHA" | |
| fi | |
| echo "notes<<EOF" >> $GITHUB_OUTPUT | |
| echo -e "$NOTES" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build Release AAB | |
| run: ./gradlew :app:bundleRelease | |
| - name: Upload AAB | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-release.aab | |
| path: app/build/outputs/bundle/release/app-release.aab | |
| if-no-files-found: error | |
| deploy: | |
| needs: cd-build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download AAB | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: app-release.aab | |
| path: app/build/outputs/bundle/release/ | |
| - name: Create Github Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.cd-build.outputs.version_tag }} | |
| release_name: ${{ needs.cd-build.outputs.version_tag }} | |
| body: ${{ needs.cd-build.outputs.release_notes }} | |
| files: app/build/outputs/bundle/release/app-release.aab | |
| generate_release_notes: true |