mirror of
https://github.com/fromchat-messenger/app.git
synced 2026-09-22 19:15:05 +03:00
15f88c7349
Cache project .gradle/ and root build/ (execution history + outputs), restore git mtimes after checkout, skip set-version when unchanged, and bump cache keys to v2 with build-jar restore fallback. Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
1.2 KiB
YAML
31 lines
1.2 KiB
YAML
name: Set release version
|
|
description: Writes versionName/versionCode into build.gradle.kts for CI
|
|
|
|
inputs:
|
|
version:
|
|
description: Semantic version (e.g. 1.2.3)
|
|
required: true
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Set version
|
|
shell: bash
|
|
run: |
|
|
VERSION="${{ inputs.version }}"
|
|
VERSION_CODE="$(printf '%s' "$VERSION" | sed 's/[^0-9]//g')"
|
|
if [[ -z "$VERSION_CODE" ]]; then
|
|
VERSION_CODE=1
|
|
fi
|
|
GRADLE_FILE="build.gradle.kts"
|
|
CURRENT_NAME="$(sed -n 's/.*extra\["versionName"\] = "\([^"]*\)".*/\1/p' "$GRADLE_FILE" | head -n 1)"
|
|
CURRENT_CODE="$(sed -n 's/.*extra\["versionCode"\] = \([0-9]*\).*/\1/p' "$GRADLE_FILE" | head -n 1)"
|
|
if [[ "$CURRENT_NAME" == "$VERSION" && "$CURRENT_CODE" == "$VERSION_CODE" ]]; then
|
|
echo "versionName=$VERSION versionCode=$VERSION_CODE (unchanged)"
|
|
exit 0
|
|
fi
|
|
sed -i.bak "s/extra\\[\"versionName\"\\] = \"[^\"]*\"/extra[\"versionName\"] = \"$VERSION\"/" "$GRADLE_FILE"
|
|
sed -i.bak "s/extra\\[\"versionCode\"\\] = [0-9]*/extra[\"versionCode\"] = $VERSION_CODE/" "$GRADLE_FILE"
|
|
rm -f "$GRADLE_FILE.bak"
|
|
echo "versionName=$VERSION versionCode=$VERSION_CODE"
|