Skip to content

Commit

Permalink
ci: versioning system
Browse files Browse the repository at this point in the history
Signed-off-by: 82Flex <[email protected]>
  • Loading branch information
Lessica committed Aug 18, 2024
1 parent 8e0c7f2 commit b8082f5
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SUBPROJECTS += TrollFoolsTweak
include $(THEOS_MAKE_PATH)/aggregate.mk

before-package::
$(ECHO_NOTHING)ldid -STrollFools.entitlements $(THEOS_STAGING_DIR)/Applications/TrollFools.app$(ECHO_END)
$(ECHO_NOTHING)ldid -STrollFools/TrollFools.entitlements $(THEOS_STAGING_DIR)/Applications/TrollFools.app$(ECHO_END)

after-package::
$(ECHO_NOTHING)mkdir -p packages $(THEOS_STAGING_DIR)/Payload$(ECHO_END)
Expand Down
20 changes: 16 additions & 4 deletions TrollFools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
CC15490C2C4B79D800A4173E /* optool in Resources */ = {isa = PBXBuildFile; fileRef = CC15490B2C4B79D800A4173E /* optool */; };
CC15490E2C4B80AF00A4173E /* EjectListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC15490D2C4B80AF00A4173E /* EjectListView.swift */; };
CC19E4BB2C561D7300E0F1B5 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC19E4BA2C561D7300E0F1B5 /* SettingsView.swift */; };
CC3485172C71B219007E0E28 /* Version.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = CC3485152C71B219007E0E28 /* Version.xcconfig */; };
CC3485182C71B219007E0E28 /* Version.Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = CC3485162C71B219007E0E28 /* Version.Debug.xcconfig */; };
CC5E54BE2C4E12F900FDE4A8 /* install_name_tool in Resources */ = {isa = PBXBuildFile; fileRef = CC5E54BC2C4E12F900FDE4A8 /* install_name_tool */; };
CC5E54BF2C4E131000FDE4A8 /* libxar.1.dylib in Resources */ = {isa = PBXBuildFile; fileRef = CC5E54BB2C4E12F900FDE4A8 /* libxar.1.dylib */; };
CC61A87C2C4A677B003BD9A0 /* CydiaSubstrate.framework.zip in Resources */ = {isa = PBXBuildFile; fileRef = CC61A87B2C4A677B003BD9A0 /* CydiaSubstrate.framework.zip */; };
Expand Down Expand Up @@ -66,6 +68,9 @@
CC15490B2C4B79D800A4173E /* optool */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = optool; sourceTree = "<group>"; };
CC15490D2C4B80AF00A4173E /* EjectListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EjectListView.swift; sourceTree = "<group>"; };
CC19E4BA2C561D7300E0F1B5 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
CC3485142C71B219007E0E28 /* TrollFools.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = TrollFools.entitlements; sourceTree = "<group>"; };
CC3485152C71B219007E0E28 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
CC3485162C71B219007E0E28 /* Version.Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.Debug.xcconfig; sourceTree = "<group>"; };
CC5E54BB2C4E12F900FDE4A8 /* libxar.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libxar.1.dylib; sourceTree = "<group>"; };
CC5E54BC2C4E12F900FDE4A8 /* install_name_tool */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = install_name_tool; sourceTree = "<group>"; };
CC61A87B2C4A677B003BD9A0 /* CydiaSubstrate.framework.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = CydiaSubstrate.framework.zip; sourceTree = "<group>"; };
Expand Down Expand Up @@ -134,6 +139,9 @@
CCC564E72C4BE8320097C300 /* libplist-2.0.3.dylib */,
CC5E54BB2C4E12F900FDE4A8 /* libxar.1.dylib */,
CCF4706B2C4A4919008D8197 /* Localizable.strings */,
CC3485142C71B219007E0E28 /* TrollFools.entitlements */,
CC3485152C71B219007E0E28 /* Version.xcconfig */,
CC3485162C71B219007E0E28 /* Version.Debug.xcconfig */,
);
name = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -275,11 +283,13 @@
CC15490C2C4B79D800A4173E /* optool in Resources */,
CCC564EC2C4BE8470097C300 /* libcrypto.3.dylib in Resources */,
CC1548E62C4A974E00A4173E /* libintl.8.dylib in Resources */,
CC3485172C71B219007E0E28 /* Version.xcconfig in Resources */,
CC1548E72C4A974E00A4173E /* libiosexec.1.dylib in Resources */,
CCC564ED2C4BE8470097C300 /* libplist-2.0.3.dylib in Resources */,
CC5E54BF2C4E131000FDE4A8 /* libxar.1.dylib in Resources */,
CC61A87C2C4A677B003BD9A0 /* CydiaSubstrate.framework.zip in Resources */,
CCF4705E2C4A464B008D8197 /* Assets.xcassets in Resources */,
CC3485182C71B219007E0E28 /* Version.Debug.xcconfig in Resources */,
CCF470692C4A4919008D8197 /* Localizable.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -446,12 +456,13 @@
};
CCF470652C4A464B008D8197 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = CC3485162C71B219007E0E28 /* Version.Debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = $DEBUG_BUILD_NUMBER;
DEVELOPMENT_TEAM = GXZ23M5TP2;
ENABLE_PREVIEWS = NO;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -471,7 +482,7 @@
"$(inherited)",
"$(PROJECT_DIR)/TrollFools",
);
MARKETING_VERSION = 2.5;
MARKETING_VERSION = $DEBUG_VERSION;
PRODUCT_BUNDLE_IDENTIFIER = wiki.qaq.TrollFools;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand All @@ -488,12 +499,13 @@
};
CCF470662C4A464B008D8197 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = CC3485152C71B219007E0E28 /* Version.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = $BUILD_NUMBER;
DEVELOPMENT_TEAM = GXZ23M5TP2;
ENABLE_PREVIEWS = NO;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -513,7 +525,7 @@
"$(inherited)",
"$(PROJECT_DIR)/TrollFools",
);
MARKETING_VERSION = 2.5;
MARKETING_VERSION = $VERSION;
PRODUCT_BUNDLE_IDENTIFIER = wiki.qaq.TrollFools;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions TrollFools/Version.Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Version.xcconfig
// TrollFools
//
// Created by Lessica on 2024/8/18.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974

DEBUG_VERSION = 2.5
DEBUG_BUILD_NUMBER = 202408181
12 changes: 12 additions & 0 deletions TrollFools/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Version.xcconfig
// TRApp
//
// Created by Lessica on 2024/8/18.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974

VERSION = 2.5
BUILD_NUMBER = 3
94 changes: 94 additions & 0 deletions devkit/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

# This script is designed to increment the build number consistently across all
# targets.

# Usage: bump_version.sh <version>
# Example: bump_version.sh 1.0

# Usage: DEBUG=1 bump_version.sh <version>
# Example: DEBUG=1 bump_version.sh 1.0

set -e
cd "$(dirname "$0")"

if [ $# -ne 1 ]; then
echo "Usage: $0 <version>"
exit 1
fi

VERSION=$1

if [ ! -z "$DEBUG" ]; then

# Navigating to the 'carbonwatchuk' directory inside the source root.
XCCONFIG_NAME=../TrollFools/Version.Debug.xcconfig
if [ ! -f $XCCONFIG_NAME ]; then
echo "Versioning configuration not found!"
exit 1
fi

# Get the current date in the format "YYYYMMDD".
current_date=$(date "+%Y%m%d")

# Parse the 'Config.xcconfig' file to retrieve the previous build number.
# The 'awk' command is used to find the line containing "BUILD_NUMBER"
# and the 'tr' command is used to remove any spaces.
previous_build_number=$(awk -F "=" '/DEBUG_BUILD_NUMBER/ {print $2}' $XCCONFIG_NAME | tr -d ' ')

# Extract the date part and the counter part from the previous build number.
previous_date="${previous_build_number:0:8}"
counter="${previous_build_number:8}"

# If the current date matches the date from the previous build number,
# increment the counter. Otherwise, reset the counter to 1.
new_counter=$((current_date == previous_date ? counter + 1 : 1))

# Combine the current date and the new counter to create the new build number.
new_build_number="${current_date}${new_counter}"

# Use 'sed' command to replace the previous build number with the new build
# number in the 'Config.xcconfig' file.
sed -i -e "/DEBUG_VERSION =/ s/= .*/= $VERSION/" $XCCONFIG_NAME
sed -i -e "/DEBUG_BUILD_NUMBER =/ s/= .*/= $new_build_number/" $XCCONFIG_NAME

# Remove the backup file created by 'sed' command.
rm -f $XCCONFIG_NAME-e

else

XCCONFIG_NAME=../TrollFools/Version.xcconfig
if [ ! -f $XCCONFIG_NAME ]; then
echo "Versioning configuration not found!"
exit 1
fi

previous_build_number=$(awk -F "=" '/BUILD_NUMBER/ {print $2}' $XCCONFIG_NAME | tr -d ' ')

new_build_number=$((previous_build_number + 1))

sed -i -e "/VERSION =/ s/= .*/= $VERSION/" $XCCONFIG_NAME
sed -i -e "/BUILD_NUMBER =/ s/= .*/= $new_build_number/" $XCCONFIG_NAME

rm -f $XCCONFIG_NAME-e

fi

# Create the layout directory
mkdir -p ../layout/DEBIAN

# Write the control file
cat > ../layout/DEBIAN/control << __EOF__
Package: wiki.qaq.trollfools
Name: TrollFools
Version: $VERSION-$new_build_number
Section: Applications
Depends: firmware (>= 14.0)
Architecture: iphoneos-arm
Author: Lessica <[email protected]>
Maintainer: Lessica <[email protected]>
Description: Give me 108 yuan.
__EOF__

# Set permissions
chmod 0644 ../layout/DEBIAN/control
24 changes: 24 additions & 0 deletions devkit/print_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -e
cd "$(dirname "$0")"

if [ ! -z "$DEBUG" ]; then
XCCONFIG_NAME=../TrollFools/Version.Debug.xcconfig
if [ ! -f $XCCONFIG_NAME ]; then
echo "Versioning configuration not found!"
exit 1
fi
previous_version=$(awk -F "=" '/DEBUG_VERSION/ {print $2}' $XCCONFIG_NAME | tr -d ' ')
previous_build_number=$(awk -F "=" '/DEBUG_BUILD_NUMBER/ {print $2}' $XCCONFIG_NAME | tr -d ' ')
else
XCCONFIG_NAME=../TrollFools/Version.xcconfig
if [ ! -f $XCCONFIG_NAME ]; then
echo "Versioning configuration not found!"
exit 1
fi
previous_version=$(awk -F "=" '/VERSION/ {print $2}' $XCCONFIG_NAME | tr -d ' ')
previous_build_number=$(awk -F "=" '/BUILD_NUMBER/ {print $2}' $XCCONFIG_NAME | tr -d ' ')
fi

echo "$previous_version ($previous_build_number)"
2 changes: 1 addition & 1 deletion control → layout/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: wiki.qaq.trollfools
Name: TrollFools
Version: 0.0.1
Version: 2.5-202408181
Section: Applications
Depends: firmware (>= 14.0)
Architecture: iphoneos-arm
Expand Down

0 comments on commit b8082f5

Please sign in to comment.