diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..27bcee3 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,4 @@ +template: | + ## What’s Changed + + $CHANGES diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c94d37..dedccba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,22 @@ name: Build on: push: - branches: [ main, dev ] + branches: + - dev + - main + - dev-** + paths: + - 'Sources/**' + - 'Tests/**' + pull_request: - branches: [ main, dev ] + branches: + - dev + - main + - dev-** + paths: + - 'Sources/**' + - 'Tests/**' jobs: build: diff --git a/.github/workflows/publish_podspec.yml b/.github/workflows/publish_podspec.yml deleted file mode 100644 index 12ef054..0000000 --- a/.github/workflows/publish_podspec.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Publish Podspec Main - -# on: -# release: -# types: [published] -on: - workflow_dispatch: - inputs: - logLevel: - description: 'Log level' - required: true - default: 'warning' - tags: - description: 'Test scenario tags' - -jobs: - build: - - runs-on: macos-latest - - steps: - - uses: actions/checkout@v2 - - name: Install Cocoapods - run: gem install cocoapods - - - name: Deploy to Cocoapods - run: | - pod lib lint --allow-warnings diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..09ee0f3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Release + + +on: + workflow_dispatch: + inputs: + tag: + description: 'tag/version' + required: true + default: '1.0.0' + +jobs: + release_rules_engine: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + with: + ref: main + + - name: Check version in Podspec + run: | + set -eo pipefail + echo Target version: ${{ github.event.inputs.tag }} + make check-version VERSION=${{ github.event.inputs.tag }} + # "release-drafter" action docs -> https://github.com/marketplace/actions/release-drafter + - name: SPM integration test + run: | + set -eo pipefail + echo SPM integration test starts: + make test-SPM-integration + - name: podspec file verification + run: | + set -eo pipefail + echo podspec file verification starts: + make test-podspec + - uses: release-drafter/release-drafter@v5 + with: + name: v${{ github.event.inputs.tag }} + tag: ${{ github.event.inputs.tag }} + version: ${{ github.event.inputs.tag }} + publish: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish Pods + run: | + set -eo pipefail + gem install cocoapods + pod lib lint --allow-warnings + # pod trunk push SwiftRulesEngineTest.podspec --allow-warnings + env: + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} + + diff --git a/Makefile b/Makefile index 4163d34..227a454 100644 --- a/Makefile +++ b/Makefile @@ -13,3 +13,20 @@ format: generate-lcov: xcrun llvm-cov export -format="lcov" .build/debug/AEPRulesEnginePackageTests.xctest/Contents/MacOS/AEPRulesEnginePackageTests -instr-profile .build/debug/codecov/default.profdata > info.lcov +# make check-version VERSION=1.0.0-beta.1 +check-version: + (sh ./script/version.sh $(VERSION)) + +test-SPM-integration: + (sh ./script/test-SPM.sh) + +test-podspec: + (sh ./script/test-podspec.sh) + +latest-version: + (which jq) + (pod spec cat AEPRulesEngine | jq '.version' | tr -d '"') + +version-podspec-local: + (which jq) + (pod ipc spec AEPRulesEngine.podspec | jq '.version' | tr -d '"') \ No newline at end of file diff --git a/Script/test-SPM.sh b/Script/test-SPM.sh new file mode 100755 index 0000000..80f0239 --- /dev/null +++ b/Script/test-SPM.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -e # Any subsequent(*) commands which fail will cause the shell script to exit immediately + +PROJECT_NAME=TestProject + +# Clean up. +rm -rf $PROJECT_NAME + +mkdir -p $PROJECT_NAME && cd $PROJECT_NAME + +# Create the package. +swift package init + +# Create the Package.swift. +echo "// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. +import PackageDescription +let package = Package( + name: \"TestProject\", + defaultLocalization: \"en-US\", + platforms: [ + .iOS(.v10) + ], + products: [ + .library( + name: \"TestProject\", + targets: [\"TestProject\"] + ) + ], + dependencies: [ + .package(name: \"AEPRulesEngine\", path: \"../\"), + ], + targets: [ + .target( + name: \"TestProject\", + dependencies: [ + .product(name: \"AEPRulesEngine\", package: \"AEPRulesEngine\")]) + ] +) +" >Package.swift + +swift package update + +# Archive for generic iOS device +echo '############# Archive for generic iOS device ###############' +xcodebuild archive -scheme TestProject -destination 'generic/platform=iOS' + +# Build for generic iOS device +echo '############# Build for generic iOS device ###############' +xcodebuild build -scheme TestProject -destination 'generic/platform=iOS' + +# Build for i386 simulator +echo '############# Build for i386 simulator ###############' +xcodebuild build -scheme TestProject -destination 'generic/platform=iOS Simulator' ARCHS=i386 + +# Build for x86_64 simulator +echo '############# Build for x86_64 simulator ###############' +xcodebuild build -scheme TestProject -destination 'generic/platform=iOS Simulator' ARCHS=x86_64 + +# Clean up. +cd ../ +rm -rf $PROJECT_NAME diff --git a/Script/test-podspec.sh b/Script/test-podspec.sh new file mode 100644 index 0000000..6e4f1f7 --- /dev/null +++ b/Script/test-podspec.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -e # Any subsequent(*) commands which fail will cause the shell script to exit immediately + +PROJECT_NAME=TestProject + +# Clean up. +rm -rf $PROJECT_NAME + +mkdir -p $PROJECT_NAME && cd $PROJECT_NAME + +# Create a new Xcode project. +swift package init +swift package generate-xcodeproj + +# Create a Podfile with our pod as dependency. +echo " +platform :ios, '10.0' +target '$PROJECT_NAME' do + use_frameworks! + pod 'AEPRulesEngine', :path => '../' +end +" >>Podfile + +# Install the pods. +pod install + +# Archive for generic iOS device +echo '############# Archive for generic iOS device ###############' +xcodebuild archive -scheme TestProject-Package -workspace TestProject.xcworkspace -destination 'generic/platform=iOS' + +# Build for generic iOS device +echo '############# Build for generic iOS device ###############' +xcodebuild clean build -scheme TestProject-Package -workspace TestProject.xcworkspace -destination 'generic/platform=iOS' + +# Archive for x86_64 simulator +echo '############# Archive for simulator ###############' +xcodebuild archive -scheme TestProject-Package -workspace TestProject.xcworkspace -destination 'generic/platform=iOS Simulator' + +# Build for x86_64 simulator +echo '############# Build for simulator ###############' +xcodebuild clean build -scheme TestProject-Package -workspace TestProject.xcworkspace -destination 'generic/platform=iOS Simulator' + +# Clean up. +cd ../ +rm -rf $PROJECT_NAME diff --git a/Script/version.sh b/Script/version.sh new file mode 100755 index 0000000..068b660 --- /dev/null +++ b/Script/version.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +set -e + +if which jq >/dev/null; then + echo "jq is installed" +else + echo "error: jq not installed.(brew install jq)" +fi + +NC='\033[0m' +RED='\033[0;31m' +GREEN='\033[0;32m' +BLUE='\033[0;34m' + +# ---- enable the following code after the new pod has been released. ---- +# LATEST_PUBLIC_VERSION=$(pod spec cat AEPRulesEngine | jq '.version' | tr -d '"') +# echo "Latest public version is: ${BLUE}$LATEST_PUBLIC_VERSION${NC}" +# if [[ "$1" == "$LATEST_PUBLIC_VERSION" ]]; then +# echo "${RED}[Error]${NC} $LATEST_PUBLIC_VERSION has been released!" +# exit -1 +# fi + +echo "Start to check the version in podspec file >" +echo "Target version - ${BLUE}$1${NC}" +# PODSPEC_VERSION=$(cat ./SwiftRulesEngineTest.podspec | egrep '^\s*s.version\s*=\s*\"(.*)\"' | ruby -e "puts gets.scan(/^\s*s.version\s*=\s*\"(.*)\"/)[0] ") +PODSPEC_VERSION=$(pod ipc spec AEPRulesEngine.podspec | jq '.version' | tr -d '"') +echo "Local podspec version - ${BLUE}${PODSPEC_VERSION}${NC}" +if [[ "$1" == "$PODSPEC_VERSION" ]]; then + echo "${GREEN}Pass!" + exit 0 +else + echo "${RED}[Error]${NC} Version do not match!" + exit -1 +fi