Files
ISODroid/.gitea/workflows/auto-tag.yml
Shihaam Abdul Rahman f7036c2c25
All checks were successful
Auto Tag on Version Change / check-version (push) Successful in 4s
update ci to commit fastlane
2026-03-29 01:18:14 +05:00

71 lines
2.3 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
if git tag -l | grep -q "^v${VERSION}$"; then
echo "Tag v${VERSION} already exists, skipping"
echo "should_release=false" >> $GITHUB_OUTPUT
else
echo "New version detected: 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}"