Skip to content

fix: release description #5

fix: release description

fix: release description #5

Workflow file for this run

name: Android CI
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
tag_prefix:
description: "Tag prefix for the release"
required: false
default: "v"
permissions:
contents: write
packages: write
issues: write
deployments: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up JDK 21 (Zulu)
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "21"
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set execute permission for gradlew
run: chmod +x ./gradlew
- name: Create local.properties
run: |
echo "PRODUCTION_MODE=${{ secrets.PRODUCTION_MODE }}" >> $GITHUB_WORKSPACE/local.properties
echo "API_URL=${{ secrets.API_URL }}" >> $GITHUB_WORKSPACE/local.properties
echo "API_URL_PROD=${{ secrets.API_URL_PROD }}" >> $GITHUB_WORKSPACE/local.properties
echo "ARTICLE_URL=${{ secrets.ARTICLE_URL }}" >> $GITHUB_WORKSPACE/local.properties
- name: Build with Gradle
run: ./gradlew assembleRelease
- name: List output directory
run: ls -R app/build/outputs/apk/release
- name: Upload APK
if: success()
uses: actions/upload-artifact@v2
with:
name: apk-files
path: app/build/outputs/apk/release/*.apk
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Ensures full history is fetched
- name: Download APKs
uses: actions/download-artifact@v2
with:
name: apk-files
path: .
- name: Get latest tag
id: get_latest_tag
run: |
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "${{ github.event.inputs.tag_prefix }}0.0.0")
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
shell: bash
- name: Generate new version
id: generate_version
run: |
latest_tag=${{ env.latest_tag }}
IFS='.' read -r -a version_parts <<< "${latest_tag#${{ github.event.inputs.tag_prefix }}}"
major=${version_parts[0]}
minor=${version_parts[1]}
patch=${version_parts[2]}
new_patch=$((patch + 1))
if [ $new_patch -ge 10 ]; then
new_minor=$((minor + 1))
new_patch=0
new_version="${{ github.event.inputs.tag_prefix }}$major.$new_minor.$new_patch"
else
new_version="${{ github.event.inputs.tag_prefix }}$major.$minor.$new_patch"
fi
echo "new_version=$new_version" >> $GITHUB_ENV
shell: bash
- name: Create new Git tag
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git tag ${{ env.new_version }}
git push origin ${{ env.new_version }}
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
shell: bash
- name: Get commit title
id: get_commit_title
run: echo "COMMIT_TITLE=$(git log -1 --pretty=%s | tr -d '\n' | tr -d '\r')" >> $GITHUB_ENV
shell: bash
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
with:
tag_name: ${{ env.new_version }}
release_name: Release ${{ env.new_version }}
body: ${{ env.COMMIT_TITLE }}
draft: false
prerelease: false
- name: Upload APK to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./app-release-unsigned.apk
asset_name: app-release-unsigned.apk
asset_content_type: application/vnd.android.package-archive
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}