-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
119 lines (88 loc) · 4.03 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh
#
# This source file is part of the Stanford BDGH VirtualMachine project
#
# SPDX-FileCopyrightText: 2023 Stanford University
#
# SPDX-License-Identifier: MIT
#
# Script to document and automate the installation of software for the GitHub Runner environment.
#
# Initial Setup
# Ensure that you have set all the correct credentials in the .env file.
# The script ask for a password at the beginning to execure sudo commands.
# The Xcode installation might require a two factor authentication credential when Xcode is downloaded.
# 1. Setup
# Load credentials from the .env file
set -a
. .env
set +a
# Enable xcode-select without requiering a sudo password.
# https://www.smileykeith.com/2021/08/12/xcode-select-sudoers/
echo "%admin ALL=NOPASSWD: /usr/bin/xcode-select,/usr/bin/xcodebuild -runFirstLaunch" | sudo tee /etc/sudoers.d/xcode
# 2. Install xcpretty
# We install xcpretty right at the beginning to avoid any repeated requests for a password.
sudo gem install xcpretty
# 3. Install homebrew
export NONINTERACTIVE=1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
# 4. Install tools
brew install java
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc
brew install node
brew install firebase-cli
brew install fastlane
# Set the local correctly to work with fastlane
echo 'export LC_ALL=en_US.UTF-8' >> ~/.zshrc
echo 'export LANG=en_US.UTF-8' >> ~/.zshrc
brew install git-lfs
git lfs install
git lfs install --system
# Install xcode & speed up the Xcode download using aria2: https://github.com/XcodesOrg/xcodes
brew install aria2
brew install xcodesorg/made/xcodes
# Required by the GitHub Runner Setup:
brew install jq
# Ensure that everything on the system is up-to-date
brew upgrade
# 5. Test and start the firebase emulator
firebase emulators:exec --project test "echo 'Firebase emulator installed and started successfully!'"
# 6. Install Xcode
# We install Xcode right at the beginning to avoid any interactive requests in the middle of the script like asking for a 2FA authentication code.
# Download Xcode Releases
xcodes install --update --experimental-unxip --empty-trash 15.3
sudo xcode-select -s /Applications/Xcode-15.3.app
xcodebuild -downloadAllPlatforms
xcodes signout
curl -o AppleWWDRCAG3.cer https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain AppleWWDRCAG3.cer
rm -f AppleWWDRCAG3.cer
# 7. Install additional build tools
brew install swiftlint
brew install xcbeautify
brew install peripheryapp/periphery/periphery
# 8. Enable homebrew autoupdate
brew tap homebrew/autoupdate
brew autoupdate start --upgrade
# 9. Install GitHub Action Runners - https://github.com/actions/runner/blob/main/docs/automate.md
brew install jq
# Setup the GitHub Action Runner setup script & copy cleanup scripts
curl -fsSL -o ~/create-latest-svc.sh https://raw.githubusercontent.com/actions/runner/main/scripts/create-latest-svc.sh
chmod 755 ~/create-latest-svc.sh
cp -f ./GitHubActions/cleanup_started.sh ~/cleanup_started.sh
chmod 755 ~/cleanup_started.sh
cp -f ./GitHubActions/cleanup_completed.sh ~/cleanup_completed.sh
chmod 755 ~/cleanup_completed.sh
# Install the runner
cd $HOME
export RUNNER_CFG_PAT=$GITHUB_ACTION_RUNNER_PAT
sh ~/create-latest-svc.sh -s $GITHUB_ACTION_SCOPE -n $GITHUB_ACTION_NAME
rm -f ~/create-latest-svc.sh
# Move the cleanup scripts and the `.env` file in the GitHub Actions Folder to enable an automatic reset of the simulators & cleaning of the working directory.
echo "ACTIONS_RUNNER_HOOK_JOB_STARTED=/Users/$USER/cleanup_started.sh" >> ~/runner/.env
echo "ACTIONS_RUNNER_HOOK_JOB_COMPLETED=/Users/$USER/cleanup_completed.sh" >> ~/runner/.env
# 10. Cleanup
echo "The installation is complete. Ensure that you remove the .env credentials file to avoid leaking information!"