forked from upstream-mirrors/quik
clean up gh actions
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
name: PR deploy
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
apk:
|
||||
name: Generate APK
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup JDK
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
|
||||
- name: Set execution flag for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Decode Keystore File
|
||||
run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 -d > ${{ github.workspace }}/my-release-key.keystore
|
||||
|
||||
- name: List files in the APK directory
|
||||
run: ls -Rla ./
|
||||
|
||||
- name: Build APK
|
||||
run: |
|
||||
./gradlew assembleRelease \
|
||||
-Pandroid.injected.signing.store.file=${{ github.workspace }}/my-release-key.keystore \
|
||||
-Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} \
|
||||
-Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} \
|
||||
-Pandroid.injected.signing.key.password=${{ secrets.KEY_PASSWORD }} \
|
||||
--stacktrace
|
||||
|
||||
- name: Rename APK
|
||||
run: mv presentation/build/outputs/apk/release/QUIK-v*-release.apk presentation/build/outputs/apk/release/QUIK-release.apk
|
||||
|
||||
- name: Upload APK
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: apk
|
||||
path: presentation/build/outputs/apk/release/QUIK-release.apk
|
||||
|
||||
release:
|
||||
name: validate fdroid APK
|
||||
needs: apk
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
steps:
|
||||
- name: Download APK from build
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: apk
|
||||
|
||||
- name: List files in the APK directory
|
||||
run: ls -Rla ./
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Validate Fastlane Supply Metadata
|
||||
uses: ashutoshgngwr/validate-fastlane-supply-metadata@v2.0.0
|
||||
with:
|
||||
fastlaneDir: ./metadata
|
||||
|
||||
@@ -5,9 +5,15 @@ on:
|
||||
schedule:
|
||||
- cron: '0 0 1 1,4,7,10 *'
|
||||
|
||||
concurrency:
|
||||
group: auto-update-mms-configs
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
vvm:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
APKEEP_VERSION: 0.9.0
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@@ -15,20 +21,37 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Cache Cargo dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-apkeep-${{ env.APKEEP_VERSION }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-apkeep-
|
||||
|
||||
- name: Set Branch Name
|
||||
run: echo "NEW_BRANCH=update-mms-configs-$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
|
||||
|
||||
- name: Install apkeep
|
||||
run: cargo install apkeep
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if command -v apkeep >/dev/null 2>&1; then
|
||||
installed_version=$(apkeep --version | awk '{print $2}')
|
||||
if [[ "$installed_version" == "$APKEEP_VERSION" ]]; then
|
||||
echo "apkeep ${APKEEP_VERSION} already installed."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
cargo install apkeep --locked --version "$APKEEP_VERSION"
|
||||
|
||||
- name: Install aapt and unzip
|
||||
- name: Install APK tooling
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt -y install aapt unzip
|
||||
|
||||
- name: Install Apktool
|
||||
run: |
|
||||
wget https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.11.1.jar
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends aapt apktool unzip
|
||||
|
||||
- name: Download Messaging APK
|
||||
run: apkeep -a com.google.android.apps.messaging -o device=walleye /home/runner/work/quik/quik
|
||||
@@ -41,13 +64,21 @@ jobs:
|
||||
unzip /home/runner/work/quik/quik/com.google.android.apps.messaging.xapk -d /home/runner/work/quik/quik
|
||||
|
||||
- name: Decompile Messaging using apktool
|
||||
run: java -jar apktool_2.11.1.jar decode com.google.android.apps.messaging.apk -o dump
|
||||
run: apktool d com.google.android.apps.messaging.apk -o dump
|
||||
|
||||
- name: Copy MMS configs
|
||||
shell: bash
|
||||
run: |
|
||||
rm -rv android-smsmms/src/main/res/xml-mcc*
|
||||
cp -rv dump/res/xml-mcc* android-smsmms/src/main/res/
|
||||
rm -rv android-smsmms/src/main/res/xml-mcc*/*_config_override.xml
|
||||
set -euo pipefail
|
||||
shopt -s nullglob
|
||||
rm -rfv android-smsmms/src/main/res/xml-mcc*
|
||||
source_dirs=(dump/res/xml-mcc*)
|
||||
if [[ "${#source_dirs[@]}" -eq 0 ]]; then
|
||||
echo "No MMS config directories found in dump." >&2
|
||||
exit 1
|
||||
fi
|
||||
cp -rv "${source_dirs[@]}" android-smsmms/src/main/res/
|
||||
find android-smsmms/src/main/res/xml-mcc* -name '*_config_override.xml' -print -delete
|
||||
|
||||
- name: Remove Duplicate MMS Config Files
|
||||
run: |
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
name: Build and Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
apk:
|
||||
name: Generate APK
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup JDK
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
|
||||
- name: Set execution flag for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Decode Keystore File
|
||||
run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 -d > ${{ github.workspace }}/my-release-key.keystore
|
||||
|
||||
- name: List files in the APK directory
|
||||
run: ls -Rla ./
|
||||
|
||||
- name: Bump MINOR version in build.gradle (features update)
|
||||
working-directory: presentation
|
||||
run: |
|
||||
# Extract current versionName and versionCode
|
||||
VERSION_LINE=$(grep "versionName" build.gradle)
|
||||
VERSION_NAME=$(echo "$VERSION_LINE" | sed -n "s/.*versionName[ ]*['\"]\([^'\"]*\)['\"].*/\1/p")
|
||||
VERSION_CODE=$(grep "versionCode" build.gradle | awk '{print $2}')
|
||||
|
||||
# Error handling for version parsing
|
||||
if [[ ! "$VERSION_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Error: versionName is not in MAJOR.MINOR.PATCH format: $VERSION_NAME"
|
||||
exit 1
|
||||
fi
|
||||
if ! [[ "$VERSION_CODE" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: versionCode is not an integer: $VERSION_CODE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Split versionName into major, minor, patch
|
||||
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION_NAME"
|
||||
# Bump minor version, reset patch to 0
|
||||
MINOR=$((MINOR + 1))
|
||||
PATCH=0
|
||||
NEW_VERSION_NAME="$MAJOR.$MINOR.$PATCH"
|
||||
NEW_VERSION_CODE=$((VERSION_CODE + 1))
|
||||
|
||||
# Update build.gradle in-place
|
||||
sed -i "s/versionName.*/versionName '$NEW_VERSION_NAME'/" build.gradle
|
||||
sed -i "s/versionCode.*/versionCode $NEW_VERSION_CODE/" build.gradle
|
||||
|
||||
echo "Bumped version to $NEW_VERSION_NAME ($NEW_VERSION_CODE)"
|
||||
|
||||
- name: Build APK
|
||||
run: |
|
||||
./gradlew assembleRelease \
|
||||
-Pandroid.injected.signing.store.file=${{ github.workspace }}/my-release-key.keystore \
|
||||
-Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} \
|
||||
-Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} \
|
||||
-Pandroid.injected.signing.key.password=${{ secrets.KEY_PASSWORD }} \
|
||||
--stacktrace
|
||||
|
||||
- name: Rename APK
|
||||
run: mv presentation/build/outputs/apk/release/QUIK-v*-release.apk presentation/build/outputs/apk/release/QUIK-release.apk
|
||||
|
||||
- name: Upload APK
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: apk
|
||||
path: presentation/build/outputs/apk/release/QUIK-release.apk
|
||||
|
||||
release:
|
||||
name: Release APK
|
||||
needs: apk
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set release datetime
|
||||
run: echo "DATETIME=$(date +'%d-%m-%y_%s')" >> $GITHUB_ENV
|
||||
|
||||
- name: Create and push tag
|
||||
run: |
|
||||
git config --global user.name "github-actions"
|
||||
git config --global user.email "github-actions@github.com"
|
||||
git tag "v${{ env.DATETIME }}"
|
||||
git push origin "v${{ env.DATETIME }}"
|
||||
|
||||
- name: Download APK from build
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: apk*
|
||||
|
||||
- name: List files in the APK directory
|
||||
run: ls -Rla ./
|
||||
|
||||
- name: Create and upload release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
prerelease: true
|
||||
tag_name: "v${{ env.DATETIME }}"
|
||||
files: QUIK-release.apk
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Validate Fastlane Supply Metadata
|
||||
uses: ashutoshgngwr/validate-fastlane-supply-metadata@v2.0.0
|
||||
with:
|
||||
fastlaneDir: ./metadata
|
||||
@@ -4,7 +4,7 @@ on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
branches:
|
||||
- '**'
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -13,21 +13,23 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Decode Keystore File
|
||||
run: echo "${{ secrets.KEYSTORE_FILE }}" | base64 -d > ${{ github.workspace }}/my-release-key.keystore
|
||||
|
||||
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: gradle
|
||||
|
||||
- name: Build with Gradle
|
||||
run: |
|
||||
./gradlew assembleDebug \
|
||||
-Dandroid.injected.signing.store.file=${{ github.workspace }}/my-release-key.keystore
|
||||
|
||||
run: ./gradlew assembleDebug
|
||||
|
||||
- name: Run Android Lint
|
||||
run: ./gradlew lint
|
||||
|
||||
- name: Run Tests
|
||||
run: ./gradlew test
|
||||
|
||||
@@ -35,8 +37,21 @@ jobs:
|
||||
run: ls -R presentation/build/outputs/apk/debug
|
||||
|
||||
- name: Rename APK
|
||||
run: mv presentation/build/outputs/apk/debug/QUIK-v*-debug.apk presentation/build/outputs/apk/debug/QUIK-debug.apk
|
||||
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
shopt -s nullglob
|
||||
mapfile -t apk_files < <(printf '%s\n' presentation/build/outputs/apk/debug/QUIK-v*-debug.apk)
|
||||
if [[ "${#apk_files[@]}" -eq 0 ]]; then
|
||||
echo "No APK found matching QUIK-v*-debug.apk" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${#apk_files[@]}" -gt 1 ]]; then
|
||||
echo "Multiple APKs found: ${apk_files[*]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
mv "${apk_files[0]}" presentation/build/outputs/apk/debug/QUIK-debug.apk
|
||||
|
||||
- name: Upload App
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
name: Bump Version & Prepare F-Droid Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
bump:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
META_YML: fdroid/metadata/dev.octoshrimpy.quik.yml
|
||||
GRADLE_FILE: presentation/build.gradle
|
||||
CHANGELOG: data/src/main/assets/changelog.json
|
||||
|
||||
steps:
|
||||
- name: Checkout full history
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: true
|
||||
|
||||
- name: Decode Android keystore
|
||||
run: |
|
||||
echo "${{ secrets.KEYSTORE_FILE }}" | base64 --decode > keystore.p12
|
||||
|
||||
- name: Install repo icon
|
||||
run: |
|
||||
mkdir -p repo/icons/metadata/en-US/images
|
||||
cp metadata/en-US/images/icon.png \
|
||||
repo/icons/metadata/en-US/images/icon.png
|
||||
|
||||
- name: Write F-Droid config.yml
|
||||
run: |
|
||||
cat > config.yml <<EOF
|
||||
repo_keystore: keystore.p12
|
||||
keystorepass: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
repo_keyalias: ${{ secrets.KEY_ALIAS }}
|
||||
keypass: ${{ secrets.KEY_PASSWORD }}
|
||||
repo_icon: metadata/en-US/images/icon.png
|
||||
EOF
|
||||
|
||||
- name: Bump F-Droid metadata
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- run: |
|
||||
pip3 install fdroidserver
|
||||
fdroid update
|
||||
|
||||
- name: Commit F-Droid metadata bump
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add "$META_YML"
|
||||
git diff --quiet --cached || git commit -m "chore: bump F-Droid metadata"
|
||||
|
||||
- name: Set up Java & jq
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
- run: sudo apt-get update && sudo apt-get install -y jq
|
||||
|
||||
- name: Bump Android version & changelog
|
||||
id: bump
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# extract current values
|
||||
current_code=$(grep -E '^[[:space:]]*versionCode ' "$GRADLE_FILE" | awk '{print $2}')
|
||||
current_name=$(grep -E 'versionName' "$GRADLE_FILE" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
# bump
|
||||
new_code=$((current_code + 1))
|
||||
IFS='.' read -r major minor patch <<< "$current_name"
|
||||
new_name="${major}.$((minor + 1)).0"
|
||||
# apply to build.gradle
|
||||
sed -i \
|
||||
-e "s|^[[:space:]]*versionCode[[:space:]]\+$current_code|versionCode $new_code|" \
|
||||
-e "s|versionName[[:space:]]\+'$current_name'|versionName '$new_name'|" \
|
||||
"$GRADLE_FILE"
|
||||
echo "NEW_CODE=$new_code" >> "$GITHUB_ENV"
|
||||
echo "NEW_NAME=$new_name" >> "$GITHUB_ENV"
|
||||
# prepend to changelog.json
|
||||
prev_tag="v${new_name}"
|
||||
if git rev-parse --verify --quiet "$prev_tag" >/dev/null; then
|
||||
base="$prev_tag"
|
||||
else
|
||||
base=$(git describe --tags --match "v[0-9]*" --abbrev=0 2>/dev/null || echo "")
|
||||
fi
|
||||
[[ -n "$base" ]] && range="$base..HEAD" || range="HEAD"
|
||||
mapfile -t commits < <(
|
||||
git log --no-merges --reverse --pretty=format:"%s by %an" $range \
|
||||
| sed -E 's/[[:space:]]*\.*[[:space:]]+by/ by/' \
|
||||
| sed -E 's/^[[:space:]]+//;s/[[:space:]]+$//' \
|
||||
| awk '!seen[$0]++'
|
||||
)
|
||||
changes_json=$(printf '%s\n' "${commits[@]:-}" | jq -R . | jq -s .)
|
||||
jq --argjson changes "$changes_json" \
|
||||
--arg vc "$new_code" \
|
||||
--arg vn "$new_name" \
|
||||
'
|
||||
def capfirst: sub("^(.)"; "\(ascii_upcase(.1))");
|
||||
$all := ($changes | map(capfirst));
|
||||
$fixes := $all | map(select(test("^(Fix|fix)")));
|
||||
$others := $all | map(select(test("^(Fix|fix)") | not));
|
||||
. = [{
|
||||
versionCode: ($vc|tonumber),
|
||||
versionName: $vn,
|
||||
fixes: $fixes,
|
||||
changes: $others
|
||||
}] + .
|
||||
' "$CHANGELOG" > tmp && mv tmp "$CHANGELOG"
|
||||
# write F-Droid .txt summary
|
||||
mkdir -p fdroid/metadata
|
||||
{
|
||||
echo "Changes in $new_name ($new_code):"
|
||||
echo
|
||||
for c in "${commits[@]}"; do echo "- $c"; done
|
||||
} > fdroid/metadata/"${new_code}".txt
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add "$GRADLE_FILE" "$CHANGELOG" "fdroid/metadata/${new_code}.txt"
|
||||
git commit -m "chore: bump to $new_name ($new_code)"
|
||||
|
||||
- name: Push bump branch
|
||||
run: |
|
||||
branch="bump/${{ env.NEW_NAME }}-${{ env.NEW_CODE }}"
|
||||
# Create or switch to the branch locally
|
||||
if git rev-parse --verify "$branch" >/dev/null 2>&1; then
|
||||
git checkout "$branch"
|
||||
else
|
||||
git checkout -b "$branch"
|
||||
fi
|
||||
# Force-push safely: only if the remote hasn't moved since last fetched
|
||||
git push --force-with-lease origin HEAD:"$branch"
|
||||
|
||||
- name: Open PR (no auto-merge)
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: "chore: bump to ${{ env.NEW_NAME }} (${{ env.NEW_CODE }})"
|
||||
title: "chore: bump to ${{ env.NEW_NAME }} (${{ env.NEW_CODE }})"
|
||||
body: |
|
||||
This PR bumps:
|
||||
- versionCode → ${{ env.NEW_CODE }}
|
||||
- versionName → ${{ env.NEW_NAME }}
|
||||
branch: bump/${{ env.NEW_NAME }}-${{ env.NEW_CODE }}
|
||||
base: master
|
||||
labels: automated
|
||||
@@ -1,55 +0,0 @@
|
||||
name: Deploy APK from master
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GRADLE_FILE: presentation/build.gradle
|
||||
|
||||
steps:
|
||||
- name: Checkout master
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Java 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
|
||||
- name: Decode Android keystore
|
||||
run: |
|
||||
echo "${{ secrets.KEYSTORE_FILE }}" \
|
||||
| base64 --decode > keystore.p12
|
||||
|
||||
- name: Build release APK
|
||||
run: |
|
||||
chmod +x ./gradlew
|
||||
./gradlew clean :presentation:assembleRelease \
|
||||
-Pandroid.injected.signing.store.file=keystore.p12 \
|
||||
-Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} \
|
||||
-Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} \
|
||||
-Pandroid.injected.signing.key.password=${{ secrets.KEY_PASSWORD }}
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────
|
||||
# 1) Extract versionName into an environment variable
|
||||
- name: Extract versionName
|
||||
id: extract
|
||||
run: |
|
||||
version=$(grep versionName $GRADLE_FILE \
|
||||
| grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
echo "VERSION=$version" >> $GITHUB_ENV
|
||||
|
||||
# 2) Publish using that VERSION
|
||||
- name: Publish GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: v${{ env.VERSION }}
|
||||
files: presentation/build/outputs/apk/release/*-release.apk
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,144 @@
|
||||
name: Manual Release Prep
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
bump_component:
|
||||
description: Which part of versionName should be bumped?
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
|
||||
jobs:
|
||||
bump-version:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GRADLE_FILE: presentation/build.gradle
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: true
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Bump version in Gradle
|
||||
id: bump
|
||||
shell: bash
|
||||
env:
|
||||
BUMP_COMPONENT: ${{ inputs.bump_component }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
python3 <<'PY'
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
|
||||
gradle_file = pathlib.Path(os.environ["GRADLE_FILE"])
|
||||
bump_component = os.environ["BUMP_COMPONENT"]
|
||||
|
||||
content = gradle_file.read_text()
|
||||
|
||||
code_pattern = re.compile(r"(^\s*versionCode\s+)(\d+)", re.MULTILINE)
|
||||
name_pattern = re.compile(r"(^\s*versionName\s+['\"])(\d+\.\d+\.\d+)(['\"])", re.MULTILINE)
|
||||
|
||||
code_match = code_pattern.search(content)
|
||||
name_match = name_pattern.search(content)
|
||||
|
||||
if not code_match or not name_match:
|
||||
sys.stderr.write("Unable to locate versionCode or versionName in Gradle file.\n")
|
||||
sys.exit(1)
|
||||
|
||||
current_code = int(code_match.group(2))
|
||||
major, minor, patch = map(int, name_match.group(2).split("."))
|
||||
|
||||
if bump_component == "major":
|
||||
major, minor, patch = major + 1, 0, 0
|
||||
elif bump_component == "minor":
|
||||
minor, patch = minor + 1, 0
|
||||
elif bump_component == "patch":
|
||||
patch += 1
|
||||
else:
|
||||
sys.stderr.write(f"Unsupported bump component: {bump_component}\n")
|
||||
sys.exit(1)
|
||||
|
||||
new_name = f"{major}.{minor}.{patch}"
|
||||
new_code = current_code + 1
|
||||
|
||||
content, code_count = code_pattern.subn(rf"\1{new_code}", content, count=1)
|
||||
content, name_count = name_pattern.subn(lambda m: f"{m.group(1)}{new_name}{m.group(3)}", content, count=1)
|
||||
|
||||
if code_count != 1 or name_count != 1:
|
||||
sys.stderr.write("Failed to update version fields uniquely.\n")
|
||||
sys.exit(1)
|
||||
|
||||
gradle_file.write_text(content)
|
||||
|
||||
github_env = pathlib.Path(os.environ["GITHUB_ENV"])
|
||||
with github_env.open("a") as env_file:
|
||||
env_file.write(f"NEW_VERSION_NAME={new_name}\n")
|
||||
env_file.write(f"NEW_VERSION_CODE={new_code}\n")
|
||||
PY
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const newTag = `v${process.env.NEW_VERSION_NAME}`;
|
||||
const {owner, repo} = context.repo;
|
||||
|
||||
const {data: tags} = await github.rest.repos.listTags({
|
||||
owner,
|
||||
repo,
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
const previousTagEntry = tags.find(tag => /^v\d/.test(tag.name));
|
||||
const previousTag = previousTagEntry ? previousTagEntry.name : undefined;
|
||||
|
||||
const requestPayload = {
|
||||
owner,
|
||||
repo,
|
||||
tag_name: newTag,
|
||||
target_commitish: 'master',
|
||||
};
|
||||
|
||||
if (previousTag) {
|
||||
requestPayload.previous_tag_name = previousTag;
|
||||
}
|
||||
|
||||
const response = await github.request('POST /repos/{owner}/{repo}/releases/generate-notes', requestPayload);
|
||||
|
||||
const notes = response.data.body || '';
|
||||
core.exportVariable('RELEASE_NOTES', notes);
|
||||
core.setOutput('release_notes', notes);
|
||||
|
||||
- name: Open release PR
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: release/v${{ env.NEW_VERSION_NAME }}
|
||||
delete-branch: false
|
||||
commit-message: "chore: release v${{ env.NEW_VERSION_NAME }} (${{ env.NEW_VERSION_CODE }})"
|
||||
title: Release v${{ env.NEW_VERSION_NAME }} (${{ env.NEW_VERSION_CODE }})
|
||||
body: |
|
||||
## Summary
|
||||
- bump `versionName` to `${{ env.NEW_VERSION_NAME }}`
|
||||
- bump `versionCode` to `${{ env.NEW_VERSION_CODE }}`
|
||||
|
||||
Triggered manually via the Manual Release Prep workflow with **${{ inputs.bump_component }}** bump.
|
||||
|
||||
## Auto-generated release notes
|
||||
${{ env.RELEASE_NOTES }}
|
||||
Reference in New Issue
Block a user