Skip to content

Build & Release (manual) #43

Build & Release (manual)

Build & Release (manual) #43

Workflow file for this run

name: Build & Release (manual)
# Manually triggered
# $ gh workflow run release.yml
on:
workflow_dispatch:
inputs:
version:
description: Select Release type - major, minor or patch(for version upgrade).
required: true
default: patch
type: choice
options:
- patch
- minor
- major
jobs:
static-analysis:
runs-on: macos-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Run static analysis
run: |
xcodebuild analyze -project BranchSDK.xcodeproj
# TODO: current repo merge controls are preventing this step from passing
# version-bump:
# runs-on: macos-latest
# needs: [static-analysis]
# steps:
# - name: Check out code
# uses: actions/checkout@v3
# - name: Update Version
# run: |
# if [[ ${{ inputs.version }} == "patch" ]]; then
# ./scripts/version.sh -i
# elif [[ ${{ inputs.version }} == "minor" ]]; then
# ./scripts/version.sh -im
# elif [[ ${{ inputs.version }} == "major" ]]; then
# ./scripts/version.sh -iM
# else
# echo "Invalid option"
# fi
# git config user.name "Branch SDK Team"
# git config user.email branch-sdks@branch.io
# git add BranchSDK.xcodeproj/project.pbxproj BranchSDK/BNCConfig.m BranchSDK.podspec Branch-TestBed/Framework-Info.plist ./scripts/version.sh
# git commit BranchSDK.xcodeproj/project.pbxproj BranchSDK/BNCConfig.m BranchSDK.podspec Branch-TestBed/Framework-Info.plist ./scripts/version.sh -m'Updated version'
# echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
# git push
build-framework:
runs-on: macos-latest
#needs: [version-bump]
needs: [static-analysis]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Build xcframework
run: |
./scripts/prep_xcframework.sh
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: release_framework
path: |
./Branch.zip
./checksum.txt
build-noidfa-framework:
runs-on: macos-latest
#needs: [version-bump]
needs: [static-analysis]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Build xcframework
run: |
./scripts/prep_xcframework_noidfa.sh
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: framework-noidfa
path: |
./Branch_noidfa.zip
./checksum_noidfa.txt
build-static-framework:
runs-on: macos-latest
#needs: [version-bump]
needs: [static-analysis]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Build static xcframework
run: |
./scripts/prep_static_xcframework.sh
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: static-framework
path: |
./Branch_static.zip
./checksum_static.txt
build-static-noidfa-framework:
runs-on: macos-latest
#needs: [version-bump]
needs: [static-analysis]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Build static xcframework
run: |
./scripts/prep_static_xcframework_noidfa.sh
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: static-framework-noidfa
path: |
./Branch_static_noidfa.zip
./checksum_static_noidfa.txt
release:
runs-on: macos-latest
needs: [build-framework, build-static-framework, build-noidfa-framework, build-static-noidfa-framework]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
# The CocoaPods dependencies are only used by the
# Branch-TestBed.xcworkspace (for unit tests).
# Bring in the Ruby deps from the cache for quick availability of
# pod command. Not using cached Pods folder.
- name: Restore cache
uses: actions/cache@v3
with:
path: |
vendor
Branch-TestBed/Pods
key: ${{ runner.os }}-${{ hashFiles('Gemfile.lock','Branch-TestBed/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-
- name: Install Ruby dependencies
run: |
bundle config set --local path vendor
bundle check || bundle install
- name: Download build artifacts
uses: actions/download-artifact@v3
- name: Publish to CocoaPods
run: |
# TODO: Authenticate using repo secret
# bundle exec pod trunk push Branch.podspec
echo "TODO: This 👆"
# 3. Create GitHub release. Also creates a tag.
- name: Get current version
id: get-version
run: |
bundle exec fastlane current_version
echo "Current version is $(cat fastlane/.version)."
echo "version=$(cat fastlane/.version)" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: actions/github-script@v6
with:
script: |
const createRelease = require('./.github/custom-scripts/create-release');
const tagName = '${{ steps.get-version.outputs.version }}';
const sha = '${{ steps.commit-checksums.outputs.sha }}';
await createRelease({
core,
context,
github,
sha,
version: tagName,
});
- name: Upload Release Assets
uses: actions/github-script@v6
with:
script: |
const uploadAsset = require('./.github/custom-scripts/upload-asset');
const tagName = '${{ steps.get-version.outputs.version }}';
const { data } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tagName,
});
const releaseId = data.id;
await uploadAsset({
github,
context,
releaseId,
assetName: 'Branch.zip',
path: 'release_framework/Branch.zip',
});
await uploadAsset({
github,
context,
releaseId,
assetName: 'Branch_noidfa.zip',
path: 'framework-noidfa/Branch_noidfa.zip',
});
await uploadAsset({
github,
context,
releaseId,
assetName: 'Branch_static.zip',
path: 'static-framework/Branch_static.zip',
});
await uploadAsset({
github,
context,
releaseId,
assetName: 'Branch_static_noidfa.zip',
path: 'static-framework-noidfa/Branch_static_noidfa.zip',
});
await uploadAsset({
github,
context,
releaseId,
assetName: 'checksum_noidfa',
path: 'framework-noidfa/checksum_noidfa.txt',
});
await uploadAsset({
github,
context,
releaseId,
assetName: 'checksum_static',
path: 'static-framework/checksum_static.txt',
});
await uploadAsset({
github,
context,
releaseId,
assetName: 'checksum_static_noidfa',
path: 'static-framework-noidfa/checksum_static_noidfa.txt',
});
await uploadAsset({
github,
context,
releaseId,
assetName: 'checksum',
path: 'release_framework/checksum.txt',
});
- name: Trigger workflow in iOS Branch SDK spm repo for updating code and creating release
run: |
curl -X POST https://api.github.com/repos/BranchMetrics/ios-branch-sdk-spm/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -u "branchlet:${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC}}" --data '{"event_type": "Trigger Workflow", "client_payload":
{ "tag":"${{steps.get-version.outputs.version}}"}}'