diff --git a/.env.example b/.env.example index aa08f71..c0b4620 100644 --- a/.env.example +++ b/.env.example @@ -3,5 +3,8 @@ ITC_TEAM_ID= TEAM_ID= FIREBASE_APP_ID_IOS= FIREBASE_CLI_TOKEN= -IPA_PATH= RELEASE_NOTE= +MATCH_GIT_URL= +MATCH_KEYCHAIN_NAME= +MATCH_KEYCHAIN_PASSWORD= +CODE_SIGNING_IDENTITY= diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..cc9951c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,65 @@ +# This workflow uses in Template repository only. + +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + distribute: + runs-on: macOS-latest + env: + MINT_PATH: mint/lib + MINT_LINK_PATH: mint/bin + + steps: + - uses: actions/checkout@v2 + - name: Cache Gem + uses: actions/cache@v2 + with: + path: vendor/bundle + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile') }} + restore-keys: | + ${{ runner.os }}-gem- + - name: Cache Mint + uses: actions/cache@v2 + with: + path: mint + key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }} + restore-keys: | + ${{ runner.os }}-mint- + - name: Cache npm + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-mint-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Cache rbenv + uses: actions/cache@v2 + with: + path: /home/runner/.rbenv + key: ${{ runner.os }}-rbenv-${{ hashFiles('**/.ruby-version') }} + restore-keys: | + {{ runner.os }}-rbenv- + - name: Init + run: ./scripts/bootstrap.sh Test com.example.template.Template true + - name: XcodeGen generate + run: mint run xcodegen + - name: Build & Distribute + run: bundle exec fastlane distribute_app + env: + APPLE_ID: ${{ secrets.APPLE_ID }} + ITC_TEAM_ID: ${{ secrets.ITC_TEAM_ID }} + TEAM_ID: ${{ secrets.TEAM_ID }} + FIREBASE_APP_ID_IOS: ${{ secrets.FIREBASE_APP_ID_IOS }} + FIREBASE_CLI_TOKEN: ${{ secrets.FIREBASE_CLI_TOKEN }} + MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }} + MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }} + MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} + CODE_SIGNING_IDENTITY: ${{ secrets.CODE_SIGNING_IDENTITY }} + RELEASE_NOTE: test + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} diff --git a/Gemfile b/Gemfile index ed91cc9..269a6f7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,6 @@ # frozen_string_literal: true source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } -ruby '2.7.1' gem 'fastlane' diff --git a/Gemfile.lock b/Gemfile.lock index 2a7efdf..926165d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -177,8 +177,5 @@ DEPENDENCIES fastlane fastlane-plugin-firebase_app_distribution -RUBY VERSION - ruby 2.7.1p83 - BUNDLED WITH 2.1.4 diff --git a/fastlane/Fastfile b/fastlane/Fastfile index c60ac4a..4167238 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -18,13 +18,39 @@ default_platform(:ios) platform :ios do desc 'Distribute iOS App' lane :distribute_app do + if is_ci? + create_keychain( + name: ENV['MATCH_KEYCHAIN_NAME'], + password: ENV['MATCH_KEYCHAIN_PASSWORD'], + default_keychain: true, + unlock: true, + timeout: 1800, + lock_when_sleeps: false + ) + end + match( + readonly: is_ci, + keychain_name: ENV['MATCH_KEYCHAIN_NAME'], + keychain_password: ENV['MATCH_KEYCHAIN_PASSWORD'] + ) + update_project_provisioning( + xcodeproj: "{Template}.xcodeproj", + profile: ENV["sigh_{BUNDLE_IDENTIFIER}_development_profile-path"], + code_signing_identity: ENV['CODE_SIGNING_IDENTITY'] + ) + build_app( + scheme: "Sample", + export_options: { + method: "development" + } + ) firebase_app_distribution( - app: ENV['FIREBASE_APP_ID_IOS'], - groups: "gotties", - ipa_path: ENV['IPA_PATH'], - release_notes: ENV['RELEASE_NOTE'], - firebase_cli_path: "./node_modules/firebase-tools/lib/bin/firebase.js", - firebase_cli_token: ENV['FIREBASE_CLI_TOKEN'], + app: ENV['FIREBASE_APP_ID_IOS'], + groups: "gotties", + ipa_path: "#{Dir.pwd}/../{Template}.ipa", + release_notes: ENV['RELEASE_NOTE'], + firebase_cli_path: "#{Dir.pwd}/../node_modules/firebase-tools/lib/bin/firebase.js", + firebase_cli_token: ENV['FIREBASE_CLI_TOKEN'], ) end diff --git a/fastlane/Matchfile b/fastlane/Matchfile new file mode 100644 index 0000000..81acd4d --- /dev/null +++ b/fastlane/Matchfile @@ -0,0 +1,8 @@ +require 'dotenv' + +# format: https://{Personal Access Token}:x-oauth-basic@github.com/{Organization}/{Repo name} +git_url(ENV['MATCH_GIT_URL']) + +storage_mode("git") + +type("development") # The default type, can be: appstore, adhoc, enterprise or development diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 81860fe..3f1af6f 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -64,11 +64,16 @@ set_git_hook() { } main() { + project_name=$1 + bundle_identifier=$2 + is_ci=$3 + if ! $is_ci; then + check_depends + fi set_git_hook - check_depends dependencies - replace_project_name $1 - replace_bundle_identifier $2 + replace_project_name $project_name + replace_bundle_identifier $bundle_identifier } main $1 $2