Skip to content

Commit

Permalink
ci: release pipeline (#291)
Browse files Browse the repository at this point in the history
* Add workflows

* Update version management

* Add lock files for CI cache

* Add release.config.js

* Re-enable doc generation

* naming nit

* Remove circleci

* Add PR template

* Update docs

* temp clear cache

* Undo clear cache

* temp disable cache

* Added macOS and tvOS tests

* disable flaky macOS tests

* Improve readme

* wording nits

* cache fix
  • Loading branch information
jooohhn authored Oct 7, 2020
1 parent 61da6d3 commit dc65001
Show file tree
Hide file tree
Showing 14 changed files with 467 additions and 18 deletions.
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!---
Thanks for contributing to the Amplitude iOS/tvOS/macOS SDK! 🎉
Please fill out the following sections to help us quickly review your pull request.
--->

### Summary

<!-- What does the PR do? -->

### Checklist

* [ ] Does your PR title have the correct [title format](https://github.com/amplitude/Amplitude-iOS/blob/master/CONTRIBUTING.md#pr-commit-title-conventions)?
* Does your PR have a breaking change?: <!-- Yes or no -->
129 changes: 129 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Release

on:
workflow_dispatch:
inputs:
dryRun:
description: 'Do a dry run to preview instead of a real release'
required: true
default: 'true'

jobs:
authorize:
name: Authorize
runs-on: macos-10.14
steps:
- name: ${{ github.actor }} permission check to do a release
uses: octokit/[email protected]
with:
route: GET /repos/:repository/collaborators/${{ github.actor }}
repository: ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
runs-on: macos-10.14
needs: [authorize]
strategy:
matrix:
ruby-version: ["2.7.x"]
node-version: ["12.x"]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set Xcode 12
run: |
sudo xcode-select -switch /Applications/Xcode_12.app
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}

- name: Cache Bundle Gems and Cocoapods
id: cache-gems-pods
uses: actions/cache@v2
with:
path: |
Pods
vendor/bundle
key: ${{ runner.os }}-ruby-${{ matrix.ruby-version }}-gems-${{ hashFiles('**/Gemfile.lock') }}-pods-${{ hashFiles('**/Podfile.lock') }}

- name: Install Cocoapods
if: steps.cache-gems-pods.outputs.cache-hit != 'true'
run: |
gem install bundler
bundle config path vendor/bundle
bundle install
pod install
- name: iOS Tests
run: |
xcodebuild test \
-workspace Amplitude.xcworkspace \
-scheme Amplitude_iOSTests \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 11,OS=14.0'
# - name: macOS Tests @TODO Fix flaky macOS tests and re-enable
# run: |
# xcodebuild \
# -workspace Amplitude.xcworkspace \
# -scheme Amplitude_macOS \
# -sdk macosx \
# -destination 'platform=macosx' \
# test

- name: tvOS Tests
run: |
xcodebuild \
-workspace Amplitude.xcworkspace \
-scheme Amplitude_tvOS \
-sdk appletvsimulator \
-destination 'platform=tvOS Simulator,name=Apple TV' \
test
- name: Validate Podfile
run: |
pod spec lint
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Semantic Release --dry-run
if: ${{ github.event.inputs.dryRun == 'true'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @google/semantic-release-replace-plugin@1 \
-p @semantic-release/exec@5 \
semantic-release --dry-run
- name: Semantic Release
if: ${{ github.event.inputs.dryRun == 'false'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @google/semantic-release-replace-plugin@1 \
-p @semantic-release/exec@5 \
semantic-release
- name: Generate docs
run: |
appledoc --project-name Amplitude --project-company "Amplitude Inc" --company-id com.amplitude --no-create-docset --output ./doc/ .
43 changes: 43 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Semantic PR Check

on:
pull_request:
types: [opened, synchronize, edited]

jobs:
pr-title-check:
name: Check PR for semantic title
runs-on: ubuntu-18.04
steps:
- name: PR title is valid
if: >
startsWith(github.event.pull_request.title, 'feat:') || startsWith(github.event.pull_request.title, 'feat(') ||
startsWith(github.event.pull_request.title, 'fix:') || startsWith(github.event.pull_request.title, 'fix(') ||
startsWith(github.event.pull_request.title, 'perf:') || startsWith(github.event.pull_request.title, 'perf(') ||
startsWith(github.event.pull_request.title, 'docs:') || startsWith(github.event.pull_request.title, 'docs(') ||
startsWith(github.event.pull_request.title, 'test:') || startsWith(github.event.pull_request.title, 'test(') ||
startsWith(github.event.pull_request.title, 'refactor:') || startsWith(github.event.pull_request.title, 'refactor(') ||
startsWith(github.event.pull_request.title, 'style:') || startsWith(github.event.pull_request.title, 'style(') ||
startsWith(github.event.pull_request.title, 'build:') || startsWith(github.event.pull_request.title, 'build(') ||
startsWith(github.event.pull_request.title, 'ci:') || startsWith(github.event.pull_request.title, 'ci(') ||
startsWith(github.event.pull_request.title, 'chore:') || startsWith(github.event.pull_request.title, 'chore(') ||
startsWith(github.event.pull_request.title, 'revert:') || startsWith(github.event.pull_request.title, 'revert(')
run: |
echo 'Title checks passed'
- name: PR title is invalid
if: >
!startsWith(github.event.pull_request.title, 'feat:') && !startsWith(github.event.pull_request.title, 'feat(') &&
!startsWith(github.event.pull_request.title, 'fix:') && !startsWith(github.event.pull_request.title, 'fix(') &&
!startsWith(github.event.pull_request.title, 'perf:') && !startsWith(github.event.pull_request.title, 'perf(') &&
!startsWith(github.event.pull_request.title, 'docs:') && !startsWith(github.event.pull_request.title, 'docs(') &&
!startsWith(github.event.pull_request.title, 'test:') && !startsWith(github.event.pull_request.title, 'test(') &&
!startsWith(github.event.pull_request.title, 'refactor:') && !startsWith(github.event.pull_request.title, 'refactor(') &&
!startsWith(github.event.pull_request.title, 'style:') && !startsWith(github.event.pull_request.title, 'style(') &&
!startsWith(github.event.pull_request.title, 'build:') && !startsWith(github.event.pull_request.title, 'build(') &&
!startsWith(github.event.pull_request.title, 'ci:') && !startsWith(github.event.pull_request.title, 'ci(') &&
!startsWith(github.event.pull_request.title, 'chore:') && !startsWith(github.event.pull_request.title, 'chore(') &&
!startsWith(github.event.pull_request.title, 'revert:') && !startsWith(github.event.pull_request.title, 'revert(')
run: |
echo 'Pull request title is not valid. Please check github.com/amplitude/Amplitude-JavaScript/blob/master/CONTRIBUTING.md#pr-commit-title-conventions'
exit 1
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Test

on: [push, pull_request]

jobs:
test:
name: Test
runs-on: macos-10.14
strategy:
matrix:
ruby-version: ["2.7.x"]
steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set Xcode 12
run: |
sudo xcode-select -switch /Applications/Xcode_12.app
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}

- name: Cache Bundle Gems and Cocoapods
id: cache-gems-pods
uses: actions/cache@v2
with:
path: |
Pods
vendor/bundle
key: ${{ runner.os }}-ruby-${{ matrix.ruby-version }}-gems-${{ hashFiles('**/Gemfile.lock') }}-pods-${{ hashFiles('**/Podfile.lock') }}

- name: Install Cocoapods
if: steps.cache-gems-pods.outputs.cache-hit != 'true'
run: |
gem install bundler
bundle config path vendor/bundle
bundle install
pod install
- name: iOS Tests
run: |
xcodebuild test \
-workspace Amplitude.xcworkspace \
-scheme Amplitude_iOSTests \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 11,OS=14.0'
# - name: macOS Tests @TODO Fix flaky macOS tests and re-enable
# run: |
# xcodebuild \
# -workspace Amplitude.xcworkspace \
# -scheme Amplitude_macOS \
# -sdk macosx \
# -destination 'platform=macosx' \
# test

- name: tvOS Tests
run: |
xcodebuild \
-workspace Amplitude.xcworkspace \
-scheme Amplitude_tvOS \
-sdk appletvsimulator \
-destination 'platform=tvOS Simulator,name=Apple TV' \
test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ Carthage/Build

doc/
.swiftpm
Podfile.lock
8 changes: 5 additions & 3 deletions Amplitude.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
amplitude_version = "7.1.0" # Version is managed automatically by semantic-release, please don't change it manually

Pod::Spec.new do |s|
s.name = "Amplitude"
s.version = "7.1.0"
s.version = amplitude_version
s.summary = "Amplitude iOS/tvOS/macOS SDK."
s.homepage = "https://amplitude.com"
s.license = { :type => "MIT" }
Expand All @@ -12,7 +14,7 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '10.0'
s.ios.source_files = 'Sources/Amplitude/*.{h,m}'
s.ios.resources = 'Sources/Amplitude/**/*.{der,xib,png}'

s.tvos.deployment_target = '9.0'
s.tvos.source_files = 'Sources/Amplitude/*.{h,m}'
s.tvos.resources = 'Sources/Amplitude/**/*.{der}'
Expand All @@ -21,7 +23,7 @@ Pod::Spec.new do |s|
'Sources/Amplitude/AMPEventExplorer.{h,m}',
'Sources/Amplitude/AMPInfoViewController.{h,m}'
]

s.osx.deployment_target = '10.10'
s.osx.source_files = 'Sources/Amplitude/*.{h,m}'
s.osx.resources = 'Sources/Amplitude/**/*.{der}'
Expand Down
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
### PR Commit Title Conventions

PR titles should follow [conventional commit standards](https://www.conventionalcommits.org/en/v1.0.0/). This helps automate the [release](#release) process.

#### Commit Types ([related to release conditions](#release))

- **Special Case**: Any commit with `BREAKING CHANGES` in the body: Creates major release
- `feat(<optional scope>)`: New features (minimum minor release)
- `fix(<optional scope>)`: Bug fixes (minimum patch release)
- `perf(<optional scope>)`: Performance improvement
- `docs(<optional scope>)`: Documentation updates
- `test(<optional scope>)`: Test updates
- `refactor(<optional scope>)`: Code change that neither fixes a bug nor adds a feature
- `style(<optional scope>)`: Code style changes (e.g. formatting, commas, semi-colons)
- `build(<optional scope>)`: Changes that affect the build system or external dependencies (e.g. Yarn, Npm)
- `ci(<optional scope>)`: Changes to our CI configuration files and scripts
- `chore(<optional scope>)`: Other changes that don't modify src or test files
- `revert(<optional scope>)`: Revert commit

### Release [Amplitude Internal]

Releases are managed by [semantic-release](https://github.com/semantic-release/semantic-release). It is a tool that will scan commits since the last release, determine the next [semantic version number](https://semver.org/), publish, and create changelogs.

#### Release Conditions [Amplitude Internal]

- `BREAKING CHANGES` in the body will do a major release
```
feat(cookies): Create new cookie format
BREAKING CHANGES: Breaks old cookie format
```
- Else `feat` in title will do a `minor` release
`feat(cookies): some changes`
- Else `fix` or `perf` in title will do a `patch` release
`fix: null check bug`
- Else no release
`docs: update website`
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'cocoapods'
Loading

0 comments on commit dc65001

Please sign in to comment.