Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update iOS release reusable workflow - handle multi-extension repos #81

Merged
merged 14 commits into from
Oct 29, 2024
Merged
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
179 changes: 125 additions & 54 deletions .github/workflows/ios-release.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,68 @@
#
# Copyright 2024 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#

name: Release (iOS)

# Currently this workflow relies on two secrets:
# - GITHUB_TOKEN: Required for creating a release on GitHub
# - COCOAPODS_TRUNK_TOKEN: Required for pushing a pod to Cocoapods
# This workflow relies on the following secrets:
# - GITHUB_TOKEN: Required for creating a release on GitHub.
# - COCOAPODS_TRUNK_TOKEN: Required for publishing a pod to Cocoapods.
# These can be passed using the `secrets: inherit` option in the caller workflow file.

on:
workflow_call:
inputs:
tag:
description: 'Tag/version (ex: 5.0.1)'
required: true
description: >
The tag (version) to be released (ex: 1.2.3).
type: string

run_full_release:
description: 'Run full release process (`no` to skip)'
required: true
default: 'yes'
type: string

release_pod:
description: 'Release to Cocoapods'
required: true
default: 'yes'
type: string
create-github-release:
description: >
Creates a single GitHub release and uploads artifacts for the specified extensions.
If the provided `tag` does not exist, it will be created.
This does **not** publish the pods to CocoaPods (use `pod-publish-extensions` for that).

library_name:
description: 'Library name to be released (ex: AEPEdge)'
required: true
**Format:** A comma-separated list of extensions.
**Syntax:** `"Extension1, Extension2, Extension3"`
**Example:** `"AEPServices, AEPCore"`
type: string

# Makefile environment variables
scheme_name_xcframework:
description: 'Scheme name for XCFramework (ex: AEPEdgeXCF)'
required: true
type: string
default: ''

test_app_ios_scheme:
description: 'iOS Test App Scheme (ex: TestAppiOS)'
required: true
release-dependency-frameworks:
description: >
**(Core-only parameter)**
A comma-separated list of extension frameworks to include as artifacts in the GitHub release.
The versions will be fetched from CocoaPods.

**Format:** A comma-separated list of extensions.
**Syntax:** `"Dependency1, Dependency2"`
**Example:** `"AEPRulesEngine"`
type: string
required: false
default: ''

test_app_tvos_scheme:
description: 'tvOS Test App Scheme (ex: TestApptvOS)'
required: true
pod-publish-extensions:
description: >
Publishes the specified extensions to CocoaPods.
Pods will be published in the order they are listed.

**Format:** A comma-separated list of extensions.
**Syntax:** `"Extension1, Extension2, Extension3"`
**Example:** `"AEPCore, AEPIdentity"`
type: string
required: true
default: ''

jobs:
release:
Expand All @@ -66,53 +84,106 @@ jobs:
- name: Install XcodeGen
run: brew install xcodegen

- name: Check Version in Podspec
- name: Check version in Podspec
run: |
set -eo pipefail
echo Target version: ${{ inputs.tag }}
make check-version VERSION=${{ inputs.tag }}

- name: SPM Integration Test
if: ${{ inputs.run_full_release == 'yes' }}
- name: Pod repo update
if: ${{ inputs.create-github-release != '' }}
run: |
pod repo update

- name: SPM integration test
if: ${{ inputs.create-github-release != '' }}
run: |
set -eo pipefail
echo SPM integration test starts:
make test-SPM-integration

- name: Podspec File Verification
if: ${{ inputs.run_full_release == 'yes' }}
- name: Podspec file verification
if: ${{ inputs.create-github-release != '' }}
run: |
set -eo pipefail
echo podspec file verification starts:
make test-podspec

- name: Build Artifacts
if: ${{ inputs.run_full_release == 'yes' }}
env:
EXTENSION_NAME: ${{ inputs.library_name }}
SCHEME_NAME_XCFRAMEWORK: ${{ inputs.scheme_name_xcframework }}
TEST_APP_IOS_SCHEME: ${{ inputs.test_app_ios_scheme }}
TEST_APP_TVOS_SCHEME: ${{ inputs.test_app_tvos_scheme }}
- name: Build artifacts
if: ${{ inputs.create-github-release != '' }}
run: |
make archive
make zip
- name: Create GH Release and Upload Asset - ${{ inputs.library_name }}
if: ${{ inputs.run_full_release == 'yes' }}

- name: Create GitHub release and upload assets
if: ${{ inputs.create-github-release != '' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CREATE_GITHUB_RELEASE: ${{ inputs.create-github-release }}
RELEASE_DEPENDENCY_FRAMEWORKS: ${{ inputs.release-dependency-frameworks }}
TAG: ${{ inputs.tag }}
run: |
gh release create ${{ inputs.tag }} \
--verify-tag \
set -eo pipefail

# Initialize an empty string to collect the file arguments
FILE_ARGS=""

# Process CREATE_GITHUB_RELEASE
# Split the input string into an array using comma as delimiter
IFS=',' read -ra LIBS <<< "${CREATE_GITHUB_RELEASE}"
for LIB in "${LIBS[@]}"; do
# Trim whitespace from the library name
LIB=$(echo "$LIB" | xargs)
# Append the file argument to FILE_ARGS
FILE_ARGS="$FILE_ARGS ./build/${LIB}.xcframework.zip#${LIB}-${TAG}.xcframework.zip"
done

# Process RELEASE_DEPENDENCY_FRAMEWORKS
if [ -n "${RELEASE_DEPENDENCY_FRAMEWORKS}" ]; then
# Split the input string into an array using comma as delimiter
IFS=',' read -ra DEPS <<< "${RELEASE_DEPENDENCY_FRAMEWORKS}"
# Loop over each dependency
for DEP in "${DEPS[@]}"; do
# Trim whitespace from the dependency name
DEP=$(echo "$DEP" | xargs)
echo "Processing dependency: $DEP"

# Fetch version from CocoaPods
echo "Fetching version for dependency ${DEP}..."
DEP_VERSION=$(pod spec cat "${DEP}" | jq -r '.version')
echo "Fetched version for ${DEP}: ${DEP_VERSION}"

# Append the file argument to FILE_ARGS
FILE_ARGS="$FILE_ARGS ./build/${DEP}.xcframework.zip#${DEP}-${DEP_VERSION}.xcframework.zip"
done
fi

# Create GitHub release with all file arguments
gh release create "$TAG" \
--generate-notes \
--title "v${{ inputs.tag }}" \
./build/${{ inputs.library_name }}.xcframework.zip#${{ inputs.library_name }}-${{ inputs.tag }}.xcframework.zip
--title "v$TAG" \
$FILE_ARGS

- name: Publish Pods - ${{ inputs.library_name }}
if: ${{ inputs.release_pod == 'yes' }}
run: |
set -eo pipefail
pod trunk push ${{ inputs.library_name }}.podspec --allow-warnings --synchronous
pod repo update
- name: Publish pods
if: ${{ inputs.pod-publish-extensions != '' }}
env:
POD_PUBLISH_EXTENSIONS: ${{ inputs.pod-publish-extensions }}
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
set -eo pipefail

# Split the input string into an array using comma as delimiter
IFS=',' read -ra LIBS <<< "${POD_PUBLISH_EXTENSIONS}"

# Loop over each library name
for LIB in "${LIBS[@]}"; do
# Trim whitespace from the library name
LIB=$(echo "$LIB" | xargs)

echo "Publishing podspec for ${LIB}..."

# Publish the pod
pod trunk push "${LIB}.podspec" --allow-warnings --synchronous
pod repo update
done