Skip to content

Commit

Permalink
ci: added CI/CD pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Pallab Maiti committed Nov 4, 2022
1 parent dbbdda4 commit c9dd8c0
Show file tree
Hide file tree
Showing 18 changed files with 487 additions and 123 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
18 changes: 3 additions & 15 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
## Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
## Checklist:
- [ ] Version updated in `README`
- [ ] Version updated in `RSConstants.m`(v1)/`RSConstant.swift`(v2)
- [ ] Version updated in `Rudder.xcodeproj`
- [ ] Version updated in `Rudder.podspec`
- [ ] `CHANGELOG` Updated
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added unit tests for the code
- [ ] I have made corresponding changes to the documentation
- [ ] Passed `pod lib lint --no-clean --allow-warnings`
# Description

< Replace with adequate description for this PR>
35 changes: 35 additions & 0 deletions .github/workflows/build-and-quality-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Code Quality Checks
on:
pull_request:
branches: ['master', 'develop']
types: ['opened', 'reopened', 'synchronize']

jobs:
build:
name: Code Quality Checks
runs-on: macOS-latest

steps:
- name: Checkout source branch
uses: actions/checkout@v3

- name: Install xcpretty
run: gem install xcpretty

- name: Build SDK(iOS)
run: |
xcodebuild build -scheme RudderSDK-iOS -workspace Rudder.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 13' | xcpretty
- name: Build SDK(watchOS)
run: |
xcodebuild build -scheme RudderSDK-iOS -workspace Rudder.xcworkspace -destination 'platform=watchOS Simulator,name=Apple Watch Series 7 - 45mm' | xcpretty
- name: Build SDK(tvOS)
run: |
xcodebuild build -scheme RudderSDK-iOS -workspace Rudder.xcworkspace -destination 'platform=tvOS Simulator,name=Apple TV' | xcpretty
- name: Install Cocoapods
run: gem install cocoapods

- name: Execute pod lint
run: pod lib lint --no-clean --allow-warnings
16 changes: 16 additions & 0 deletions .github/workflows/check-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check PR title
on:
pull_request:
branches: ['master', 'develop']
types: ['opened', 'reopened', 'edited', 'synchronize']

jobs:
check_pr_title:
name: Check PR title
runs-on: ubuntu-latest
steps:
- name: Checkout source branch
uses: actions/checkout@v3

- name: Check PR title
uses: rudderlabs/github-action-check-pr-title@v1.0.7
21 changes: 21 additions & 0 deletions .github/workflows/create-hotfix-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Create new hotfix branch

on:
workflow_dispatch:
inputs:
hotfix_name:
description: Hotfix branch name
required: true

jobs:
create-branch:
name: Create new branch
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Create branch
uses: peterjgrainger/action-create-branch@v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: 'hotfix/${{ github.event.inputs.hotfix_name }}'
22 changes: 22 additions & 0 deletions .github/workflows/deploy-cocoapods.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Deploy to Cocoapods

on:
release:
types: [created]

jobs:
build:
name: Deploy to Cocoapods
runs-on: macOS-latest
steps:
- name: Checkout source branch
uses: actions/checkout@v3

- name: Install Cocoapods
run: gem install cocoapods

- name: Publish to CocoaPod
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
pod trunk push --allow-warnings
90 changes: 90 additions & 0 deletions .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Draft new release

on:
workflow_dispatch

jobs:
draft-new-release:
name: Draft a new release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/hotfix/')
steps:
- name: Checkout source branch
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set Node 16
uses: actions/setup-node@v3
with:
node-version: 16

# In order to make a commit, we need to initialize a user.
# You may choose to write something less generic here if you want, it doesn't matter functionality wise.
- name: Initialize mandatory git config
run: |
git config user.name "GitHub actions"
git config user.email noreply@github.com
# Calculate the next release version based on conventional semantic release
- name: Create release branch
id: create-release
env:
HUSKY: 0
run: |
source_branch_name=${GITHUB_REF##*/}
release_type=release
grep -q "hotfix/" <<< "${GITHUB_REF}" && release_type=hotfix-release
git fetch origin master --depth=1
git merge origin/master
current_version=$(jq -r .version package.json)
npx standard-version --skip.commit --skip.tag --skip.changelog
new_version=$(jq -r .version package.json)
git reset --hard
branch_name="${release_type}/${new_version}"
echo "Source branch for new release is $source_branch_name"
echo "Current version is $current_version"
echo "Release type is $release_type"
echo "New version is $new_version"
echo "New release branch name is $branch_name"
git checkout -b "$branch_name"
git push --set-upstream origin "$branch_name"
echo "source_branch_name=$source_branch_name" >> $GITHUB_OUTPUT
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
echo "new_version=$new_version" >> $GITHUB_OUTPUT
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV
echo "NEW_VERSION_VALUE=$new_version" >> $GITHUB_ENV
- name: Update changelog & bump version
id: finish-release
env:
HUSKY: 0
run: |
npm i -g conventional-changelog-cli
SUMMARY=$(((npx conventional-changelog -u) 2>&1) | sed "s/*/<br> */g" | sed "s/#/ /g" | tr -d '\n' || true)
echo $SUMMARY
echo "Current version: $CURRENT_VERSION_VALUE"
echo "New version: $NEW_VERSION_VALUE"
npx replace $CURRENT_VERSION_VALUE $NEW_VERSION_VALUE README.md Sources/Classes/Public/RSVersion.h
git add README.md Sources/Classes/Public/RSVersion.h
echo ${{ steps.create-release.outputs.new_version }}
echo "commit_summary=$SUMMARY" >> $GITHUB_OUTPUT
npx standard-version -a
- name: Push new version in release branch & tag
run: |
git push --follow-tags
- name: Create pull request into master
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ steps.create-release.outputs.branch_name }}
destination_branch: 'master'
github_token: ${{ secrets.PAT }}
pr_title: "chore(release): pulling ${{ steps.create-release.outputs.branch_name }} into master"
pr_body: ":crown: *An automated PR*\n\n${{ steps.finish-release.outputs.commit_summary }}"
pr_reviewer: 'pallabmaiti'
17 changes: 0 additions & 17 deletions .github/workflows/main.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/notion-pr-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Notion PR Sync

on:
issues:
types:
[
opened,
edited,
deleted,
transferred,
pinned,
unpinned,
closed,
reopened,
assigned,
unassigned,
labeled,
unlabeled,
locked,
unlocked,
milestoned,
demilestoned,
]
pull_request:
types:
[
assigned,
unassigned,
labeled,
unlabeled,
opened,
edited,
closed,
reopened,
synchronize,
converted_to_draft,
ready_for_review,
locked,
unlocked,
review_requested,
review_request_removed,
auto_merge_enabled,
auto_merge_disabled,
]

jobs:
request:
runs-on: ubuntu-latest
steps:
- name: Sync Github PRs to Notion
uses: sivashanmukh/github-notion-pr-sync@1.0.0
with:
notionKey: ${{ secrets.NOTION_BOT_KEY }}
notionDatabaseId: ${{ secrets.NOTION_PR_DB_ID }}
githubKey: ${{ secrets.PAT }}
66 changes: 66 additions & 0 deletions .github/workflows/publish-new-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Publish new github release

on:
pull_request:
branches:
- master
types:
- closed

jobs:
release:
name: Publish new release
runs-on: ubuntu-latest
if: (startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix-release/')) && github.event.pull_request.merged == true # only merged pull requests must trigger this job
steps:
- name: Extract version from branch name (for release branches)
id: extract-version
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#hotfix-}
VERSION=${VERSION#release/}
echo "release_version=$VERSION" >> $GITHUB_OUTPUT
- name: Checkout source branch
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set Node 16
uses: actions/setup-node@v3
with:
node-version: 16

- name: Create Github Release
id: create_release
env:
HUSKY: 0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx conventional-github-releaser -p angular
- name: Create pull request into develop
uses: repo-sync/pull-request@v2
with:
source_branch: 'master'
destination_branch: 'develop'
github_token: ${{ secrets.PAT }}
pr_title: "chore(release): pulling master into develop post release v${{ steps.extract-version.outputs.release_version }}"
pr_body: ':crown: *An automated PR*'

- name: Delete hotfix release branch
uses: koj-co/delete-merged-action@master
if: startsWith(github.event.pull_request.head.ref, 'hotfix-release/')
with:
branches: 'hotfix-release/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Delete release branch
uses: koj-co/delete-merged-action@master
if: startsWith(github.event.pull_request.head.ref, 'release/')
with:
branches: 'release/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit c9dd8c0

Please sign in to comment.