From 95931b99ff9b9e403112388c93f242c247e668ec Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Mon, 19 Feb 2024 14:43:28 +0100 Subject: [PATCH] Add step to precommit ensuring that local development is set to false in Package.swift, also required for when making releses. --- .pre-commit-config.yaml | 7 +++++++ Package.swift | 2 +- scripts/ios/ensure-not-local.sh | 11 +++++++++++ scripts/ios/release.sh | 3 +-- 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100755 scripts/ios/ensure-not-local.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3fb01d451..cb24ec0e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,13 @@ repos: - id: typos - repo: local hooks: + - id: ensure Swift not changed to local development + name: ensure Swift not changed to local development + language: system + types: [file, swift] + entry: ./scripts/ios/ensure-not-local.sh + pass_filenames: false + - id: fmt name: fmt language: system diff --git a/Package.swift b/Package.swift index 73aa60cbb..53499e635 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let sargonBinaryTargetName = "SargonCoreRS" let binaryTarget: Target -let useLocalFramework = true +let useLocalFramework = false if useLocalFramework { binaryTarget = .binaryTarget( diff --git a/scripts/ios/ensure-not-local.sh b/scripts/ios/ensure-not-local.sh new file mode 100755 index 000000000..5fb08a6ec --- /dev/null +++ b/scripts/ios/ensure-not-local.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env zsh + +set -e +set -u + +if grep -q "let useLocalFramework = true" Package.swift; then + echo "You MUST let useLocalFramework be set to 'false'. Else Swift release will fail." + exit 1; +fi + +exit 0; \ No newline at end of file diff --git a/scripts/ios/release.sh b/scripts/ios/release.sh index cca2953fc..b94532dac 100755 --- a/scripts/ios/release.sh +++ b/scripts/ios/release.sh @@ -13,8 +13,7 @@ echo "🚢 Start of '$me' (see: '$DIR/$me')" echo "🚢 PWD: $PWD" echo "🚢 Ensure 'useLocalFramework' is set to 'false' in Package.swift" -sed -i '' 's/let useLocalFramework = true/let useLocalFramework = false/' Package.swift - +sh ./scripts/ios/ensure-not-local.sh || exit $? `git fetch --prune --tags` function last_tag() {