Skip to content

Added some checks to prevent usage of SDK when is disabled (#147) #56

Added some checks to prevent usage of SDK when is disabled (#147)

Added some checks to prevent usage of SDK when is disabled (#147) #56

Workflow file for this run

name: Create Release
env:
ARCHIVE_QUIET_MODE: 1
on:
push:
branches:
- "release/*"
workflow_dispatch:
inputs:
rc_version:
description: "The release candidate version to create"
required: true
is_production_ready:
description: "Is the release candidate production ready"
type: boolean
default: false
permissions:
id-token: write
contents: write
packages: read
jobs:
extractor:
name: Extract elements from context
runs-on: ubuntu-latest
timeout-minutes: 5
env:
RC_VERSION: ${{ github.event.inputs.rc_version }}
IS_PRODUCTION_READY: ${{ github.event.inputs.is_production_ready }}
outputs:
rc_version: ${{ steps.rc_version_extractor.outputs.rc_version }}
is_production_ready: ${{ env.IS_PRODUCTION_READY }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Define Production Readiness
run: |
if [ -z "$IS_PRODUCTION_READY" ]; then
echo "IS_PRODUCTION_READY=false" >> $GITHUB_ENV
fi
echo "Production readiness determined: $IS_PRODUCTION_READY"
- name: Validate and Extract RC Version Number
id: rc_version_extractor
run: |
# If the workflow wasn't triggered manually, extract the version number either from branch or tag
# (depending the event which triggered the workflow).
if [ -z "$RC_VERSION" ]; then
if [[ "${{ github.ref_type }}" == "branch" ]]; then
BRANCH_VERSION=${GITHUB_REF_NAME##release/}
RC_VERSION=$BRANCH_VERSION
fi
fi
# Production-ready versions should always follow a "definitive" version format:
# - xx.yy.zz
# But, non-production-ready versions support having pre-release versions, like:
# - x.y.z-rc1
if [ "$IS_PRODUCTION_READY" == "true" ]; then
if ! [[ "$RC_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: RC_VERSION of '$RC_VERSION' is not in the correct production-ready format."
exit 1
fi
else
if ! [[ "$RC_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$ ]]; then
echo "Error: RC_VERSION of '$RC_VERSION' is not compliant with pre-release semver."
exit 1
fi
VERSION_COUNTER=1
while [ ! -z $(git tag -l ${RC_VERSION}-rc${VERSION_COUNTER}) ]; do
VERSION_COUNTER=$((VERSION_COUNTER + 1))
done
RC_VERSION="${RC_VERSION}-rc${VERSION_COUNTER}"
fi
echo "rc_version=$RC_VERSION" >> $GITHUB_OUTPUT
echo "Using RC_VERSION of $RC_VERSION"
build_release_candidate:
name: Bump Version and Build Release
runs-on: macos-14
timeout-minutes: 60
needs:
- extractor
env:
RC_VERSION: ${{ needs.extractor.outputs.rc_version }}
IS_PRODUCTION_READY: ${{ needs.extractor.outputs.is_production_ready }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump Version
run: |
echo "Bumping version to '$RC_VERSION'"
bin/version_bump $RC_VERSION
# DEV: show diff
git diff
if [[ `git status --porcelain` ]]; then
echo "VERSION_BUMPED=true" >> $GITHUB_ENV
fi
- name: Commit Version Changes
if: env.VERSION_BUMPED == 'true'
run: |
git config --global user.name "embrace-ci"
git config --global user.email "embrace-ci@users.noreply.github.com"
git add EmbraceIO.podspec \
Sources/EmbraceCommonInternal/EmbraceMeta.swift
git diff --cached
git commit -m "CI/CD: Bumps version to '$RC_VERSION'"
git push
- name: Select Xcode 15
run: sudo xcode-select -switch /Applications/Xcode_15.4.app
- name: Install Mise
run: |
# Install Mise
curl https://mise.jdx.dev/install.sh | sh
echo "$HOME/.local/share/mise/bin" >> $GITHUB_PATH
echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH
- name: Build XCFramework
run: |
eval "$(~/.local/bin/mise activate bash)" >> ~/.bashrc
echo "$PATH"
# mise doctor
./bin/build_xcframeworks.sh
# TODO: Finish this step
- name: Sign XCFramework
run: echo "We're not going to sign the xcframeworks at this moment. Will do it later"
- name: Zip XCFrameworks
run: |
DIR=$(pwd -P)
cd build; zip -r "$DIR/xcframeworks.zip" xcframeworks
- name: Store XCFrameworks
uses: actions/upload-artifact@v4
with:
name: Embrace-Universal Build Artifacts
path: xcframeworks.zip
- name: Tag the release candidate version
run: |
git tag $RC_VERSION
git push origin $RC_VERSION
archive_cocoapods_artifacts:
name: Archive Cocoapods Artifacts
runs-on: ubuntu-latest
timeout-minutes: 5
needs:
- extractor
- build_release_candidate
env:
RC_VERSION: ${{ needs.extractor.outputs.rc_version }}
steps:
- name: Determine latest embrace_support.zip version
env:
GH_TOKEN: ${{ github.token }}
run: |
version=$(gh release list --repo embrace-io/action-symbol-upload --json tagName --jq '.[] | select(.tagName | startswith("embrace_support-")) | .tagName' --order desc | head -1)
echo "Using tool version ${version}"
echo "SUPPORT_TOOL=${version}" >> $GITHUB_ENV
- name: Download embrace_support.zip
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release --repo embrace-io/action-symbol-upload download ${{ env.SUPPORT_TOOL }} --pattern 'embrace_support-*' --clobber
- name: Verify and extract embrace_support.zip
run: |
if /usr/bin/shasum -a 256 -c ${{ env.SUPPORT_TOOL }}.zip.sha256; then
unzip -o ${{ env.SUPPORT_TOOL }}.zip
else
echo "Checksum verification failed, aborting."
exit 1
fi
- name: Download Artifacts - XCFrameworks
uses: actions/download-artifact@v4
with:
name: Embrace-Universal Build Artifacts
- name: Unzip Embrace-Universal Build Artifacts
run: unzip xcframeworks.zip
- name: Create Cocoapods Release Zip
run: |
DIR=$(pwd -P)
mkdir artifacts
chmod +x run.sh embrace_symbol_upload.darwin
mv run.sh embrace_symbol_upload.darwin artifacts/
cd artifacts; zip "$DIR/embrace_$RC_VERSION.zip" *; cd -;
zip "$DIR/embrace_$RC_VERSION.zip" -r xcframeworks/*; cd -;
- name: Store Cocoapods Artifacts
uses: actions/upload-artifact@v4
with:
name: Cocoapods Release Archive
path: embrace_${{ env.RC_VERSION }}.zip
create_github_release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs:
- extractor
- archive_cocoapods_artifacts
steps:
- name: Download Cocoapods Release Archive
uses: actions/download-artifact@v4
with:
name: Cocoapods Release Archive
path: cocoapods/
- name: Disable GitHub CLI Prompt if Enabled
run: |
if [ "$(gh config get prompt)" = "enabled" ]; then
gh config set prompt disabled
fi
- name: Create/Edit Release
env:
GITHUB_TOKEN: ${{ github.token }}
RC_VERSION: ${{ needs.extractor.outputs.rc_version}}
IS_PRODUCTION_READY: ${{ needs.extractor.outputs.is_production_ready }}
run: |
if gh release view --repo embrace-io/embrace-apple-sdk $RC_VERSION > /dev/null 2>&1; then
if [ "$IS_PRODUCTION_READY" == "false" ]; then
echo "Release $RC_VERSION already exists; editing..."
gh release upload $RC_VERSION cocoapods/embrace_$RC_VERSION.zip --clobber --repo embrace-io/embrace-apple-sdk --verify-tag
else
echo "Cannot update a production release"
exit 1
fi
else
echo "Creating Release $RC_VERSION in Github"
PRERELEASE_FLAG=""
if [ "$IS_PRODUCTION_READY" == "false" ]; then
PRERELEASE_FLAG="--prerelease"
fi
gh release create $RC_VERSION cocoapods/embrace_$RC_VERSION.zip --title "$RC_VERSION" $PRERELEASE_FLAG --repo embrace-io/embrace-apple-sdk --verify-tag
fi
push_podspec:
name: Push Podspec to Cocoapods
runs-on: macos-14
timeout-minutes: 10
needs:
- extractor
- create_github_release
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
RC_VERSION: ${{ needs.extractor.outputs.rc_version }}
IS_PRODUCTION_READY: ${{ needs.extractor.outputs.is_production_ready }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: ${{ needs.extractor.outputs.rc_version }}
fetch-depth: 0
path: embrace-apple-sdk
- name: Be sure Podspec has bumped version
run: |
cd embrace-apple-sdk
bin/version_bump $RC_VERSION --cocoapods
- name: Push EmbraceIO Podspec
run: |
pod trunk push embrace-apple-sdk/EmbraceIO.podspec --allow-warnings
# Note: missing/removed steps from old sdk
# - dsyms work