DEADSOFTWARE

Add release scripts
authorfredboy <fredboy@protonmail.com>
Tue, 16 Apr 2024 19:56:39 +0000 (02:56 +0700)
committerfredboy <fredboy@protonmail.com>
Tue, 16 Apr 2024 20:06:47 +0000 (03:06 +0700)
.gitignore
gen-changelog.sh [new file with mode: 0755]
make-release.sh [new file with mode: 0755]
up-version.sh [new file with mode: 0755]

index ac624d207dbf4971a19c34d50b5b78ea187c9358..c83f78b4ffd5af2bd48e8f05d719903386ff5a79 100644 (file)
@@ -116,3 +116,5 @@ Thumbs.db
 !/ios-moe/xcode/*.xcodeproj/xcshareddata
 !/ios-moe/xcode/*.xcodeproj/project.pbxproj
 /ios-moe/xcode/native/
+
+release-*/
\ No newline at end of file
diff --git a/gen-changelog.sh b/gen-changelog.sh
new file mode 100755 (executable)
index 0000000..f2959c1
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+previous_tag=0
+i=0
+for current_tag in $(git tag --sort=-creatordate)
+do
+
+if [ "$previous_tag" != 0 ] &&  [ $i -lt 1 ]; then
+    i=$(echo "$i + 1" | bc -q )
+    tag_date=$(git log -1 --pretty=format:'%ad' --date=short ${previous_tag})
+    printf "## ${previous_tag} (${tag_date})\n\n"
+    git log ${current_tag}...${previous_tag} --pretty=format:'*  %s ' --reverse | grep -v Merge
+    printf "\n\n"
+fi
+previous_tag=${current_tag}
+done
diff --git a/make-release.sh b/make-release.sh
new file mode 100755 (executable)
index 0000000..e593734
--- /dev/null
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+require_clean_work_tree() {
+    # Update the index
+    git update-index -q --ignore-submodules --refresh
+    err=0
+
+    # Disallow unstaged changes in the working tree
+    if ! git diff-files --quiet --ignore-submodules --
+    then
+        echo >&2 "cannot $1: you have unstaged changes."
+        git diff-files --name-status -r --ignore-submodules -- >&2
+        err=1
+    fi
+
+    # Disallow uncommitted changes in the index
+    if ! git diff-index --cached --quiet HEAD --ignore-submodules --
+    then
+        echo >&2 "cannot $1: your index contains uncommitted changes."
+        git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
+        err=1
+    fi
+
+    if [ $err = 1 ]
+    then
+        echo >&2 "Please commit or stash them."
+        exit 1
+    fi
+}
+
+
+if [[ ! $1 ]]; then
+  echo "usage: $0 versionName"
+  exit
+fi
+
+require_clean_work_tree "$0"
+
+release_dir="release-$1"
+
+mkdir "$release_dir"
+
+./up-version.sh "$1"
+./gen-changelog.sh > "$release_dir/CHANGELOG"
+
+./gradlew clean android:assembleRelease desktop:dist
+
+cp android/build/outputs/apk/release/*.apk "$release_dir/"
+cp desktop/build/libs/*.jar "$release_dir/"
+
+echo "$release_dir/"
diff --git a/up-version.sh b/up-version.sh
new file mode 100755 (executable)
index 0000000..ed84b4d
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+git stash > /dev/null
+stashed=$?
+
+new_version=$1
+
+new_version_string=$(echo $new_version | sed 's/\(alpha\|beta\)\(.*\)/\1 \2/')
+
+sed -i 's/\(version\s=\s\)'"'"'.*'"'"'/\1'"'"''"$new_version"''"'"'/g' build.gradle
+sed -i 's/\(versionName\s\)\".*\"/\1\"'"$new_version"'\"/g' android/build.gradle
+sed -i 's/\(^\s*versionCode\s\)\([0-9]*\)/echo "\1$((\2+1))"/ge' android/build.gradle
+sed -i 's/\(public static final String VERSION = \)\".*\"/\1\"'"$new_version_string"'\"/' core/src/ru/deadsoftware/cavedroid/CaveGame.java
+
+git add build.gradle android/build.gradle core/src/ru/deadsoftware/cavedroid/CaveGame.java
+
+git commit -m "Update version"
+git tag "$new_version"
+
+if [ $stashed ]; then
+  git stash pop
+fi