Skip to content

Commit

Permalink
Adds TestFlight note script.
Browse files Browse the repository at this point in the history
  • Loading branch information
mntone committed Jan 10, 2024
1 parent ea59f3d commit 8de9671
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/versioning.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/zsh

# Build Number Offset
INTERNAL_SHORT_VERSION_OFFSET=3
Expand All @@ -10,7 +10,12 @@ fi
SCRIPT_DIR=$(cd $(dirname $0); pwd)
XCCONFIG_PATH=$SCRIPT_DIR/../src/App/Versioning.xcconfig

GIT_TAG=$(git describe --tags --abbrev=0 || echo "0.8")
if [ -v CI_TAG ]; then
GIT_TAG=$CI_TAG
else
GIT_TAG=$(git describe --tags --abbrev=0 || echo "0.8")
fi

GIT_HASH_SHORT=$(git rev-parse --short HEAD)
VERSION=$GIT_TAG-$GIT_HASH_SHORT
echo "Current version: $VERSION"
Expand Down
10 changes: 10 additions & 0 deletions src/MonsterAnalyzer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@
EB6FF1DE2B48F03200118E0F /* SettingsPaddingModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPaddingModifier.swift; sourceTree = "<group>"; };
EB84A5BC2B47873B00291C6B /* DeveloperSettingsPane.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperSettingsPane.swift; sourceTree = "<group>"; };
EB84A5BF2B47910000291C6B /* DeveloperMonsterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperMonsterView.swift; sourceTree = "<group>"; };
EB86E2802B4EC8CE00A06718 /* ci_post_xcodebuild.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = ci_post_xcodebuild.sh; sourceTree = "<group>"; };
EB8729B12B4D682000E0E5A1 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
EB8778202B26B1E600B3359C /* NavigationSplitViewHost.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationSplitViewHost.swift; sourceTree = "<group>"; };
EB8778222B26B28500B3359C /* MonsterList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonsterList.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -700,6 +701,14 @@
path = Modifiers;
sourceTree = "<group>";
};
EB86E27E2B4EC89100A06718 /* ci_scripts */ = {
isa = PBXGroup;
children = (
EB86E2802B4EC8CE00A06718 /* ci_post_xcodebuild.sh */,
);
path = ci_scripts;
sourceTree = "<group>";
};
EB8F07DB2B2FF3E1006AC575 /* Utils */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1106,6 +1115,7 @@
EBF9281E2B1038C9007D59D4 = {
isa = PBXGroup;
children = (
EB86E27E2B4EC89100A06718 /* ci_scripts */,
EBEA6F262B1858FA00734AAA /* Core */,
EBEA6F342B1858FB00734AAA /* CoreTests */,
EBF928292B1038C9007D59D4 /* App */,
Expand Down
62 changes: 62 additions & 0 deletions src/ci_scripts/ci_post_xcodebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/zsh

LATEST_RELEASES=$(curl -s -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/mntone/ProfMonster/releases?per_page=3")

getSection() {
local TOTAL_LINE=$(printf '%s' $2 | wc -l)
local START=$(printf '%s' $2 | grep -n "## <!--$1-->" | head -n 1 | cut -d ':' -f1)
if [ "$3" = "YES" ]; then
START=$(($START + 1))
fi
local TAIL_LINE=$(($TOTAL_LINE - $START + 1))
local END=$(printf '%s' $2 | tail -n $TAIL_LINE | grep -n '^## ' | head -n 1 | cut -d ':' -f1)
if [ "$END" = "" ]; then
END=$(($TAIL_LINE + 1))
fi
local RESULT=$(printf '%s' $RELEASE_NOTE_T0 | head -n $(($START + $END - 1)) | tail -n $END | perl -pe "s/^## <!--$1-->(.+?)$/[\$1]/")
echo "$RESULT"
}

VERSION_0=$(printf '%s' "$LATEST_RELEASES" | jq -r '.[0].name')
RELEASE_NOTE_T0=$(printf '%s' "$LATEST_RELEASES" | jq -r '.[0].body' | tr -d '\r')
RELEASE_NOTE_0=$(printf '%s' $RELEASE_NOTE_T0 | head -n $(($(printf '%s' $RELEASE_NOTE_T0 | grep -n '## ' | head -n 1 | cut -d ':' -f1) - 2)) | perl -pe 's/\b([a-f0-9]{7})[a-f0-9]{33}\b/$1/ge')

MESSAGE=`getSection "MESSAGE" "$RELEASE_NOTE_T0" | grep -v '^[[:space:]]*$'`
KNOWN_ISSUES=`getSection "KNOWN_ISSUES" "$RELEASE_NOTE_T0" "YES" | perl -pe 's/^###\s+(.+?)$/$1/'`

VERSION_1=$(printf '%s' "$LATEST_RELEASES" | jq -r '.[1].name')
RELEASE_NOTE_T1=$(printf '%s' "$LATEST_RELEASES" | jq -r '.[1].body')
RELEASE_NOTE_1=$(printf '%s' $RELEASE_NOTE_T1 | head -n $(($(printf '%s' $RELEASE_NOTE_T1 | grep -n '## ' | head -n 1 | cut -d ':' -f1) - 2)) | perl -pe 's/\b([a-f0-9]{7})[a-f0-9]{33}\b/$1/ge')

VERSION_2=$(printf '%s' "$LATEST_RELEASES" | jq -r '.[2].name')
RELEASE_NOTE_T2=$(printf '%s' "$LATEST_RELEASES" | jq -r '.[2].body')
RELEASE_NOTE_2=$(printf '%s' $RELEASE_NOTE_T2 | head -n $(($(printf '%s' $RELEASE_NOTE_T2 | grep -n '## ' | head -n 1 | cut -d ':' -f1) - 2)) | perl -pe 's/\b([a-f0-9]{7})[a-f0-9]{33}\b/$1/ge')

RELEASE_NOTES=$(cat << EOS
$MESSAGE
[Release Notes]
$VERSION_0
$RELEASE_NOTE_0
$VERSION_1
$RELEASE_NOTE_1
$VERSION_2
$RELEASE_NOTE_2
[Known Issues]
$KNOWN_ISSUES
EOS
)

if [[ -d "$CI_APP_STORE_SIGNED_APP_PATH" ]]; then
TESTFLIGHT_DIR_PATH=../TestFlight
mkdir $TESTFLIGHT_DIR_PATH
echo "$RELEASE_NOTES" >! $TESTFLIGHT_DIR_PATH/WhatToTest.en-US.txt
else
echo $RELEASE_NOTES
fi

0 comments on commit 8de9671

Please sign in to comment.