Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NETCETERA_API_KEY=ta_clé_ici
145 changes: 41 additions & 104 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
build:
runs-on: macos-14
runs-on: macos-15
outputs:
version: ${{ steps.get-version.outputs.version }}
should-release: ${{ steps.check-release.outputs.should-release }}
Expand All @@ -17,10 +17,10 @@ jobs:
with:
fetch-depth: 0

- name: Set up Xcode 16.2
- name: Set up Xcode 26.2
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.2'
xcode-version: '26.2'

- name: Download iOS and iOS Simulator Platforms
run: |
Expand All @@ -38,12 +38,12 @@ jobs:
IPHONESIMULATOR_SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)
echo "Device SDK: $IPHONEOS_SDK"
echo "Simulator SDK: $IPHONESIMULATOR_SDK"
if [ ! -d "$IPHONEOS_SDK" ]; then

if [ ! -d "$IPHONEOS_SDK" ]; then
echo "❌ iOS SDK not found at $IPHONEOS_SDK"
exit 1
fi

if [ ! -d "$IPHONESIMULATOR_SDK" ]; then
echo "❌ iOS Simulator SDK not found at $IPHONESIMULATOR_SDK"
exit 1
Expand All @@ -52,18 +52,16 @@ jobs:
- name: Get version from plist
id: get-version
run: |
VERSION=$(plutil -extract CFBundleShortVersionString raw Sources/Monext/AppMetadata.plist)
VERSION=$(plutil -extract CFBundleShortVersionString raw Sources/Monext/Resources/AppMetadata.plist)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "📦 Version détectée: $VERSION"

- name: Check if release should be created
id: check-release
run: |
VERSION="${{ steps.get-version.outputs.version }}"

# Vérifier si on est sur master/main

if [[ "${{ github.ref }}" == "refs/heads/master" ]] || [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
# Vérifier si le tag existe déjà
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "should-release=false" >> $GITHUB_OUTPUT
echo "🏷️ Tag v$VERSION existe déjà, pas de release"
Expand All @@ -72,22 +70,10 @@ jobs:
echo "✨ Nouvelle version détectée: v$VERSION"
fi
else
# Pas sur master/main (PR ou autre branche)
echo "should-release=false" >> $GITHUB_OUTPUT
echo "🔧 Branche: ${{ github.ref_name }}, pas de release"
fi

- name: Configure API Key
env:
NETCETERA_API_KEY: ${{ secrets.NETCETERA_API_KEY }}
run: |
if [ -z "$NETCETERA_API_KEY" ]; then
echo "⚠️ NETCETERA_API_KEY secret non configuré"
exit 1
fi
sed -i '' "s/\${NETCETERA_API_KEY}/$NETCETERA_API_KEY/g" Sources/Monext/AppMetadata.plist
echo "🔑 Clé API configurée"

- name: Clean build folders
run: |
rm -rf .build build dist Package.resolved .swiftpm/xcode
Expand All @@ -98,7 +84,13 @@ jobs:
swift package show-dependencies

- name: Build XCFramework
env:
NETCETERA_API_KEY: ${{ secrets.NETCETERA_API_KEY }}
run: |
if [ -z "$NETCETERA_API_KEY" ]; then
echo "⚠️ NETCETERA_API_KEY secret non configuré"
exit 1
fi
chmod +x build_xcframework.sh
bash -x build_xcframework.sh

Expand All @@ -119,7 +111,7 @@ jobs:

release:
needs: build
runs-on: macos-latest
runs-on: macos-15
if: needs.build.outputs.should-release == 'true'

steps:
Expand All @@ -146,30 +138,30 @@ jobs:
fi
cat > release-notes.md << EOF
## 🚀 Monext v$VERSION

### 📋 Changements
$COMMITS

### 🔧 Installation
Monext iOS SDK is available via [Swift Package Manager](https://www.swift.org/documentation/package-manager/).

### Swift Package Manager
1. **Add the Package Dependency:**

1. **Add the Package Dependency:**
Follow Apple's guide on [Adding Package Dependencies to Your App](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app).

2. **Enter the Repository URL:**
\`\`\`
https://github.com/Monext/monext-ios-sdk
\`\`\`
3. **Specify the Version:**
\`\`\`

3. **Specify the Version:**
Use version \`$VERSION\` or later.

### 📦 Contenu de la release
- Monext.xcframework
- Archive zip

---
**Build Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')
**Commit:** \`${{ github.sha }}\`
Expand All @@ -178,7 +170,7 @@ jobs:
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.build.outputs.version }}
tag_name: ${{ needs.build.outputs.version }}
name: 🚀 Monext v${{ needs.build.outputs.version }}
body_path: release-notes.md
draft: false
Expand All @@ -204,8 +196,7 @@ jobs:
RELEASE_RESULT="${{ needs.release.result }}"
BRANCH="${{ github.ref_name }}"
SHOULD_RELEASE="${{ needs.build.outputs.should-release }}"

# Déterminer le statut global

if [[ "$BUILD_RESULT" == "failure" ]]; then
OVERALL_STATUS="failure"
NOTIFICATION_TYPE="Build"
Expand All @@ -222,13 +213,12 @@ jobs:
OVERALL_STATUS="unknown"
NOTIFICATION_TYPE="Build"
fi

# Configuration selon le statut

if [[ "$OVERALL_STATUS" == "success" ]]; then
ICON_COLOR="Good"
ICON="CheckmarkStarburst"
STATUS_TEXT="✅ Success"

if [[ "$RELEASE_RESULT" == "success" ]]; then
EXTRA_MESSAGE="Publication sur Github Releases réussie."
RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/v${VERSION}"
Expand All @@ -237,32 +227,24 @@ jobs:
\"title\": \"🚀 Voir la release\",
\"url\": \"${RELEASE_URL}\"
},"
echo "✅ Release v${VERSION} créée avec succès!"
echo "🔗 ${RELEASE_URL}"
else
EXTRA_MESSAGE="Build réussi sur la branche ${BRANCH} (pas de release créée)."
RELEASE_ACTION=""
echo "✅ Build v${VERSION} réussi sur ${BRANCH} (should-release: ${SHOULD_RELEASE})"
fi
elif [[ "$OVERALL_STATUS" == "failure" ]]; then
ICON_COLOR="Attention"
ICON="DismissCircle"
STATUS_TEXT="❌ Échec"
EXTRA_MESSAGE="Échec lors du processus de ${NOTIFICATION_TYPE}."
RELEASE_ACTION=""

echo "❌ Échec du ${NOTIFICATION_TYPE}"
else
ICON_COLOR="Warning"
ICON="Warning"
STATUS_TEXT="⚠️ Statut inconnu"
EXTRA_MESSAGE="Le statut du workflow est indéterminé."
RELEASE_ACTION=""

echo "⚠️ Statut inconnu"
fi

# Envoi de la notification Teams

curl -X POST "${TEAMS_WEBHOOK_URL}" \
-H "Content-Type: application/json" \
-d @- << EOF
Expand All @@ -283,73 +265,31 @@ jobs:
{
"type": "Column",
"width": "auto",
"height": "stretch",
"items": [
{
"type": "Icon",
"name": "${ICON}",
"style": "Filled",
"color": "${ICON_COLOR}"
}
],
"items": [{ "type": "Icon", "name": "${ICON}", "style": "Filled", "color": "${ICON_COLOR}" }],
"spacing": "None"
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Publication **SDK iOS** - ${STATUS_TEXT}",
"wrap": true,
"size": "Large",
"weight": "Bolder"
}
],
"items": [{ "type": "TextBlock", "text": "Publication **SDK iOS** - ${STATUS_TEXT}", "wrap": true, "size": "Large", "weight": "Bolder" }],
"spacing": "Small"
}
],
"spacing": "None"
},
{
"type": "TextBlock",
"text": "_version ${VERSION}_",
"wrap": true,
"isSubtle": true,
"spacing": "Small"
},
{ "type": "TextBlock", "text": "_version ${VERSION}_", "wrap": true, "isSubtle": true, "spacing": "Small" },
{
"type": "FactSet",
"facts": [
{
"title": "Repository:",
"value": "${{ github.repository }}"
},
{
"title": "Branch/Tag:",
"value": "${BRANCH}"
},
{
"title": "Auteur:",
"value": "${{ github.actor }}"
},
{
"title": "Build Status:",
"value": "${BUILD_RESULT}"
},
{
"title": "Release Status:",
"value": "${RELEASE_RESULT}"
}
{ "title": "Repository:", "value": "${{ github.repository }}" },
{ "title": "Branch/Tag:", "value": "${BRANCH}" },
{ "title": "Auteur:", "value": "${{ github.actor }}" },
{ "title": "Build Status:", "value": "${BUILD_RESULT}" },
{ "title": "Release Status:", "value": "${RELEASE_RESULT}" }
],
"separator": true
},
{
"type": "TextBlock",
"text": "${EXTRA_MESSAGE}",
"wrap": true,
"separator": true
}
{ "type": "TextBlock", "text": "${EXTRA_MESSAGE}", "wrap": true, "separator": true }
],
"actions": [
${RELEASE_ACTION}
Expand All @@ -364,10 +304,7 @@ jobs:
]
}
EOF

echo "✅ Notification ${NOTIFICATION_TYPE} (${OVERALL_STATUS}) envoyée avec succès"

# Faire échouer le step si le statut global est en échec

if [[ "$OVERALL_STATUS" == "failure" ]]; then
exit 1
fi
38 changes: 32 additions & 6 deletions .github/workflows/test-and-sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,50 @@ jobs:

- name: Create symlink for compatibility
run: |
mkdir -p ${{ github.workspace }}/../
ln -s ${{ github.workspace }} ${{ github.workspace }}/../Monext

mkdir -p ${{ github.workspace }}/../
ln -s ${{ github.workspace }} ${{ github.workspace }}/../Monext

- name: Setup Xcode 26.2
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '26.2'

- name: Install xcresultparser
run: |
brew install xcresultparser

- name: Build plugin executable for macOS host
run: |
xcodebuild build \
-scheme InjectSecretsExecutable \
-configuration Debug \
-destination "platform=macOS,arch=arm64" \
-derivedDataPath ~/SharedDerivedData

- name: Install SonarQube Scanner
run: |
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.2.1.4610.zip
unzip sonar-scanner-cli-6.2.1.4610.zip
echo "${PWD}/sonar-scanner-6.2.1.4610/bin" >> $GITHUB_PATH

- name: Execute Coverage
env:
NETCETERA_API_KEY: "ta_clé_ici"
run: |
set -o pipefail
xcodebuild test -sdk ${{ matrix.sdk }} -scheme "Monext" -destination '${{ matrix.destination }}' -enableCodeCoverage YES -resultBundlePath sdk.xcresult -quiet
xcodebuild test -project ./Example/Example.xcodeproj -scheme Example -destination '${{ matrix.destination }}' -enableCodeCoverage YES -resultBundlePath ./example.xcresult
xcodebuild test \
-sdk ${{ matrix.sdk }} \
-scheme "Monext" \
-destination '${{ matrix.destination }}' \
-enableCodeCoverage YES \
-resultBundlePath sdk.xcresult \
-derivedDataPath ~/SharedDerivedData
xcodebuild test \
-project ./Example/Example.xcodeproj \
-scheme Example \
-destination '${{ matrix.destination }}' \
-enableCodeCoverage YES \
-resultBundlePath ./example.xcresult
xcrun xcresulttool merge sdk.xcresult example.xcresult --output-path=results.xcresult
xcresultparser -o xml --coverage results.xcresult > sonarqube-generic-coverage.xml

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ sonarqube-generic-coverage.xml
Example/Config/Secrets.xcconfig
Sources/Monext/AppMetadata.plist
Example/fastlane/report.xml
/dist
.env.local
Sources/Monext/APIConfig.swift
2 changes: 1 addition & 1 deletion .swiftpm/xcode/xcshareddata/xcschemes/Monext.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
</Scheme>
2 changes: 1 addition & 1 deletion Example/Example.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>com.apple.developer.in-app-payments</key>
<array>
<string>merchant.homo.sdk.monext.com</string>
<string>merchant.com.payline.prod</string>
</array>
</dict>
</plist>
Loading