Skip to content

Commit

Permalink
Setup beta builds via Travis (#293)
Browse files Browse the repository at this point in the history
* Setup beta builds via Travis

* Update README

* Final few changes

* Trying to get this to build on CI

* Fix failing tests
  • Loading branch information
ZachOrr authored Nov 20, 2018
1 parent 929cc1c commit b1e1f34
Show file tree
Hide file tree
Showing 17 changed files with 294 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ node_modules
subtrees/the-blue-alliance-react/ios/*
subtrees/the-blue-alliance-react/ios.zip

GoogleService-Info.plist
Secrets.plist

# fastlane specific
Expand All @@ -52,3 +51,4 @@ fastlane/test_output

# derived data
fastlane/derived_data
*.dSYM.zip
20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
osx_image: xcode10.1
language: swift

branches:
only:
- master
stages:
- name: test
- name: beta
if: (type == push) AND (branch == master) AND (commit_message =~ /^\[beta\]/)

cache:
bundler: true
Expand All @@ -15,8 +16,15 @@ install:
- cd subtrees/the-blue-alliance-react && npm install && cd ../..
- bundle install
- bundle exec pod install --repo-update
- cp mock-GoogleService-Info.plist the-blue-alliance-ios/GoogleService-Info.plist
- cp mock-Secrets.plist the-blue-alliance-ios/Secrets.plist
- bundle exec fastlane setup_ci

script:
- bundle exec fastlane test
jobs:
include:
- stage: test
name: "Unit Tests"
script: bundle exec fastlane test_unit
# - script: bundle exec fastlane test_ui
# name: "UI Tests"
- stage: beta
script: bundle exec fastlane beta
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ GEM
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
fastimage (2.1.4)
fastlane (2.105.1)
fastlane (2.108.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0)
Expand Down Expand Up @@ -113,10 +113,10 @@ GEM
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
signet (~> 0.9)
googleauth (0.6.6)
googleauth (0.6.7)
faraday (~> 0.12)
jwt (>= 1.4, < 3.0)
memoist (~> 0.12)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (~> 0.7)
Expand Down Expand Up @@ -154,7 +154,7 @@ GEM
ruby-macho (1.1.0)
rubyzip (1.2.2)
security (0.1.3)
signet (0.9.2)
signet (0.11.0)
addressable (~> 2.3)
faraday (~> 0.9)
jwt (>= 1.5, < 3.0)
Expand All @@ -179,7 +179,7 @@ GEM
unf_ext (0.0.7.5)
unicode-display_width (1.4.0)
word_wrap (1.0.0)
xcodeproj (1.6.0)
xcodeproj (1.7.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand All @@ -198,4 +198,4 @@ DEPENDENCIES
fastlane

BUNDLED WITH
1.16.2
1.17.1
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ These should be done after you've cloned the project and navigated to the projec

Setup Firebase
---
The Blue Alliance's mobile apps depend on Firebase. We configure Firebase in The Blue Alliance for iOS using a `GoogleService-Info.plist` file, provided by Firebase. The production plist isn't checked in to source control, since it contains an API key. You can setup your own Firebase application to develop against.
The Blue Alliance's mobile apps depend on Firebase. We configure Firebase in The Blue Alliance for iOS using a `GoogleService-Info.plist` file, provided by Firebase. You can setup your own Firebase application to develop against.

1. Navigate to the [Firebase Console](https://console.firebase.google.com/u/0/)
2. Click `Add Project`
Expand Down Expand Up @@ -91,7 +91,7 @@ Before building in Xcode, make sure you've setup a Firebase project, as describe
* On the left sidebar, under `Targets` click `The Blue Alliance`
* Click the `General` tab along the top bar
* Change `Bundle Identifier` to the bundle identifier you set during Firebase setup
5. Add your `GoogleService-Info.plist` is in the `the-blue-alliance-ios/the-blue-alliance-ios` folder. If linked properly, the `GoogleService-Info.plist` file in the Xcode project navigation should go from being red to being black
5. Replace the existing `GoogleService-Info.plist` is in the `the-blue-alliance-ios/the-blue-alliance-ios` folder.
6. Build and run The Blue Alliance for iOS!

Contributing
Expand Down
1 change: 1 addition & 0 deletions changelogs/v1.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hey y'all - welcome to the initial release of The Blue Alliance for iOS!
7 changes: 1 addition & 6 deletions fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
app_identifier "com.the-blue-alliance.tba" # The bundle identifier of your app
# apple_id "" # Your Apple email address

team_id "[[DEV_PORTAL_TEAM_ID]]" # Developer Portal Team ID

# you can even provide different app identifiers, Apple IDs and team names per lane:
# More information: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Appfile.md
team_id "LKZ8X6P249"
170 changes: 151 additions & 19 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command
default_platform :ios

setup_travis
platform :ios do

# If you want to automatically update fastlane if a new version is available:
# update_fastlane
desc "Setup CI"
lane :setup_ci do
setup_travis
setup_secrets
setup_url_schemes
update_project_team
end

default_platform :ios
## CI Setup Lanes ##

platform :ios do
desc "Setup Secrets.plist file (used by CI)"
private_lane :setup_secrets do
set_info_plist_value(path: "the-blue-alliance-ios/Secrets.plist", key: "tba_api_key", value: ENV['TBA_API_KEY'])
end

desc "Runs all the tests"
lane :test do
test_unit
# test_ui
desc "Setup URL schemes in our project"
private_lane :setup_url_schemes do
# Setup Google callback URL from GoogleService-Info.plist
identifier = get_info_plist_value(path: "the-blue-alliance-ios/GoogleService-Info.plist", key: "REVERSED_CLIENT_ID")
update_url_schemes(path: "the-blue-alliance-ios/Info.plist", url_schemes: [identifier])
end

desc "Run only the unit tests"
private_lane :test_unit do
## End CI Setup Lanes ##

## Testing Lanes ##

desc "Run unit tests"
lane :test_unit do
# Build for unit tests
run_tests(
scheme: "tba-unit-tests",
Expand All @@ -29,14 +39,13 @@ platform :ios do
# Run unit tests
run_tests(
scheme: "tba-unit-tests",
devices: ["iPhone X (11.4)", "iPhone X (12.1)"],
derived_data_path: "fastlane/derived_data/derived_data_unit",
test_without_building: true
)
end

desc "Run only the UI tests on 3 devices (square device, notch device, and iPad) and two platforms (iOS 11.4 and iOS 12)"
private_lane :test_ui do
desc "Run UI tests"
lane :test_ui do
# Build for UI tests
run_tests(
scheme: "tba-ui-tests",
Expand All @@ -46,12 +55,135 @@ platform :ios do
# Run UI tests
run_tests(
scheme: "tba-ui-tests",
devices: ["iPhone X (11.4)", "iPhone X (12.0)"],
derived_data_path: "fastlane/derived_data/derived_data_ui",
test_without_building: true
)
end

## End Testing Lanes ##

## Create A New Version Lanes ##

desc "Create a new app version (major, minor, patch, build) by bumping the version number and creating a changelog"
lane :new_version do |options|
version_type = options[:version_type]
# Bump version accordingly
bump_version(version_type: version_type)
# Create new changelog file
version = "v#{get_version_number}"
if version_type == "build"
version = current_git_tag
end
sh("touch", "../changelogs/#{version}")
# Commit our version bump and changelog file
commit_version_bump(message: "[skip ci] New version - #{version}", xcodeproj: "the-blue-alliance-ios.xcodeproj", include: "changelogs/#{version}")
end

desc "Bump the build version (major, minor, patch) and/or build number (build)"
private_lane :bump_version do |options|
version_type = options[:version_type]
if version_type != "build"
increment_version_number(bump_type: version_type)
end
increment_build_number
end

## End Create A New Version Lanes ##

desc "Bump version and push if necessary"
private_lane :ensure_version_bump do
if !git_tag_exists(tag: current_git_tag)
UI.success("`#{current_git_tag}` is a new version, all good! 💪")
else
UI.user_error!("A tag with the name `#{current_git_tag}` already exists! Run `fastlane bump_version` to generate a new version.")
end
end

## Release Lanes ##

desc "Upload a new beta build to TestFlight"
lane :beta do
ship
pilot(changelog: build_changelog, distribute_external: true, wait_processing_interval: 300) # Upload to TestFlight
ship_github(is_prerelease: true) # Create GitHub release
slack(message: "#{current_git_tag} uploaded to TestFlight")
end

desc "Upload a new build to the App Store"
lane :app_store do
# ship
# deliver
# ship_github(is_prerelease: false) # Create GitHub release
# slack(message: "#{current_git_tag} shipped to the App Store")
end

## End Release Lanes ##

## Shipping Lanes for Release Lanes ##

desc "Perform pre-ship tasks"
private_lane :ship do
ensure_git_status_clean # Ensure we're in a clean repo before uploading
ensure_git_branch # Ensure we're on master before shipping
ensure_version_bump # Ensure we're on a new version

match(type: "appstore", readonly: true) # Sync our code signing with Match
# TODO: get_push_certificate, once we can manage uploading to Firebase preferrably

gym(scheme: "The Blue Alliance") # Build our app
end

private_lane :ship_github do |options|
set_github_release(
repository_name: "the-blue-alliance/the-blue-alliance-ios",
api_token: ENV["GITHUB_TOKEN"],
name: current_git_tag,
tag_name: current_git_tag,
commitish: commit,
description: github_changelog,
is_prerelease: options[:is_prerelease] ? true : false,
upload_assets: ["The Blue Alliance.ipa", "The Blue Alliance.app.dSYM.zip"]
)
end

## End Shipping Lanes for Release Lanes ##

## Internal Lanes for Shipping Lanes ##

private_lane :current_git_tag do
"v#{get_version_number}b#{get_build_number}"
end

private_lane :changelog do |options|
version = options[:version]
File.read("../changelogs/#{version}") rescue "No changelog for #{version}"
end

private_lane :version_changelog do
# Use our version changelog (no build number) - ex: `v1.0.0`
version = "v#{get_version_number}"
changelog(version: version)
end

private_lane :build_changelog do
# Use our build changelog - ex: `v1.0.0b6`
version = current_git_tag
changelog(version: version)
end

private_lane :github_changelog do
"## Release Notes\n#{version_changelog}\n## Changelog\n#{release_changelog}"
end

lane :release_changelog do
changelog_from_git_commits(
pretty: "{{[%h|https://github.com/the-blue-alliance/the-blue-alliance-ios/commit/%h]}} [%an]: %s",
merge_commit_filtering: "exclude_merges"
)
end

## End Internal Lanes for Shipping Lanes ##

end

error do |lane, exception|
Expand Down
4 changes: 4 additions & 0 deletions fastlane/Matchfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
git_url("git@github.com:ZachOrr/tba-ios-certificates.git")

type("appstore")
readonly(true)
41 changes: 38 additions & 3 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,46 @@ or alternatively using `brew cask install fastlane`

# Available Actions
## iOS
### ios test
### ios setup_secrets
```
fastlane ios test
fastlane ios setup_secrets
```
Runs all the tests
Setup Secrets.plist file (used by CI)
### ios setup_url_schemes
```
fastlane ios setup_url_schemes
```
Setup URL schemes in our project
### ios test_unit
```
fastlane ios test_unit
```
Run unit tests
### ios test_ui
```
fastlane ios test_ui
```
Run UI tests
### ios new_version
```
fastlane ios new_version
```
Create a new app version (major, minor, patch, build) by bumping the version number and creating a changelog
### ios beta
```
fastlane ios beta
```
Upload a new beta build to TestFlight
### ios app_store
```
fastlane ios app_store
```
Upload a new build to the App Store
### ios release_changelog
```
fastlane ios release_changelog
```


----

Expand Down
2 changes: 1 addition & 1 deletion fastlane/Scanfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
workspace("the-blue-alliance-ios.xcworkspace")
devices(["iPhone X (11.4)", "iPhone X (12.1)"])
disable_concurrent_testing(true)
skip_slack(true)
Loading

0 comments on commit b1e1f34

Please sign in to comment.