Skip to content

Commit

Permalink
feat: buildkite ios setup
Browse files Browse the repository at this point in the history
  • Loading branch information
n0izn0iz authored and gfanton committed Feb 4, 2020
1 parent 6213f8a commit 8d77615
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .buildkite/agent_setup/macos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* have an administrator user
* install cli build tools (if you can git it's ok)
* install brew
* install coreutils, gnu-sed, go, yarn with brew
* sudo xcode-select <xcode-path>
* sudo xcodebuild -license
* sudo gem install cocoapods
* sudo gem install bundler
45 changes: 45 additions & 0 deletions .buildkite/agent_setup/macos/create_agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

set -e

SECRETS_DIR=/Users/administrator/secrets

# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=$(greadlink -f "$0")
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=$(dirname "$SCRIPT")

username="$1"
usergroupname=staff

[ -n "$username" ] || {
echo "Error: missing username argument" 1>&2
echo "Usage: $0 <username>" 1>&2
false
}

agent_token_file="$SECRETS_DIR/buildkite-agent-token"
[ -f "$agent_token_file" ] || {
echo "Error: missing buildkite agent token file '$agent_token_file'" 1>&2
false
}
bootstrap_vars="BUILDKITE_AGENT_TOKEN=$(cat $agent_token_file)"

user_home=/Users/$username

sysadminctl -addUser $username

cp -r $SCRIPTPATH/user/* $user_home/
chown -R $username:$usergroupname $user_home

su -l $username -c "$bootstrap_vars make deps"

echo
echo "WARNING: YOU must add this key to the repo host (GitHub)"
cat $user_home/.ssh/id_ed25519.pub

echo
echo "WARNING: If this agent must be in special queues, don't forget to edit tags in '$user_home/.buildkite-agent/buildkite-agent.cfg'"

echo
echo "INFO: To start agent run 'launchctl load /Users/$username/Library/LaunchAgents/com.buildkite.buildkite-agent.plist'"
26 changes: 26 additions & 0 deletions .buildkite/agent_setup/macos/user/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
AGENT_KEY_TYPE=ed25519
BUILDKITE_AGENT_TOKEN ?=xxx

.PHONY: deps
deps: ~/.ssh/id_$(AGENT_KEY_TYPE) \
~/.buildkite-agent \
~/Library/LaunchAgents/com.buildkite.buildkite-agent.plist \


~/.ssh/id_%:
ssh-keygen -t $* -f $@ -P ""

~/.buildkite-agent:
bash -c "`curl -sL https://raw.githubusercontent.com/buildkite/agent/master/install.sh`"
gsed -i 's/^name="%hostname-%n"/name="%hostname-$(shell id -un)-%n"/g' $@/buildkite-agent.cfg
@gsed -i 's/^token="xxx"/token="$(BUILDKITE_AGENT_TOKEN)"/g' $@/buildkite-agent.cfg
@echo sed -i 's/^token="xxx"/token="REDACTED"/g' $@/buildkite-agent.cfg
touch $@

~/Library/LaunchAgents/com.buildkite.buildkite-agent.plist: ~/.buildkite-agent
# Download the launchd config to /Library/LaunchDaemons/
curl --create-dirs -o $@ https://raw.githubusercontent.com/buildkite/agent/master/templates/launchd_local_with_gui.plist
# Set buildkite-agent to be run as the current user (a full user, created via System Prefs)
sed -i '' "s/your-build-user/$(whoami)/g" $@
# Create the agent's log directory with the correct permissions
mkdir -p ~/.buildkite-agent/log && chmod 775 ~/.buildkite-agent/log
15 changes: 15 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ steps:
- "js/packages/berty-app/android/toc.pb"
- "js/packages/berty-app/android/app/build/outputs/bundle/release/app-release.aab"

- label: ios-build
agents:
queue: "macos"
plugins:
- gopath-checkout#v1.0.1:
import: berty.tech/berty
commands:
- set -x
- go get golang.org/x/mobile/cmd/gomobile
- gomobile init
- cd js
- make release.ios.yolo
- find . -name '.ipa'
- find . -name '.app'

- label: js-generate
plugins:
- n0izn0iz/docker#v3.5.4:
Expand Down
9 changes: 5 additions & 4 deletions js/packages/berty-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ release.ios.store: method := app-store
release.ios.store: profile := AppStore
release.ios.store: team-id := WMBQ84HN4T
release.ios.store: release.ios
release.ios: export PWD := $(PWD)
release.ios: platform := ios
release.ios: bundle-id = chat.berty.ios.$(target)
release.ios: version = $(shell git describe --tags --always | cut -d - -f 1,2 | tr - .| tail -c +2)
Expand All @@ -176,9 +177,9 @@ release.ios: export GYM_CLEAN = false
release.ios: export GYM_OPTION_METHOD = $(method)
release.ios: export GYM_OPTION_APP_ID = $(bundle-id)
release.ios: export GYM_OPTION_PROVISIONING_PROFILE = "match $(profile) $(bundle-id)"
release.ios: export GYM_OUTPUT_NAME = $(shell echo $(name) | caser --pascal)
release.ios: export GYM_OUTPUT_NAME = $(shell echo $(name) | $(PWD)/node_modules/.bin/caser --pascal)
release.ios: export GYM_OUTPUT_DIRECTORY = $(dest)
release.ios: export GYM_WORKSPACE = $(PWD)/ios/$(shell echo $(name) | caser --pascal).xcworkspace
release.ios: export GYM_WORKSPACE = $(PWD)/ios/$(shell echo $(name) | $(PWD)/node_modules/.bin/caser --pascal).xcworkspace
release.ios: export GYM_SCHEME = $(target)
release.ios: export GYM_SKIP_PROFILE_DETECTION = true
release.ios: export GYM_INCLUDE_SYMBOLS = false
Expand All @@ -187,13 +188,13 @@ release.ios: deps.ios
$(if $(method),, $(error "method variable not defined"))
# fetch app store profile
cd $(PWD) \
&& $(bundle) exec fastlane run match \
&& fastlane run match \
type:$(shell echo $(method) | sed 's/-//g') \
app_identifier:$(bundle-id) \
readonly:true \
team_id:$(team-id) \
$(if $(git-url), git_url:$(git-url)) \
&& time $(bundle) exec fastlane $(platform) build --verbose
&& time fastlane $(platform) build --verbose

release.android.debug:
release.android.staff:
Expand Down

0 comments on commit 8d77615

Please sign in to comment.