Skip to content

Update git config for stable release #37

Update git config for stable release

Update git config for stable release #37

Workflow file for this run

name: Build & Publish Release APK
on:
push:
branches:
- stable
tags:
- "*"
workflow_dispatch:
jobs:
Gradle:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: "adopt"
java-version: "20"
cache: "gradle"
- name: Setup Bun
uses: antongolub/action-setup-bun@v1
with:
bun-version: "1.0.25"
cache: true
cache-bin: true
- name: Prepare Tag
shell: bash
id: tag
run: |
if [[ ${{ github.ref_name }} == v* ]]; then
tag="${{ github.ref_name }}"
echo "prerelease=false" >> $GITHUB_OUTPUT
elif [[ ${{ github.ref_name }} == stable ]]; then
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
tag=$(git describe --tags --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=0)
echo "Latest tag: $tag"
if [[ $tag == "" ]]; then
echo "No semver tag found, use 0.0.0"
tag="v0.0.0"
fi
# Get the major, minor and patch parts from the tag.
major_minor_patch=$(echo $tag | grep -oE "[0-9]+\.[0-9]+\.[0-9]+")
echo "Major, minor and patch version: $major_minor_patch"
major=$(echo $major_minor_patch | grep -oE "^[0-9]+")
minor=$(echo $major_minor_patch | grep -oE "\.[0-9]+\." | grep -oE "[0-9]+")
patch=$(echo $major_minor_patch | grep -oE "[0-9]+$")
echo "Major version: $major"
echo "Minor version: $minor"
echo "Patch version: $patch"
commits=$(git rev-list $tag.. --count)
echo "Commits since last tag: $commits"
# If any of commit messages contains "BREAKING" string, increment major version.
breaking_changes=$(git log --pretty=%B $tag.. | grep -iE "BREAKING" | wc -l)
echo "Breaking changes: $breaking_changes"
if [[ $breaking_changes -gt 0 ]]; then
major=$((major + 1))
minor=0
patch=0
else
# Increment minor version.
features=$(git log --pretty=%B $tag.. | grep -iE "feat|compatibility|integration|upgrade" | wc -l)
echo "Features: $features"
if [[ $features -gt 0 ]]; then
minor=$((minor + 1))
patch=0
else
patch=$((patch + 1))
fi
fi
# Calculate the new version number.
tag="v${major}.${minor}.${patch}"
echo "New version: $tag"
echo "prerelease=false" >> $GITHUB_OUTPUT
else
tag="$(date +'vdev.%y.%m.%d.%H%M%S')"
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Bump version in app.json
run: |
tag=${{ steps.tag.outputs.tag }}
# change version in app.json
sed -i "s/\"version\": \".*\"/\"version\": \"${tag:1}\"/g" app.json
- name: Install dependencies
run: bun install
- name: Build Expo
run: bun run build:android
- name: Build Signed APK
run: |
cd android
chmod +x ./gradlew
./gradlew assembleRelease \
--build-cache \
-Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/android/app/keystore.jks \
-Pandroid.injected.signing.store.password="${{ secrets.STORE_PASSWORD }}" \
-Pandroid.injected.signing.key.alias="key0" \
-Pandroid.injected.signing.key.password="${{ secrets.KEY_PASSWORD }}" \
-Pandroid.enableProguardInReleaseBuilds=true
- name: Rename APK
shell: bash
run: |
cd android/app/build/outputs/apk/release
tag=${{ steps.tag.outputs.tag }}
for file in app-*.apk; do name=$(echo $file | cut -d'-' -f2-3); new_name="prevanced-manager-${name%-release*}-$tag.apk"; mv "$file" "$new_name"; done
- name: Release APK
uses: ncipollo/release-action@v1
with:
artifacts: android/app/build/outputs/apk/release/*.apk
tag: ${{ steps.tag.outputs.tag }}
prerelease: ${{ steps.tag.outputs.prerelease }}
generateReleaseNotes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sync app.json version
if: steps.tag.outputs.prerelease == 'false'
continue-on-error: true
run: |
tag=${{ steps.tag.outputs.tag }}
cd $GITHUB_WORKSPACE
git checkout main
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
sed -i "s/\"version\": \".*\"/\"version\": \"${tag:1}\"/g" app.json
git add app.json
git commit -m "chore: bump version to $tag"
git push origin main