Skip to content

Commit

Permalink
add CI scripts for pod release
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyansong-adbe committed Jan 12, 2021
1 parent 354c1a4 commit e9fafe1
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 30 deletions.
4 changes: 4 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
template: |
## What’s Changed
$CHANGES
17 changes: 15 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/publish_podspec.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}


17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 '"')
63 changes: 63 additions & 0 deletions Script/test-SPM.sh
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions Script/test-podspec.sh
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions Script/version.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e9fafe1

Please sign in to comment.