Skip to content

Commit 1c8a663

Browse files
committed
Move Support scripts into subfolders
1 parent d862e60 commit 1c8a663

File tree

14 files changed

+508
-420
lines changed

14 files changed

+508
-420
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
set -o pipefail
5+
6+
SCRIPT_DIR="${BASH_SOURCE[0]%/*}"
7+
8+
echo "🕵️‍♀️ Linting $PROJECT_NAME..."
9+
"${SCRIPT_DIR}/SwiftLint"
Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# PactSwiftMockService
44
#
5-
# Created by Marko Justinek on 24/4/24.
6-
# Copyright © 2021 Marko Justinek. All rights reserved.
5+
# Created by Marko Justinek on 09/12/24.
6+
# Copyright © 2024 Marko Justinek. All rights reserved.
77
# Permission to use, copy, modify, and/or distribute this software for any
88
# purpose with or without fee is hereby granted, provided that the above
99
# copyright notice and this permission notice appear in all copies.
@@ -17,31 +17,28 @@
1717
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1818
#
1919

20-
set -euo pipefail
20+
set -eu
21+
set -o pipefail
2122

22-
function executeCommand {
23-
if [ $# -eq 0 ]; then
24-
echo -e "No command provided"
25-
exit 1
26-
else
27-
COMMAND="$1"
28-
printf "🤖 Executing:\n '%s'\n" "$COMMAND"
29-
eval "$COMMAND"
30-
fi
31-
}
23+
SUPPORT_DIR="${BASH_SOURCE[0]%/*}/../.."
24+
SRCROOT=${SRCROOT:-"."}
25+
PATH="$PATH:/opt/local/bin:/opt/homebrew/bin/:/usr/local/bin"
3226

33-
function folderExists {
34-
if [ ! -d "$1" ]; then
35-
echo false
27+
function lint {
28+
if [ "${CI:-false}" == "true" ]; then
29+
echo "Skipping Xcode build phase SwiftLint as there is now a CI workflow for it."
3630
else
37-
echo true
31+
# Note that the config file path needs to be specified relative to the $SRCROOT
32+
swiftlint lint \
33+
--no-cache \
34+
--config "${SUPPORT_DIR}/Configuration/swiftlint.yml" \
35+
--strict \
36+
"${SRCROOT}/Sources"
3837
fi
3938
}
4039

41-
function fileExists {
42-
if [ ! -f "$1" ]; then
43-
echo false
44-
else
45-
echo true
46-
fi
47-
}
40+
if command -v "swiftlint"; then
41+
lint
42+
else
43+
echo "warning: swiftlint not installed! See https://github.com/realm/SwiftLint?tab=readme-ov-file#installation"
44+
fi
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ set -o pipefail
2626
IPHONEOS_DEPLOYMENT_TARGET=16.0
2727
MACOSX_DEPLOYMENT_TARGET=13.0
2828

29-
TMP_DIR="./.tmp/build-xcframework"
29+
TMP_DIR="../../.tmp/build-xcframework"
3030
PRODUCT_NAME="PactSwiftMockServer"
3131

3232
# Only use xcbeautify if it can be found in path.
@@ -43,7 +43,7 @@ XCBEAUTIFY=$(command -v xcbeautify || command -v cat)
4343
echo "⚠️ Checking for the right Xcode tools..."
4444
xcode-select -p && xcode-select -v
4545

46-
echo "🚨 Are you running this using Xcode 14.x tools!? It should be 14.x!"
46+
echo "🚨 Are you running this using Xcode 16.x tools!?"
4747
select yn in "Yes" "No"; do
4848
case $yn in
4949
Yes) break;;
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
3+
# PactSwiftMockService
4+
#
5+
# Created by Marko Justinek on 09/12/24.
6+
# Copyright © 2024 Marko Justinek. All rights reserved.
7+
# Permission to use, copy, modify, and/or distribute this software for any
8+
# purpose with or without fee is hereby granted, provided that the above
9+
# copyright notice and this permission notice appear in all copies.
10+
#
11+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
14+
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
17+
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18+
#
19+
20+
# Check if a version part is provided
21+
if [[ -z "$1" ]]; then
22+
echo "Usage: $0 {major|minor|patch}"
23+
exit 1
24+
fi
25+
26+
# Get the latest tag from the repository
27+
VERSION=$(git describe --abbrev=0 --tags 2>/dev/null)
28+
29+
# Default to v0.0.0 if no tags are found
30+
if [ -z "$VERSION" ]; then
31+
VERSION="v0.0.0"
32+
fi
33+
34+
# Remove 'v' prefix for easier manipulation
35+
VERSION=${VERSION#v}
36+
37+
# Split the version into major, minor, and patch components
38+
IFS='.' read -r VNUM1 VNUM2 VNUM3 <<< "$VERSION"
39+
40+
# Determine which part of the version to increment based on the argument
41+
case $1 in
42+
major)
43+
echo "ℹ️ Updating major version"
44+
VNUM1=$((VNUM1 + 1))
45+
VNUM2=0
46+
VNUM3=0
47+
;;
48+
minor)
49+
echo "ℹ️ Updating minor version"
50+
VNUM2=$((VNUM2 + 1))
51+
VNUM3=0
52+
;;
53+
patch)
54+
echo "ℹ️ Updating patch version"
55+
VNUM3=$((VNUM3 + 1))
56+
;;
57+
*)
58+
echo "Invalid argument: $1. Use 'major', 'minor', or 'patch'."
59+
exit 1
60+
;;
61+
esac
62+
63+
# Construct the new tag
64+
NEW_TAG="v$VNUM1.$VNUM2.$VNUM3"
65+
66+
# Check if the current commit already has a tag
67+
GIT_COMMIT=$(git rev-parse HEAD)
68+
NEEDS_TAG=$(git describe --contains "$GIT_COMMIT" 2>/dev/null)
69+
70+
# Only create a new tag if it doesn't already exist for this commit
71+
if [ -z "$NEEDS_TAG" ]; then
72+
echo "🏷️ Tagging with $NEW_TAG"
73+
git tag "$NEW_TAG"
74+
else
75+
echo "Current commit already has a tag: $NEEDS_TAG"
76+
fi

0 commit comments

Comments
 (0)