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

ci:Add iOS Kit Release Workflow #80

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
141 changes: 141 additions & 0 deletions .github/workflows/ios-kit-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: iOS Kit Release

on:
workflow_dispatch:
inputs:
dryRun:
description: Do a dry run to preview instead of a real release [true/false]
required: true
default: "true"

jobs:
# SDK release is done from main branch.
confirm-main-branch:
name: Confirm release is run from main branch
uses: mParticle/mparticle-workflows/.github/workflows/sdk-release-repo-branch-check.yml@stable

create-release-branch:
name: Create release branch
runs-on: macOS-12
needs: confirm-main-branch
steps:
- name: Checkout development branch
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
ref: development

- name: Create and push release branch
run: |
git checkout -b release/${{ github.run_number }}
git push origin release/${{ github.run_number }}

release:
name: Perform release
runs-on: macOS-12
needs: create-release-branch
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Validate environment
run: |
env | grep -q '^GITHUB_ACCESS_TOKEN=' || (echo "Required environment variable GITHUB_ACCESS_TOKEN is not set" && exit 1)
env | grep -q '^COCOAPODS_TRUNK_TOKEN=' || (echo "Required environment variable COCOAPODS_TRUNK_TOKEN is not set" && exit 1)

- name: Setup git config
run: |
git config user.email "developers@mparticle.com"
git config user.name "mParticle Automation"

- name: Checkout main branch
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: ${{ github.repository }}
token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
ref: main

- name: Merge release branch into main branch
run: |
git pull origin release/${{ github.run_number }}

- name: Release --dry-run
if: ${{ github.event.inputs.dryRun == 'true'}}
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
GIT_AUTHOR_NAME: mparticle-bot
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-bot
GIT_COMMITTER_EMAIL: developers@mparticle.com
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @semantic-release/exec@5 \
semantic-release --dry-run

- name: Release
if: ${{ github.event.inputs.dryRun == 'false'}}
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
GIT_AUTHOR_NAME: mparticle-bot
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-bot
GIT_COMMITTER_EMAIL: developers@mparticle.com
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @semantic-release/exec@5 \
semantic-release

- name: Push automated release commits to release branch
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
ls
git status
git push origin HEAD:release/${{ github.run_number }}

- name: Release to CocoaPods
if: ${{ github.event.inputs.dryRun == 'false'}}
run: |
sudo gem install xcodeproj
pod trunk push --allow-warnings

sync-repository:
name: Finalize release
needs: release
runs-on: macOS-12
steps:
- name: Checkout main branch
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: ${{ github.repository }}
token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
ref: main

- name: Merge release branch into main branch
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git pull origin release/${{ github.run_number }}

- name: Push release commits to main and development branches
if: ${{ github.event.inputs.dryRun == 'false'}}
run: |
git push origin HEAD:main
git push origin HEAD:development

- name: Delete release branch
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git push --delete origin release/${{ github.run_number }}
24 changes: 24 additions & 0 deletions Scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
VERSION="$1"
PREFIXED_VERSION="v$1"
NOTES="$2"

# Update version number
#

# Update Carthage release json file
jq --indent 3 '. += {'"\"$VERSION\""': "'"https://github.com/mparticle-integrations/mparticle-apple-integration-appboy/releases/download/$PREFIXED_VERSION/mParticle_Appboy.framework.zip?alt=https://github.com/mparticle-integrations/mparticle-apple-integration-appboy/releases/download/$PREFIXED_VERSION/mParticle_Appboy.xcframework.zip"'"}'
mParticle_Appboy.json > tmp.json
mv tmp.json mParticle_Appboy.json

BrandonStalnaker marked this conversation as resolved.
Show resolved Hide resolved
# Update CocoaPods podspec file
sed -i '' 's/\(^ s.version[^=]*= \).*/\1"'"$VERSION"'"/' mParticle-Appboy.podspec

# Make the release commit in git
#

git add mParticle-Appboy.podspec
git add mParticle_Appboy.json
git add CHANGELOG.md
git commit -m "chore(release): $VERSION [skip ci]

$NOTES"
40 changes: 40 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module.exports = {
branches: ["main"],
tagFormat: "v${version}",
plugins: [
[
"@semantic-release/commit-analyzer",
{
preset: "angular",
},
],
[
"@semantic-release/release-notes-generator",
{
preset: "angular",
},
],
[
"@semantic-release/changelog",
{
changelogFile: "CHANGELOG.md",
},
],
[
"@semantic-release/exec",
{
prepareCmd: "sh ./Scripts/release.sh ${nextRelease.version} \"${nextRelease.notes}\"",
},
],
[
"@semantic-release/github",
{
assets: [
"mParticle_Appboy.framework.zip",
"mParticle_Appboy.xcframework.zip",
"generated-docs.zip",
BrandonStalnaker marked this conversation as resolved.
Show resolved Hide resolved
],
},
],
],
};
Loading