Skip to content

Commit f4f000f

Browse files
ci:Add iOS Kit Release Workflow (#25)
1 parent 9592d6e commit f4f000f

File tree

3 files changed

+197
-0
lines changed

3 files changed

+197
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: iOS Kit Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dryRun:
7+
description: Do a dry run to preview instead of a real release [true/false]
8+
required: true
9+
default: "true"
10+
11+
jobs:
12+
# SDK release is done from main branch.
13+
confirm-main-branch:
14+
name: Confirm release is run from main branch
15+
uses: mParticle/mparticle-workflows/.github/workflows/sdk-release-repo-branch-check.yml@stable
16+
17+
create-release-branch:
18+
name: Create release branch
19+
runs-on: macOS-12
20+
needs: confirm-main-branch
21+
steps:
22+
- name: Checkout development branch
23+
uses: actions/checkout@v3
24+
with:
25+
repository: ${{ github.repository }}
26+
token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
27+
ref: development
28+
29+
- name: Create and push release branch
30+
run: |
31+
git checkout -b release/${{ github.run_number }}
32+
git push origin release/${{ github.run_number }}
33+
34+
release:
35+
name: Perform release
36+
runs-on: macOS-12
37+
needs: create-release-branch
38+
env:
39+
GITHUB_ACCESS_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
40+
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v3
44+
45+
- name: Validate environment
46+
run: |
47+
env | grep -q '^GITHUB_ACCESS_TOKEN=' || (echo "Required environment variable GITHUB_ACCESS_TOKEN is not set" && exit 1)
48+
env | grep -q '^COCOAPODS_TRUNK_TOKEN=' || (echo "Required environment variable COCOAPODS_TRUNK_TOKEN is not set" && exit 1)
49+
50+
- name: Setup git config
51+
run: |
52+
git config user.email "[email protected]"
53+
git config user.name "mParticle Automation"
54+
55+
- name: Checkout main branch
56+
uses: actions/checkout@v3
57+
with:
58+
fetch-depth: 0
59+
repository: ${{ github.repository }}
60+
token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
61+
ref: main
62+
63+
- name: Merge release branch into main branch
64+
run: |
65+
git pull origin release/${{ github.run_number }}
66+
67+
- name: Release --dry-run
68+
if: ${{ github.event.inputs.dryRun == 'true'}}
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
71+
GIT_AUTHOR_NAME: mparticle-bot
72+
GIT_AUTHOR_EMAIL: [email protected]
73+
GIT_COMMITTER_NAME: mparticle-bot
74+
GIT_COMMITTER_EMAIL: [email protected]
75+
run: |
76+
npx \
77+
-p lodash \
78+
-p semantic-release@17 \
79+
-p @semantic-release/changelog@5 \
80+
-p @semantic-release/git@9 \
81+
-p @semantic-release/exec@5 \
82+
semantic-release --dry-run
83+
84+
- name: Release
85+
if: ${{ github.event.inputs.dryRun == 'false'}}
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
88+
GIT_AUTHOR_NAME: mparticle-bot
89+
GIT_AUTHOR_EMAIL: [email protected]
90+
GIT_COMMITTER_NAME: mparticle-bot
91+
GIT_COMMITTER_EMAIL: [email protected]
92+
run: |
93+
npx \
94+
-p lodash \
95+
-p semantic-release@17 \
96+
-p @semantic-release/changelog@5 \
97+
-p @semantic-release/git@9 \
98+
-p @semantic-release/exec@5 \
99+
semantic-release
100+
101+
- name: Push automated release commits to release branch
102+
if: ${{ github.event.inputs.dryRun == 'false' }}
103+
run: |
104+
ls
105+
git status
106+
git push origin HEAD:release/${{ github.run_number }}
107+
108+
- name: Release to CocoaPods
109+
if: ${{ github.event.inputs.dryRun == 'false'}}
110+
run: |
111+
sudo gem install xcodeproj
112+
pod trunk push --allow-warnings
113+
114+
sync-repository:
115+
name: Finalize release
116+
needs: release
117+
runs-on: macOS-12
118+
steps:
119+
- name: Checkout main branch
120+
uses: actions/checkout@v3
121+
with:
122+
fetch-depth: 0
123+
repository: ${{ github.repository }}
124+
token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
125+
ref: main
126+
127+
- name: Merge release branch into main branch
128+
if: ${{ github.event.inputs.dryRun == 'false' }}
129+
run: |
130+
git pull origin release/${{ github.run_number }}
131+
132+
- name: Push release commits to main and development branches
133+
if: ${{ github.event.inputs.dryRun == 'false'}}
134+
run: |
135+
git push origin HEAD:main
136+
git push origin HEAD:development
137+
138+
- name: Delete release branch
139+
if: ${{ github.event.inputs.dryRun == 'false' }}
140+
run: |
141+
git push --delete origin release/${{ github.run_number }}

Scripts/release.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
VERSION="$1"
2+
PREFIXED_VERSION="v$1"
3+
NOTES="$2"
4+
5+
# Update version number
6+
#
7+
8+
# Update CocoaPods podspec file
9+
sed -i '' 's/\(^ s.version[^=]*= \).*/\1"'"$VERSION"'"/' mParticle-Google-Analytics-Firebase.podspec
10+
11+
# Make the release commit in git
12+
#
13+
14+
git add mParticle-Google-Analytics-Firebase.podspec
15+
git add mParticle_Google_Analytics_Firebase.json
16+
git add CHANGELOG.md
17+
git commit -m "chore(release): $VERSION [skip ci]
18+
19+
$NOTES"

release.config.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = {
2+
branches: ["main"],
3+
tagFormat: "v${version}",
4+
plugins: [
5+
[
6+
"@semantic-release/commit-analyzer",
7+
{
8+
preset: "angular",
9+
},
10+
],
11+
[
12+
"@semantic-release/release-notes-generator",
13+
{
14+
preset: "angular",
15+
},
16+
],
17+
[
18+
"@semantic-release/changelog",
19+
{
20+
changelogFile: "CHANGELOG.md",
21+
},
22+
],
23+
[
24+
"@semantic-release/exec",
25+
{
26+
prepareCmd: "sh ./Scripts/release.sh ${nextRelease.version} \"${nextRelease.notes}\"",
27+
},
28+
],
29+
[
30+
"@semantic-release/github",
31+
{
32+
assets: [
33+
],
34+
},
35+
],
36+
],
37+
};

0 commit comments

Comments
 (0)