Files
android/.gitea/workflows/auto-tag.yml
T
shihaam 877147959a
Auto Tag on Version Change / check-version (push) Successful in 3s
Build and Release APK / build (push) Successful in 6m0s
Release v1.0.33
2026-10-01 06:21:59 +05:00

80 lines
2.9 KiB
YAML

name: Auto Tag on Version Change
on:
push:
branches:
- main
jobs:
check-version:
runs-on: docker-compose
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_GITEA }}
- name: Check version and prepare release
id: version
run: |
VERSION=$(grep 'versionName = ' app/build.gradle.kts | sed 's/.*versionName = "\(.*\)".*/\1/')
VERSION_CODE=$(grep 'versionCode = ' app/build.gradle.kts | sed 's/.*versionCode = \([0-9]*\).*/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT
BEFORE="${{ github.event.before }}"
if [ -z "$BEFORE" ] || ! git cat-file -e "${BEFORE}^{commit}" 2>/dev/null; then
BEFORE="HEAD~1"
fi
PREV_VERSION_CODE=$(git show "${BEFORE}:app/build.gradle.kts" 2>/dev/null | grep 'versionCode = ' | sed 's/.*versionCode = \([0-9]*\).*/\1/')
if [ "$VERSION_CODE" = "$PREV_VERSION_CODE" ]; then
echo "versionCode unchanged (${VERSION_CODE}), skipping"
echo "should_release=false" >> $GITHUB_OUTPUT
elif git tag -l | grep -q "^v${VERSION}$"; then
echo "versionCode changed (${PREV_VERSION_CODE} -> ${VERSION_CODE}) but tag v${VERSION} already exists; bump versionName"
exit 1
else
echo "New versionCode detected: ${PREV_VERSION_CODE} -> ${VERSION_CODE} (v${VERSION})"
echo "should_release=true" >> $GITHUB_OUTPUT
fi
# - name: Extract and commit fastlane changelog
# if: steps.version.outputs.should_release == 'true'
# run: |
# VERSION="${{ steps.version.outputs.version }}"
# VERSION_CODE="${{ steps.version.outputs.version_code }}"
# FASTLANE_DIR="fastlane/metadata/android/en-US/changelogs"
#
# mkdir -p "$FASTLANE_DIR"
#
# awk -v ver="$VERSION" '
# BEGIN { found=0 }
# /^## \[/ {
# if (found) exit
# if ($0 ~ "\\[" ver "\\]") { found=1; next }
# }
# found { print }
# ' CHANGELOG.md > "$FASTLANE_DIR/${VERSION_CODE}.txt"
#
# git config user.name "Gitea Actions"
# git config user.email "actions@gitea.local"
#
# if git diff --quiet "$FASTLANE_DIR/${VERSION_CODE}.txt" 2>/dev/null; then
# echo "No changelog changes to commit"
# else
# git add "$FASTLANE_DIR/${VERSION_CODE}.txt"
# git commit -m "Add fastlane changelog for v${VERSION}"
# git push origin main
# fi
- name: Create and push tag
if: steps.version.outputs.should_release == 'true'
run: |
VERSION="${{ steps.version.outputs.version }}"
git tag "v${VERSION}"
git push origin "v${VERSION}"
echo "Created and pushed tag v${VERSION}"